mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
Cleanup (formatting)
This commit is contained in:
+25
-21
@@ -374,38 +374,42 @@ public class HighlightClassUtil {
|
||||
private static HighlightInfo checkStaticClassDeclarationInInnerClass(PsiKeyword keyword) {
|
||||
// keyword points to 'class' or 'interface' or 'enum'
|
||||
if (new PsiMatcherImpl(keyword)
|
||||
.parent(PsiMatchers.hasClass(PsiClass.class))
|
||||
.dot(JavaMatchers.hasModifier(PsiModifier.STATIC, true))
|
||||
.parent(PsiMatchers.hasClass(PsiClass.class))
|
||||
.dot(JavaMatchers.hasModifier(PsiModifier.STATIC, false))
|
||||
.parent(PsiMatchers.hasClass(PsiClass.class, PsiDeclarationStatement.class, PsiNewExpression.class, PsiEnumConstant.class))
|
||||
.getElement() == null) {
|
||||
.parent(PsiMatchers.hasClass(PsiClass.class))
|
||||
.dot(JavaMatchers.hasModifier(PsiModifier.STATIC, true))
|
||||
.parent(PsiMatchers.hasClass(PsiClass.class))
|
||||
.dot(JavaMatchers.hasModifier(PsiModifier.STATIC, false))
|
||||
.parent(PsiMatchers.hasClass(PsiClass.class, PsiDeclarationStatement.class, PsiNewExpression.class, PsiEnumConstant.class))
|
||||
.getElement() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiClass aClass = (PsiClass)keyword.getParent();
|
||||
if (PsiUtilCore.hasErrorElementChild(aClass) || aClass.getQualifiedName() == null && !aClass.isInterface()) return null;
|
||||
if (PsiUtilCore.hasErrorElementChild(aClass) || aClass.getQualifiedName() == null && !aClass.isInterface()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// highlight 'static' keyword if any, or class or interface if not
|
||||
PsiElement context = null;
|
||||
PsiModifierList modifierList = aClass.getModifierList();
|
||||
PsiElement[] children = modifierList.getChildren();
|
||||
for (PsiElement element : children) {
|
||||
if (Comparing.equal(element.getText(), PsiModifier.STATIC)) {
|
||||
context = element;
|
||||
break;
|
||||
if (modifierList != null) {
|
||||
for (PsiElement element : modifierList.getChildren()) {
|
||||
if (Comparing.equal(element.getText(), PsiModifier.STATIC)) {
|
||||
context = element;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
TextRange range = context == null ? null : context.getTextRange();
|
||||
if (range == null) {
|
||||
range = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
|
||||
}
|
||||
TextRange range = context != null ? context.getTextRange() : HighlightNamesUtil.getClassDeclarationTextRange(aClass);
|
||||
String message = JavaErrorMessages.message("static.declaration.in.inner.class");
|
||||
HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create();
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create();
|
||||
if (context != keyword) {
|
||||
QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false));
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false));
|
||||
}
|
||||
QuickFixAction.registerQuickFixAction(errorResult,
|
||||
QUICK_FIX_FACTORY.createModifierListFix(aClass.getContainingClass(), PsiModifier.STATIC, true, false));
|
||||
return errorResult;
|
||||
PsiClass containingClass = aClass.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createModifierListFix(containingClass, PsiModifier.STATIC, true, false));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+11
-11
@@ -11,16 +11,16 @@ public class a {
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
final int f1 = 3 < 4 ? (a.ix==5 ? 1 : 3) / 4 + 18 : 0;
|
||||
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
final int f2 = x instanceof Integer ? 1 : 0;
|
||||
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
class a_ic_c {}
|
||||
|
||||
<error descr="Inner classes cannot have static declarations">interface a_ic_i</error> {}
|
||||
<error descr="Inner classes cannot have static declarations">static</error> interface a_ic_i2 {}
|
||||
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
int a_ic_m(String s) { return 0; }
|
||||
|
||||
// static initializer
|
||||
@@ -45,13 +45,13 @@ public class a {
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
final int f1 = 3 < 4 ? (a.ix==5 ? 1 : 3) / 4 + 18 : 0;
|
||||
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
final int f2 = x instanceof Integer ? 1 : 0;
|
||||
|
||||
<error descr="Modifier 'static' not allowed here">static</error>
|
||||
<error descr="Modifier 'static' not allowed here">static</error>
|
||||
class a_ic_c2 {}
|
||||
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
int a_ic_m2(String s) { return 0; }
|
||||
// static initializer
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
@@ -59,7 +59,7 @@ public class a {
|
||||
}
|
||||
}
|
||||
|
||||
void f1()
|
||||
void f1()
|
||||
{
|
||||
new a() {
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
@@ -69,16 +69,16 @@ public class a {
|
||||
final int f1 = 3 < 4 ? (a.ix==5 ? 1 : 3) / 4 + 18 : 0;
|
||||
|
||||
// its not a compile time constant
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
final Object o = null;
|
||||
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
final int f2 = x instanceof Integer ? 1 : 0;
|
||||
|
||||
<error descr="Modifier 'static' not allowed here">static</error>
|
||||
<error descr="Modifier 'static' not allowed here">static</error>
|
||||
class a_ic_c2 {}
|
||||
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
int a_ic_m2(String s) { return 0; }
|
||||
// static initializer
|
||||
<error descr="Inner classes cannot have static declarations">static</error>
|
||||
|
||||
+2
-4
@@ -71,9 +71,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testAutoboxingMethods() { doTest5(false); }
|
||||
public void testAutoboxingConstructors() { doTest5(false); }
|
||||
public void testEnumWithAbstractMethods() { doTest5(false); }
|
||||
public void testEnum() {
|
||||
doTest(LanguageLevel.JDK_1_5, JavaSdkVersion.JDK_1_5, false);
|
||||
}
|
||||
public void testEnum() { doTest(LanguageLevel.JDK_1_5, JavaSdkVersion.JDK_1_5, false); }
|
||||
public void testEnum56239() { doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
|
||||
public void testSameErasure() { doTest5(false); }
|
||||
public void testMethods() { doTest5(false); }
|
||||
@@ -300,7 +298,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA67682() { doTest5(false); }
|
||||
public void testIDEA57391() { doTest5(false); }
|
||||
public void testIDEA110869() { doTest5(false); }
|
||||
public void _testIDEA110947() { doTest5(false); }
|
||||
/*public void testIDEA110947() { doTest5(false); }*/
|
||||
public void testIDEA112122() { doTest5(false); }
|
||||
public void testNoInferenceFromTypeCast() { doTest5(false); }
|
||||
public void testCaptureWildcardsInTypeCasts() { doTest5(false); }
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.ExtensionPoints;
|
||||
import com.intellij.ToolExtensionPoints;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance;
|
||||
@@ -218,7 +218,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testUnusedNonPrivateMembers2() {
|
||||
ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.DEAD_CODE_TOOL);
|
||||
ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.DEAD_CODE_TOOL);
|
||||
EntryPoint extension = new EntryPoint() {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user