mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
method refs: super::abstract method
This commit is contained in:
+13
-1
@@ -1040,7 +1040,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (myRefCountHolder != null) {
|
||||
myRefCountHolder.registerReference(expression, result);
|
||||
}
|
||||
if (result.getElement() != null && !result.isAccessible()) {
|
||||
final PsiElement method = result.getElement();
|
||||
if (method != null && !result.isAccessible()) {
|
||||
final String accessProblem = HighlightUtil.buildProblemWithAccessDescription(expression, result);
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(accessProblem).create();
|
||||
myHolder.add(info);
|
||||
@@ -1075,6 +1076,17 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (!myHolder.hasErrorResults()) {
|
||||
myHolder.add(HighlightUtil.checkUnhandledExceptions(expression, expression.getTextRange()));
|
||||
}
|
||||
if (!myHolder.hasErrorResults()) {
|
||||
if (method instanceof PsiMethod && ((PsiMethod)method).hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
final PsiElement qualifier = expression.getQualifier();
|
||||
if (qualifier instanceof PsiSuperExpression) {
|
||||
myHolder.add(HighlightInfo
|
||||
.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(expression.getReferenceNameElement())
|
||||
.descriptionAndTooltip("Abstract method '" + ((PsiMethod)method).getName() + "' cannot be accessed directly").create());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
class Test {
|
||||
interface I {
|
||||
int _();
|
||||
}
|
||||
|
||||
static abstract class Parent {
|
||||
abstract int foo() ;
|
||||
}
|
||||
|
||||
static abstract class Child extends Parent {
|
||||
abstract int foo() ;
|
||||
void test() {
|
||||
I s = super::<error descr="Abstract method 'foo' cannot be accessed directly">foo</error>;
|
||||
I s1 = this::foo;
|
||||
|
||||
Parent sup = null;
|
||||
I s2 = sup::foo;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -200,6 +200,10 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAbstractMethod() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user