eclipse-jdt / eclipse-jdt/eclipse.jdt.core

missing value in annotation attributes causes NodeFinder to return wrong result

Open
#3,260 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.