Skip to content

Commit c7f61c4

Browse files
datho7561robstryker
authored andcommitted
Fix not reporting reference to java.lang.Object
... since it had `null` as the IResource. It should be reported, and `null` should be used as the IReosurce. Signed-off-by: David Thompson <[email protected]>
1 parent 707f8cb commit c7f61c4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/core/search/matching/DOMTypeReferenceLocator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import org.eclipse.jdt.core.search.TypeDeclarationMatch;
7171
import org.eclipse.jdt.core.search.TypeReferenceMatch;
7272
import org.eclipse.jdt.internal.core.ClassFileWorkingCopy;
73+
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
7374
import org.eclipse.jdt.internal.core.JavaElement;
7475
import org.eclipse.jdt.internal.core.search.DOMASTNodeUtils;
7576
import org.eclipse.jdt.internal.core.search.LocatorResponse;
@@ -868,6 +869,10 @@ private int resolveLevelForTypeBindingDeclarationOfReferencedTypes(ITypeBinding
868869
if( je != null && !this.foundElements.contains(je) && DOMASTNodeUtils.isWithinRange(node, enclosing)) {
869870
ISourceReference sr = je instanceof ISourceReference ? (ISourceReference)je : null;
870871
IResource r = je.getResource();
872+
boolean isExternal = false;
873+
if (r == null && je.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT) instanceof JarPackageFragmentRoot jpfRoot) {
874+
isExternal = true;
875+
}
871876
ISourceRange srg = null;
872877
ISourceRange nameRange = null;
873878
try {
@@ -877,7 +882,7 @@ private int resolveLevelForTypeBindingDeclarationOfReferencedTypes(ITypeBinding
877882
// ignore
878883
}
879884
ISourceRange rangeToUse = (nameRange == null) ? srg : nameRange;
880-
if( rangeToUse != null && r != null) {
885+
if( rangeToUse != null && (r != null || isExternal)) {
881886
TypeDeclarationMatch tdm = new TypeDeclarationMatch(je, newLevel,
882887
rangeToUse.getOffset(), rangeToUse.getLength(),
883888
locator.getParticipant(), r);
@@ -888,6 +893,7 @@ private int resolveLevelForTypeBindingDeclarationOfReferencedTypes(ITypeBinding
888893
// ignore
889894
}
890895
}
896+
891897
}
892898
return IMPOSSIBLE_MATCH;
893899
}

0 commit comments

Comments
 (0)