Skip to content

Commit

Permalink
Fix testDeclarationOfReferencedTypes01 and others
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 19, 2024
1 parent ff2db38 commit e645b35
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class TypeReferenceLocator extends PatternLocator {

private final int fineGrain;
private final Map<QualifiedTypeReference, List<TypeBinding>> recordedResolutions = new HashMap<>();
private List<IJavaElement> foundElements = new ArrayList<>();

public TypeReferenceLocator(TypeReferencePattern pattern) {

Expand Down Expand Up @@ -1004,6 +1005,7 @@ public void recordResolution(QualifiedTypeReference typeReference, TypeBinding r
public String toString() {
return "Locator for " + this.pattern.toString(); //$NON-NLS-1$
}

@Override
public int resolveLevel(org.eclipse.jdt.core.dom.ASTNode node, IBinding binding, MatchLocator locator) {
if (binding == null) {
Expand Down Expand Up @@ -1039,7 +1041,7 @@ public int resolveLevel(org.eclipse.jdt.core.dom.ASTNode node, IBinding binding,
// We don't add this node. We manually add the declaration
ITypeBinding t2 = ((ITypeBinding) binding).getTypeDeclaration();
IJavaElement je = t2 == null ? null : t2.getJavaElement();
if( je != null && DOMASTNodeUtils.isWithinRange(node, enclosing)) {
if( je != null && !this.foundElements.contains(je) && DOMASTNodeUtils.isWithinRange(node, enclosing)) {
ISourceReference sr = je instanceof ISourceReference ? (ISourceReference)je : null;
IResource r = null;
ISourceRange srg = null;
Expand All @@ -1058,6 +1060,7 @@ public int resolveLevel(org.eclipse.jdt.core.dom.ASTNode node, IBinding binding,
rangeToUse.getOffset(), rangeToUse.getLength(),
locator.getParticipant(), r);
try {
foundElements.add(je);
locator.report(tdm);
} catch(CoreException ce) {
// ignore
Expand Down

0 comments on commit e645b35

Please sign in to comment.