ruff
ffa824e0 - [red-knot] Add `Type.definition` method (#17153)

Commit
174 days ago
[red-knot] Add `Type.definition` method (#17153) ## Summary This is a follow up to the goto type definition PR. Specifically, that we want to avoid exposing too many semantic model internals publicly. I want to get some feedback on the approach taken. I think it goes into the right direction but I'm not super happy with it. The basic idea is that we add a `Type::definition` method which does the "goto type definition". The parts that I think make it awkward: * We can't directly return `Definition` because we don't create a `Definition` for modules (but we could?). Although I think it makes sense to possibly have a more public wrapper type anyway? * It doesn't handle unions and intersections. Mainly because not all elements in an intersection may have a definition and we only want to show a navigation target for intersections if there's only a single positive element (besides maybe `Unknown`). An alternative design or an addition to this design is to introduce a `SemanticAnalysis(Db)` struct that has methods like `type_definition(&self, type)` which explicitly exposes the methods we want. I don't feel comfortable design this API yet because it's unclear how fine granular it has to be (and if it is very fine granular, directly using `Type` might be better after all) ## Test Plan `cargo test`
Author
Parents
Loading