diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java index 6436215ef340..535aee6ea37b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java @@ -845,8 +845,9 @@ public class HighlightClassUtil { } PsiModifierListOwner staticParent = PsiUtil.getEnclosingStaticElement(place, outerClass); if (staticParent != null) { - String description = JavaErrorMessages.message("cannot.be.referenced.from.static.context", - outerClass == null ? "" : HighlightUtil.formatClass(outerClass) + "." + PsiKeyword.THIS); + String element = outerClass == null ? "" : HighlightUtil.formatClass(outerClass) + "." + + (place instanceof PsiSuperExpression ? PsiKeyword.SUPER : PsiKeyword.THIS); + String description = JavaErrorMessages.message("cannot.be.referenced.from.static.context", element); HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, elementToHighlight, description); // make context not static or referenced class static IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(staticParent, PsiModifier.STATIC, false, false); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCalls.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCalls.java index 74175a7a882c..183e8d01211d 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCalls.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCalls.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2012 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // illegal method calls class A { @@ -48,14 +64,12 @@ class CX { class c { - c() { + c() {} - } class inner { class ininner {} } - static void f() { new inner(); } @@ -88,21 +102,20 @@ class DCC { } public DCC(int i, int z) { - DCC(i); + DCC(i); } void f() { DCC(1); new DCC(1); } - { - java.toString(); - } - + { + java.toString(); + } } class ThisExpression { static String foo() { System.out.println(this); - return this.toString(); + return super.toString(); } }