[red-knot] Add 'Goto type definition' to the playground#17055
Merged
MichaReiser merged 1 commit intomainfrom Apr 2, 2025
Merged
[red-knot] Add 'Goto type definition' to the playground#17055MichaReiser merged 1 commit intomainfrom
MichaReiser merged 1 commit intomainfrom
Conversation
Contributor
|
b1f53a8 to
a950f23
Compare
285e071 to
54c359b
Compare
a950f23 to
debd0c8
Compare
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Pull Request Overview
This PR adds a “Goto type definition” feature to the playground by leveraging the existing LSP infrastructure and updating both the frontend editor and the Rust backend.
- Introduces a helper method to detect Python files in Files.tsx.
- Updates the Editor.tsx to register a type definition provider and handle file model creation and switching.
- Adds a new Rust function in red_knot_wasm to power go-to-type-definition and updates dependency configuration.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| playground/knot/src/Editor/Files.tsx | Added helper function to check if a file is a Python file |
| playground/knot/src/Editor/Editor.tsx | Updated editor API to support type definition operations and file switching |
| playground/knot/src/Editor/Chrome.tsx | Modified integration to pass new props to the editor |
| crates/red_knot_wasm/src/lib.rs | Added Rust function for type definition lookup and enhanced range conversion |
| crates/red_knot_wasm/Cargo.toml | Added dependency on red_knot_ide |
| crates/red_knot_ide/src/lib.rs | Implemented file_range accessor for improved integration |
Comments suppressed due to low confidence (2)
playground/knot/src/Editor/Editor.tsx:210
- [nitpick] The variable name 'selectedFile' might be misleading if it represents a file identifier. Consider renaming it to 'selectedFileId' for enhanced clarity.
const selectedFile = this.props.current.files.selected;
playground/knot/src/Editor/Editor.tsx:260
- [nitpick] The name 'fileId' might benefit from additional context (e.g. 'targetFileId') to clarify that it is derived from a file lookup based on the resource URI.
const fileId = files.index.find((file) => { return Uri.file(file.name).toString() === resource.toString(); })?.id;
Contributor
|
9cf6900 to
d6aa201
Compare
debd0c8 to
ae875e7
Compare
d6aa201 to
c8b07ce
Compare
0229ed9 to
b9b659c
Compare
b9b659c to
68d506e
Compare
dcreager
added a commit
that referenced
this pull request
Apr 3, 2025
* origin/main: (35 commits) [red-knot] Callable types are disjoint from literals (#17160) [red-knot] Fix inference for `pow` between two literal integers (#17161) [red-knot] Add GitHub PR annotations when mdtests fail in CI (#17150) [red-knot] Fix equivalence of differently ordered unions that contain `Callable` types (#17145) [red-knot] Add initial set of tests for unreachable code (#17159) [`airflow`] Move `AIR302` to `AIR301` and `AIR303` to `AIR302` (#17151) ruff_db: simplify lifetimes on `DiagnosticDisplay` [red-knot] Detect division-by-zero in unions and intersections (#17157) [`airflow`] Add autofix infrastructure to `AIR302` name checks (#16965) [`flake8-bandit`] Mark `str` and `list[str]` literals as trusted input (`S603`) (#17136) [`airflow`] Add autofix for `AIR302` attribute checks (#16977) [`airflow`] Extend `AIR302` with additional symbols (#17085) [`airflow`] Move `AIR301` to `AIR002` (#16978) [`airflow`] Add autofix for `AIR302` method checks (#16976) ruff_db: switch diagnostic rendering over to `std::fmt::Display` [red-knot] Add 'Goto type definition' to the playground (#17055) red_knot_ide: update snapshots red_knot_python_semantic: remove comment about `TypeCheckDiagnostic` ruff_db: delete most of the old diagnostic code red_knot: use `Diagnostic` inside of red knot ...
maxmynter
pushed a commit
to maxmynter/ruff
that referenced
this pull request
Apr 3, 2025
) ## Summary This PR adds Goto type definition to the playground, using the same infrastructure as the LSP. The main *challenge* with implementing this feature was that the editor can now participate in which tab is open. ## Known limitations The same as for the LSP. Most notably, navigating to types defined in typeshed isn't supported. ## Test Plan https://github.com/user-attachments/assets/22dad7c8-7ac7-463f-b066-5d5b2c45d1fe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds Goto type definition to the playground, using the same infrastructure as the LSP.
The main challenge with implementing this feature was that the editor can now participate in which tab is open.
Known limitations
The same as for the LSP. Most notably, navigating to types defined in typeshed isn't supported.
Test Plan
Screen.Recording.2025-04-01.at.13.20.13.mov