Repository navigation
Resolve names in annotation values for navigation - #12
Merged
Merged
Conversation
Names in annotation element values (@produces(MediaType.TEXT_PLAIN), @foo(BAR)) are not part of any body's inference, so go to definition found nothing for them. Resolve them as constant expression names: fields of the enclosing classes, statically imported fields, then types and packages, following qualified names through classes and packages.
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.
Go to definition on a name inside an annotation value, such as
MediaTypeorTEXT_PLAINin@Produces(MediaType.TEXT_PLAIN), reported no target. These expressions are not part of any body's inference, soclassify_name_refhad nothing to look up.When body resolution finds nothing inside an annotation argument list, the name is now resolved as a constant expression name. A simple name is looked up as a field of the enclosing classes (inherited fields included), then a statically imported field (single imports before on-demand ones), then a type, then a package. A qualified name resolves its qualifier to a class or package, then finds a field, member class, class in the package or subpackage.
How it was verified
goto_definition_in_annotation_valuescovers method and class annotations, a fully qualified name, a static import, an array value with named elements, an enum constant, a nested class field and a constant of the enclosing class. Before the change every case returned no target.cargo test -p hir -p ide -p ide-db -p ide-diagnostics -p ide-completionpasses.cargo clippy -p hir -p ide --all-targets -- -D warningsis clean, andcargo fmt --all --checkpasses.