EA-49302 - NPE: UnusedDeclarationInspection.checkForReachables

This commit is contained in:
Alexey Kudravtsev
2013-10-25 13:42:20 +04:00
parent e59b7dab25
commit e85708a1a9
2 changed files with 6 additions and 6 deletions
@@ -391,7 +391,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool {
});
if (isAddNonJavaUsedEnabled()) {
checkForReachables();
checkForReachables(globalContext);
final StrictUnreferencedFilter strictUnreferencedFilter = new StrictUnreferencedFilter(this, globalContext);
ProgressManager.getInstance().runProcess(new Runnable() {
@Override
@@ -520,7 +520,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool {
public boolean queryExternalUsagesRequests(@NotNull InspectionManager manager,
@NotNull GlobalInspectionContext globalContext,
@NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
checkForReachables();
checkForReachables(globalContext);
final RefFilter filter = myPhase == 1 ? new StrictUnreferencedFilter(this, globalContext) :
new RefUnreachableFilter(this, globalContext);
final boolean[] requestAdded = {false};
@@ -647,16 +647,16 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool {
}
void checkForReachables() {
void checkForReachables(@NotNull final GlobalInspectionContext context) {
CodeScanner codeScanner = new CodeScanner();
// Cleanup previous reachability information.
getContext().getRefManager().iterate(new RefJavaVisitor() {
context.getRefManager().iterate(new RefJavaVisitor() {
@Override
public void visitElement(@NotNull RefEntity refEntity) {
if (refEntity instanceof RefJavaElement) {
final RefJavaElementImpl refElement = (RefJavaElementImpl)refEntity;
if (!((GlobalInspectionContextBase)getContext()).isToCheckMember(refElement, UnusedDeclarationInspection.this)) return;
if (!((GlobalInspectionContextBase)context).isToCheckMember(refElement, UnusedDeclarationInspection.this)) return;
refElement.setReachable(false);
}
}
@@ -334,7 +334,7 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
@Override
public void updateContent() {
getTool().checkForReachables();
getTool().checkForReachables(getContext());
myPackageContents = new HashMap<String, Set<RefEntity>>();
getContext().getRefManager().iterate(new RefJavaVisitor() {
@Override public void visitElement(@NotNull RefEntity refEntity) {