plugin: anchor generated top entry point on the design class#403
Merged
Conversation
The `@top` (`TopAnnotPhase`) generated `top_<Design>` entry-point object was created without a real source span on its definition tree. As a result `ExtractSemanticDB` recorded it only in the SemanticDB `Symbols` section with no `Occurrences` entry (the symbol name `top_Foo` is not textually present in the source), so Metals had no position to anchor the `run`/`debug` code lenses on and fell back to placing them at the very top of the file. Position the generated module symbol (`coord`) and its definition tree on the design class's name span. Combined with the matching SemanticDB change, this makes the generated entry point appear as a definition occurrence anchored on the design class, so the `run`/`debug` lenses show up directly above the class that introduces the entry point. Using the class name (rather than the `@top` annotation) also keeps this working if the design no longer needs an explicit `@top` annotation. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Uze3nGgdwa8W2wkfoaDoHR
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.
The
@top(TopAnnotPhase) generatedtop_<Design>entry-point object was created without a real source span on its definition tree. As a resultExtractSemanticDBrecorded it only in the SemanticDBSymbolssection with noOccurrencesentry (the symbol nametop_Foois not textually present in the source), so Metals had no position to anchor therun/debugcode lenses on and fell back to placing them at the very top of the file.Position the generated module symbol (
coord) and its definition tree on the design class's name span. Combined with the matching SemanticDB change, this makes the generated entry point appear as a definition occurrence anchored on the design class, so therun/debuglenses show up directly above the class that introduces the entry point. Using the class name (rather than the@topannotation) also keeps this working if the design no longer needs an explicit@topannotation.Claude-Session: https://claude.ai/code/session_01Uze3nGgdwa8W2wkfoaDoHR