number of inspections moved to java-analysis

This commit is contained in:
Alexey Kudravtsev
2013-05-08 11:43:49 +04:00
parent 8df07569f2
commit d9d97e258c
19 changed files with 105 additions and 35 deletions
@@ -17,7 +17,6 @@ package com.intellij.codeInspection;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInsight.daemon.JavaErrorMessages;
import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.psi.*;
@@ -29,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
/**
* User: cdr
*/
public class NumericOverflowInspection extends BaseLocalInspectionTool {
public class NumericOverflowInspection extends BaseJavaBatchLocalInspectionTool {
private static final Key<String> HAS_OVERFLOW_IN_CHILD = Key.create("HAS_OVERFLOW_IN_CHILD");
@Nls
@@ -15,13 +15,13 @@
*/
package com.intellij.codeInspection.java15api;
import com.intellij.ExtensionPoints;
import com.intellij.ToolExtensionPoints;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInspection.*;
import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.LanguageLevelUtil;
import com.intellij.openapi.module.EffectiveLanguageLevelUtil;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.ui.VerticalFlowLayout;
@@ -34,7 +34,7 @@ import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.reference.SoftReference;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ide.ui.ListCellRendererWrapper;
import com.intellij.util.ui.UIUtil;
import gnu.trove.THashSet;
import org.jdom.Element;
@@ -55,7 +55,7 @@ import java.util.Set;
/**
* @author max
*/
public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
public class Java15APIUsageInspection extends BaseJavaBatchLocalInspectionTool {
@NonNls public static final String SHORT_NAME = "Since15";
private static final Map<LanguageLevel, Reference<Set<String>>> ourForbiddenAPI = new EnumMap<LanguageLevel, Reference<Set<String>>>(LanguageLevel.class);
@@ -180,7 +180,7 @@ public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
cModel.addElement(level);
}
llCombo.setSelectedItem(myEffectiveLanguageLevel != null ? myEffectiveLanguageLevel : LanguageLevel.JDK_1_3);
llCombo.setRenderer(new ListCellRendererWrapper() {
llCombo.setRenderer(new ListCellRendererWrapper(llCombo) {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof LanguageLevel) {
@@ -235,7 +235,7 @@ public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
private class MyVisitor extends JavaElementVisitor {
private final ProblemsHolder myHolder;
private final boolean myOnTheFly;
private final ExtensionPoint<FileCheckingInspection> point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.JAVA15_INSPECTION_TOOL);
private final ExtensionPoint<FileCheckingInspection> point = Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.JAVA15_INSPECTION_TOOL);
public MyVisitor(final ProblemsHolder holder, boolean onTheFly) {
myHolder = holder;
@@ -306,7 +306,7 @@ public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
private LanguageLevel getEffectiveLanguageLevel(Module module) {
if (myEffectiveLanguageLevel != null) return myEffectiveLanguageLevel;
return LanguageLevelUtil.getEffectiveLanguageLevel(module);
return EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module);
}
private void registerError(PsiJavaCodeReferenceElement reference, LanguageLevel api) {
@@ -560,4 +560,4 @@ java.util.zip.DeflaterOutputStream#DeflaterOutputStream(java.io.OutputStream;boo
java.util.zip.DeflaterOutputStream#flush()
java.util.zip.ZipOutputStream#ZipOutputStream(java.io.OutputStream;java.nio.charset.Charset;)
java.util.Scanner#Scanner(java.nio.file.Path;)
java.util.Scanner#Scanner(java.nio.file.Path;java.lang.String;)
java.util.Scanner#Scanner(java.nio.file.Path;java.lang.String;)
@@ -0,0 +1 @@
java.awt.geom.GeneralPath
@@ -18,7 +18,6 @@ package com.intellij.codeInspection.localCanBeFinal;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -42,7 +41,7 @@ import java.util.List;
/**
* @author max
*/
public class LocalCanBeFinal extends BaseLocalInspectionTool {
public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.localCanBeFinal.LocalCanBeFinal");
public boolean REPORT_VARIABLES = true;
@@ -1 +0,0 @@
java.awt.geom.GeneralPath
+1
View File
@@ -8,6 +8,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="core-api" exported="" />
<orderEntry type="module" module-name="projectModel-api" />
</component>
</module>
@@ -0,0 +1,32 @@
/*
* Copyright 2000-2013 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.
*/
package com.intellij.openapi.module;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.roots.LanguageLevelModuleExtension;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;
public class EffectiveLanguageLevelUtil {
@NotNull
public static LanguageLevel getEffectiveLanguageLevel(@NotNull final Module module) {
ApplicationManager.getApplication().assertReadAccessAllowed();
LanguageLevel level = LanguageLevelModuleExtension.getInstance(module).getLanguageLevel();
if (level != null) return level;
return LanguageLevelProjectExtension.getInstance(module.getProject()).getLanguageLevel();
}
}
@@ -119,4 +119,4 @@ public class LanguageLevelModuleExtension extends ModuleExtension<LanguageLevelM
myModule = null;
myLanguageLevel = null;
}
}
}
@@ -15,11 +15,8 @@
*/
package com.intellij.openapi.module;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.roots.LanguageLevelModuleExtension;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;
@@ -27,18 +24,10 @@ import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class LanguageLevelUtil {
public class LanguageLevelUtil extends EffectiveLanguageLevelUtil {
private LanguageLevelUtil() {
}
@NotNull
public static LanguageLevel getEffectiveLanguageLevel(@NotNull final Module module) {
ApplicationManager.getApplication().assertReadAccessAllowed();
LanguageLevel level = LanguageLevelModuleExtension.getInstance(module).getLanguageLevel();
if (level != null) return level;
return LanguageLevelProjectExtension.getInstance(module.getProject()).getLanguageLevel();
}
@NotNull
public static LanguageLevel getLanguageLevelForFile(final VirtualFile file) {
if (file == null) return LanguageLevel.HIGHEST;
@@ -0,0 +1,24 @@
/*
* Copyright 2000-2013 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.
*/
package com.intellij;
import org.jetbrains.annotations.NonNls;
public interface ToolExtensionPoints {
@NonNls String INVALID_PROPERTY_KEY_INSPECTION_TOOL = "com.intellij.invalidPropertyKeyInspectionTool";
@NonNls String I18N_INSPECTION_TOOL = "com.intellij.i18nInspectionTool";
@NonNls String JAVA15_INSPECTION_TOOL = "com.intellij.java15InspectionTool";
}
@@ -0,0 +1,29 @@
/*
* Copyright 2000-2013 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.
*/
package com.intellij.codeInspection;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author yole
*/
public interface FileCheckingInspection {
@Nullable
ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly);
}
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NonNls;
/**
* Extension points provided by IDEA core are listed here.
*/
public interface ExtensionPoints {
public interface ExtensionPoints extends ToolExtensionPoints {
/**
* This extension point should be used instead of former application-components, project-components, module-components.
* Extension declaration sample is as follows:
@@ -64,8 +64,7 @@ public interface ExtensionPoints {
* </pre>
* my.plugin.package.MyJUnitPatcher class must implement {@link com.intellij.execution.JUnitPatcher} abstract class.
*/
@NonNls String JUNIT_PATCHER = "com.intellij.junitPatcher";
@SuppressWarnings("JavadocReference") @NonNls String JUNIT_PATCHER = "com.intellij.junitPatcher";
/**
* This extensions allows to run custom [command-line] application based on IDEA platform
@@ -78,10 +77,6 @@ public interface ExtensionPoints {
*/
@NonNls String APPLICATION_STARTER = "com.intellij.appStarter";
@NonNls String INVALID_PROPERTY_KEY_INSPECTION_TOOL = "com.intellij.invalidPropertyKeyInspectionTool";
@NonNls String I18N_INSPECTION_TOOL = "com.intellij.i18nInspectionTool";
@NonNls String JAVA15_INSPECTION_TOOL = "com.intellij.java15InspectionTool";
@NonNls String INSPECTIONS_GRAPH_ANNOTATOR = "com.intellij.refGraphAnnotator";
@NonNls String DEAD_CODE_TOOL = "com.intellij.deadCode";
@@ -24,6 +24,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class ModuleExtension<T extends ModuleExtension> implements JDOMExternalizable, Disposable, Comparable<ModuleExtension> {
@@ -47,7 +48,8 @@ public abstract class ModuleExtension<T extends ModuleExtension> implements JDOM
return null;
}
public int compareTo(final ModuleExtension o) {
@Override
public int compareTo(@NotNull final ModuleExtension o) {
return getClass().getName().compareTo(o.getClass().getName());
}
}
+1 -1
View File
@@ -15,7 +15,7 @@
<orderEntry type="module" module-name="lang-impl" />
<orderEntry type="module" module-name="xml" />
<orderEntry type="module" module-name="spellchecker" />
<orderEntry type="module" module-name="java-impl" />
<orderEntry type="module" module-name="java-impl" exported="" />
<orderEntry type="module" module-name="jsp-base-openapi" />
<orderEntry type="module" module-name="jsp-openapi" />
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />