Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing value in annotation attributes causes NodeFinder to return wrong result #3260

Open
martinlippert opened this issue Nov 6, 2024 · 1 comment

Comments

@martinlippert
Copy link

I am using NodeFinder to identify AST nodes at a specific position in the document. When using this for positions inside of annotations while having missing pieces in the annotation attributes at the same time, I am experiencing difficulties. The concrete case is (the <*> is not part of the doc, just marks the position in the doc where I am trying to find the node):

@ConditionalOnProperty(name=<*>)

NodeFinder for the <*> position returns the inserted $missing$ SimpleName node. Correct behavior, I think.

@ConditionalOnProperty(prefix = "else", name=<*>)

NodeFinder at <*> does not find the $missing$ node, but returns the surrounding TypeDeclaration node (because the annotation mentioned here is on a type).

It looks to me like the length of the NormalAnnotation node is slightly off (-1) in this case, so that the NodeFinder thinks that the <*> is not covered by the annotation, but only by the surrounding node (the TypeDeclaration). Whereas in the first case (where it works), the annotation node seems to cover that position, so that NodeFinder can find the $missing$ node.

@martinlippert
Copy link
Author

@stephan-herrmann Interested in taking a look here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant