mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make message closer to javac error (IDEA-169865)
This commit is contained in:
+16
-8
@@ -1336,10 +1336,18 @@ public class GenericsHighlightUtil {
|
||||
final PsiElement resolve = ref.resolve();
|
||||
final PsiClass containingClass = resolve != null ? ((PsiClass)resolve).getContainingClass() : null;
|
||||
if (containingClass == null) return null;
|
||||
if (psiClass.isInheritor(containingClass, true) ||
|
||||
unqualifiedNestedClassReferenceAccessedViaContainingClassInheritance((PsiClass)typeClass, ((PsiClass)resolve).getExtendsList()) ||
|
||||
unqualifiedNestedClassReferenceAccessedViaContainingClassInheritance((PsiClass)typeClass, ((PsiClass)resolve).getImplementsList())) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(((PsiClass)resolve).getName() + " is not accessible in current context").range(ref).create();
|
||||
PsiClass hiddenClass = null;
|
||||
if (psiClass.isInheritor(containingClass, true)) {
|
||||
hiddenClass = (PsiClass)resolve;
|
||||
}
|
||||
else {
|
||||
hiddenClass = unqualifiedNestedClassReferenceAccessedViaContainingClassInheritance((PsiClass)typeClass, ((PsiClass)resolve).getExtendsList());
|
||||
if (hiddenClass == null) {
|
||||
hiddenClass = unqualifiedNestedClassReferenceAccessedViaContainingClassInheritance((PsiClass)typeClass, ((PsiClass)resolve).getImplementsList());
|
||||
}
|
||||
}
|
||||
if (hiddenClass != null) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(hiddenClass.getName() + " is not accessible in current context").range(ref).create();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1347,8 +1355,8 @@ public class GenericsHighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean unqualifiedNestedClassReferenceAccessedViaContainingClassInheritance(PsiClass containingClass,
|
||||
PsiReferenceList referenceList) {
|
||||
private static PsiClass unqualifiedNestedClassReferenceAccessedViaContainingClassInheritance(PsiClass containingClass,
|
||||
PsiReferenceList referenceList) {
|
||||
if (referenceList != null) {
|
||||
for (PsiJavaCodeReferenceElement referenceElement : referenceList.getReferenceElements()) {
|
||||
if (!referenceElement.isQualified()) {
|
||||
@@ -1358,13 +1366,13 @@ public class GenericsHighlightUtil {
|
||||
if (superContainingClass != null &&
|
||||
InheritanceUtil.isInheritorOrSelf(containingClass, superContainingClass, true) &&
|
||||
!PsiTreeUtil.isAncestor(superContainingClass, containingClass, true)) {
|
||||
return true;
|
||||
return (PsiClass)superClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void registerVariableParameterizedTypeFixes(@Nullable HighlightInfo highlightInfo,
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ abstract class IdeaBugTest<M extends IdeaBugTest.Mapping>
|
||||
static class Mapping {}
|
||||
}
|
||||
|
||||
class BugTestSub extends IdeaBugTest<<error descr="SubMapping is not accessible in current context">BugTestSub.SubMapping</error>>
|
||||
class BugTestSub extends IdeaBugTest<<error descr="Mapping is not accessible in current context">BugTestSub.SubMapping</error>>
|
||||
{
|
||||
public abstract static class SubMapping extends Mapping {}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class Parent<T extends Parent.NestedParent>
|
||||
|
||||
class Test
|
||||
{
|
||||
public final static class Child extends Parent<<error descr="NestedChild is not accessible in current context">Child.NestedChild</error>>
|
||||
public final static class Child extends Parent<<error descr="NestedParent is not accessible in current context">Child.NestedChild</error>>
|
||||
{
|
||||
private static interface NestedChild extends NestedParent
|
||||
{
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ abstract class IdeaBugTest<M extends IdeaBugTest.Mapping>
|
||||
static class Mapping {}
|
||||
}
|
||||
|
||||
class BugTestSub extends IdeaBugTest<<error descr="SubMapping is not accessible in current context">BugTestSub.SubMapping</error>>
|
||||
class BugTestSub extends IdeaBugTest<<error descr="Mapping is not accessible in current context">BugTestSub.SubMapping</error>>
|
||||
{
|
||||
public abstract static class SubMapping extends Mapping {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user