EA-52004 (NPE: CyclicClassDependencyInspection.checkElement)

This commit is contained in:
Bas Leijdekkers
2013-11-20 15:15:05 +01:00
parent d9a30c6520
commit 148ca98358
3 changed files with 7 additions and 4 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package com.intellij.codeInspection.reference;
import com.intellij.psi.PsiClass;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Set;
@@ -65,6 +66,7 @@ public interface RefClass extends RefJavaElement {
boolean isSelfInheritor(PsiClass psiClass);
@Nullable
@Override
PsiClass getElement();
}
@@ -211,6 +211,7 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass {
return isSelfInheritor(psiClass, new ArrayList<PsiClass>());
}
@Nullable
@Override
public PsiClass getElement() {
return (PsiClass)super.getElement();
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2011 Dave Griffith, Bas Leijdekkers
* Copyright 2006-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@ public class CyclicClassDependencyInspection extends BaseGlobalInspection {
}
final RefClass refClass = (RefClass)refEntity;
final PsiClass aClass = refClass.getElement();
if (aClass.getContainingClass() != null) {
if (aClass == null || aClass.getContainingClass() != null) {
return null;
}
final Set<RefClass> dependencies =
@@ -67,7 +67,7 @@ public class CyclicClassDependencyInspection extends BaseGlobalInspection {
}
final String errorString = InspectionGadgetsBundle.message(
"cyclic.class.dependency.problem.descriptor",
refEntity.getName(), numMutualDependents - 1);
refEntity.getName(), Integer.valueOf(numMutualDependents - 1));
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)
};