mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-88468 (restrict Javac quirks inspection by language level)
This commit is contained in:
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -36,6 +36,7 @@ public class JavacQuirksInspectionVisitor extends JavaElementVisitor {
|
||||
|
||||
@Override
|
||||
public void visitAnnotationArrayInitializer(final PsiArrayInitializerMemberValue initializer) {
|
||||
if (PsiUtil.isLanguageLevel7OrHigher(initializer)) return;
|
||||
final PsiElement lastElement = PsiTreeUtil.skipSiblingsBackward(initializer.getLastChild(), PsiWhiteSpace.class, PsiComment.class);
|
||||
if (lastElement != null && PsiUtil.isJavaToken(lastElement, JavaTokenType.COMMA)) {
|
||||
final String message = InspectionsBundle.message("inspection.compiler.javac.quirks.anno.array.comma.problem");
|
||||
@@ -46,6 +47,7 @@ public class JavacQuirksInspectionVisitor extends JavaElementVisitor {
|
||||
|
||||
@Override
|
||||
public void visitTypeCastExpression(final PsiTypeCastExpression expression) {
|
||||
if (PsiUtil.isLanguageLevel7OrHigher(expression)) return;
|
||||
final PsiTypeElement type = expression.getCastType();
|
||||
if (type != null) {
|
||||
type.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
|
||||
+6
-1
@@ -30,6 +30,7 @@ import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -128,6 +129,11 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testJavacQuirks() throws Exception {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_6);
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
public void testNumericLiterals() throws Exception { doTest(false, false); }
|
||||
public void testMultiCatch() throws Exception { doTest(false, false); }
|
||||
public void testTryWithResources() throws Exception { doTest(false, false); }
|
||||
@@ -136,7 +142,6 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testUncheckedGenericsArrayCreation() throws Exception { doTest(true, false); }
|
||||
public void testPreciseRethrow() throws Exception { doTest(false, false); }
|
||||
public void testImprovedCatchAnalysis() throws Exception { doTest(true, false); }
|
||||
public void testJavacQuirks() throws Exception { doTest(true, false); }
|
||||
public void testPolymorphicTypeCast() throws Exception { doTest(true, false); }
|
||||
public void testErasureClashConfusion() throws Exception { doTest(true, false, new UnusedDeclarationInspection()); }
|
||||
public void testUnused() throws Exception { doTest(true, false, new UnusedDeclarationInspection()); }
|
||||
|
||||
Reference in New Issue
Block a user