accept @Nullable scope EA-58099 - NPE: RefManagerImpl.findAllDeclarations

This commit is contained in:
Anna Kozlova
2014-07-25 17:41:43 +02:00
parent 36ee5e09d5
commit 9e30dc382c
4 changed files with 8 additions and 4 deletions
@@ -194,7 +194,7 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
final SearchScope searchScope = new GlobalSearchScope(refManager.getProject()) {
@Override
public boolean contains(@NotNull VirtualFile file) {
return !scope.contains(file) || file.getFileType() != StdFileTypes.JAVA;
return scope != null && !scope.contains(file) || file.getFileType() != StdFileTypes.JAVA;
}
@Override
@@ -394,7 +394,7 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
@Override
public boolean execute(PsiReference reference) {
AnalysisScope scope = context.getRefManager().getScope();
if (scope.contains(reference.getElement()) && reference.getElement().getLanguage() == StdLanguages.JAVA ||
if (scope != null && scope.contains(reference.getElement()) && reference.getElement().getLanguage() == StdLanguages.JAVA ||
PsiTreeUtil.getParentOfType(reference.getElement(), PsiDocComment.class) != null) {
return true;
}
@@ -132,7 +132,7 @@ public class UnusedParametersInspection extends GlobalJavaBatchInspectionTool {
int idx = refParameter.getIndex();
final boolean[] found = {false};
for (int i = 0; i < derived.length && !found[0]; i++) {
if (!scope.contains(derived[i])) {
if (scope == null || !scope.contains(derived[i])) {
final PsiParameter[] parameters = derived[i].getParameterList().getParameters();
if (parameters.length >= idx) continue;
PsiParameter psiParameter = parameters[idx];
@@ -47,6 +47,7 @@ public abstract class RefManager {
*
* @return the analysis scope.
*/
@Nullable
public abstract AnalysisScope getScope();
/**
@@ -149,6 +149,7 @@ public class RefManagerImpl extends RefManager {
}
}
@Nullable
@Override
public AnalysisScope getScope() {
return myScope;
@@ -304,7 +305,9 @@ public class RefManagerImpl extends RefManager {
if (!myDeclarationsFound) {
long before = System.currentTimeMillis();
final AnalysisScope scope = getScope();
scope.accept(myProjectIterator);
if (scope != null) {
scope.accept(myProjectIterator);
}
myDeclarationsFound = true;
LOG.info("Total duration of processing project usages:" + (System.currentTimeMillis() - before));