Summary: | searchenging NPE in searchDeclarationsOfReferencedTypes | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Frank Sauer <frank.sauer> |
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 2.1 | ||
Target Milestone: | 3.0 M1 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Frank Sauer
2003-05-09 12:05:42 EDT
here's the offending code:
line marked with >>>
TypeDeclaration typeDecl = ((SourceTypeBinding)
typeBinding).scope.referenceContext;
I guess either typeBinding or its scope must be null for some reason...
Note that for some packages it works, others cause this problem.
private void reportDeclaration(TypeBinding typeBinding, int maxType,
MatchLocator locator) throws CoreException {
IType type = locator.lookupType(typeBinding);
if (type == null) return; // case of a secondary type
IResource resource = type.getResource();
boolean isBinary = type.isBinary();
IBinaryType info = null;
if (isBinary) {
if (resource == null) {
resource = type.getJavaProject().getProject();
}
info = locator.getBinaryInfo
((org.eclipse.jdt.internal.core.ClassFile)type.getClassFile(), resource);
}
while (maxType >= 0 && type != null) {
if (!this.knownTypes.contains(type)) {
if (isBinary) {
locator.reportBinaryMatch(resource, type, info,
IJavaSearchResultCollector.EXACT_MATCH);
} else {
>>> TypeDeclaration typeDecl = ((SourceTypeBinding)
typeBinding).scope.referenceContext;
locator.report(resource, typeDecl.sourceStart,
typeDecl.sourceEnd, type, IJavaSearchResultCollector.EXACT_MATCH);
}
this.knownTypes.add(type);
}
if (typeBinding instanceof BinaryTypeBinding) {
typeBinding = ((BinaryTypeBinding)
typeBinding).enclosingType();
} else {
typeBinding = ((SourceTypeBinding)
typeBinding).enclosingType();
}
IJavaElement parent = type.getParent();
if (parent instanceof IType) {
type = (IType)parent;
} else {
type = null;
}
maxType--;
}
}
never mind, case of RTFM. Doesn't work with packages..... Sorry Perhaps a feature request? Search for all declarations of referenced types in a package? Now I have to do multiple searches to get the same effect. As Frank noticed this is not supported, but we should not get a NPE. Added protection against this case. We now return no result. Added regression test JavaSearchTests.testDeclarationOfReferencedTypes7() Verified. |