Skip to content

Commit

Permalink
Fix testDeclarationOfAccessedFields2 and 3
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Stryker <stryker@redhat.com>
  • Loading branch information
Rob Stryker committed Nov 12, 2024
1 parent d9eaece commit 6dd1174
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public int match(FieldDeclaration node, MatchingNodeSet nodeSet) {
}
@Override
public int match(VariableDeclaration node, MatchingNodeSet nodeSet, MatchLocator locator) {
if (!this.pattern.findDeclarations) {
if (!this.pattern.findDeclarations && !this.isDeclarationOfAccessedFieldsPattern) {
return IMPOSSIBLE_MATCH;
}
if (node.getLocationInParent() != org.eclipse.jdt.core.dom.FieldDeclaration.FRAGMENTS_PROPERTY) {
Expand All @@ -132,7 +132,7 @@ public int match(VariableDeclaration node, MatchingNodeSet nodeSet, MatchLocator
referencesLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH;

int declarationsLevel = IMPOSSIBLE_MATCH;
if (this.pattern.findDeclarations &&
if ((this.pattern.findDeclarations || this.isDeclarationOfAccessedFieldsPattern) &&
matchesName(this.pattern.name, node.getName().getIdentifier().toCharArray()) &&
this.pattern instanceof FieldPattern fieldPattern &&
matchesTypeReference(fieldPattern.typeSimpleName, ((org.eclipse.jdt.core.dom.FieldDeclaration)node.getParent()).getType())) {
Expand Down Expand Up @@ -273,7 +273,7 @@ protected void matchReportReference(ASTNode reference, IJavaElement element, Bin
}
@Override
public int match(Name name, MatchingNodeSet nodeSet, MatchLocator locator) {
if (this.pattern.findDeclarations) {
if (this.pattern.findDeclarations || this.isDeclarationOfAccessedFieldsPattern) {
return IMPOSSIBLE_MATCH; // already caught by match(VariableDeclaration)
}

Expand Down

0 comments on commit 6dd1174

Please sign in to comment.