diff --git a/java/java-impl/src/com/intellij/codeInspection/internal/InternalInspection.java b/java/java-impl/src/com/intellij/codeInspection/internal/InternalInspection.java index d252bb45212e..f9c6dc475531 100644 --- a/java/java-impl/src/com/intellij/codeInspection/internal/InternalInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/internal/InternalInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 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. @@ -19,6 +19,7 @@ import com.intellij.codeInspection.BaseJavaLocalInspectionTool; import com.intellij.codeInspection.LocalInspectionToolSession; import com.intellij.codeInspection.ProblemsHolder; import com.intellij.psi.JavaPsiFacade; +import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.components.JBList; @@ -26,11 +27,13 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; public abstract class InternalInspection extends BaseJavaLocalInspectionTool { + private static final String GROUP_NAME = "IDEA Platform Inspections"; + @Nls @NotNull @Override public String getGroupDisplayName() { - return InternalInspectionToolsProvider.GROUP_NAME; + return GROUP_NAME; } public boolean isEnabledByDefault() { @@ -42,11 +45,8 @@ public abstract class InternalInspection extends BaseJavaLocalInspectionTool { public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly, @NotNull LocalInspectionToolSession session) { - if (JavaPsiFacade.getInstance(holder.getProject()).findClass(JBList.class.getName(), - GlobalSearchScope.allScope(holder.getProject())) == null) { - return new PsiElementVisitor() { - }; - } - return super.buildVisitor(holder, isOnTheFly, session); + final GlobalSearchScope scope = GlobalSearchScope.allScope(holder.getProject()); + final PsiClass markerClass = JavaPsiFacade.getInstance(holder.getProject()).findClass(JBList.class.getName(), scope); + return markerClass != null ? super.buildVisitor(holder, isOnTheFly, session) : new PsiElementVisitor() { }; } } diff --git a/java/java-impl/src/com/intellij/codeInspection/internal/InternalInspectionToolsProvider.java b/java/java-impl/src/com/intellij/codeInspection/internal/InternalInspectionToolsProvider.java deleted file mode 100644 index 68cb9e40a5f7..000000000000 --- a/java/java-impl/src/com/intellij/codeInspection/internal/InternalInspectionToolsProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2010 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.internal; - -import com.intellij.openapi.application.ex.ApplicationManagerEx; -import com.intellij.util.ArrayUtil; - -public class InternalInspectionToolsProvider { - public static final String GROUP_NAME = "IDEA Platform Inspections"; - private static final Class[] CLASSES = new Class[] { - UndesirableClassUsageInspection.class, - FileEqualsUsageInspection.class, - GtkPreferredJComboBoxRendererInspection.class - }; - - public Class[] getInspectionClasses() { - if (!isActive()) return ArrayUtil.EMPTY_CLASS_ARRAY; - return CLASSES; - } - - public static Class[] getPublicClasses() { - if (isActive()) return ArrayUtil.EMPTY_CLASS_ARRAY; - return CLASSES; - } - - private static boolean isActive() { - return ApplicationManagerEx.getApplicationEx().isInternal(); - } -} diff --git a/plugins/devkit/testSources/codeInsight/ExtensionsTest.java b/plugins/devkit/testSources/codeInsight/ExtensionsTest.java index 5bea99fca884..eff87a82a16d 100644 --- a/plugins/devkit/testSources/codeInsight/ExtensionsTest.java +++ b/plugins/devkit/testSources/codeInsight/ExtensionsTest.java @@ -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. @@ -23,10 +23,9 @@ import com.intellij.util.PathUtil; /** * @author Dmitry Avdeev - * Date: 10/11/11 + * @since 10/11/11 */ public class ExtensionsTest extends JavaCodeInsightFixtureTestCase { - public void testInspectionMappings() throws Throwable { myFixture.testHighlighting("inspectionMapping.xml", "bundle.properties"); } diff --git a/plugins/devkit/testSources/codeInsight/PluginXmlFunctionalTest.java b/plugins/devkit/testSources/codeInsight/PluginXmlFunctionalTest.java index c3b22ad5f90c..050f604ce17e 100644 --- a/plugins/devkit/testSources/codeInsight/PluginXmlFunctionalTest.java +++ b/plugins/devkit/testSources/codeInsight/PluginXmlFunctionalTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -16,7 +16,7 @@ package org.jetbrains.idea.devkit.codeInsight; import com.intellij.codeInsight.TargetElementUtilBase; -import com.intellij.codeInspection.internal.InternalInspectionToolsProvider; +import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.openapi.application.PluginPathManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; @@ -28,11 +28,12 @@ import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; import com.intellij.testFramework.fixtures.TempDirTestFixture; import com.intellij.usageView.UsageViewNodeTextLocation; import com.intellij.usageView.UsageViewTypeLocation; -import com.intellij.util.ArrayUtil; import com.intellij.util.xml.DeprecatedClassUsageInspection; import org.jetbrains.idea.devkit.inspections.*; import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; /** * @author peter @@ -186,15 +187,14 @@ public class PluginXmlFunctionalTest extends JavaCodeInsightFixtureTestCase { myFixture.testHighlighting(true, true, true); } - static Class[] getInspectionClasses() { - Class[] result = { + static Collection> getInspectionClasses() { + return Arrays.>asList( //RegistrationProblemsInspection.class, PluginXmlDomInspection.class, ComponentNotRegisteredInspection.class, InspectionDescriptionNotFoundInspection.class, IntentionDescriptionNotFoundInspection.class, InspectionMappingConsistencyInspection.class - }; - return ArrayUtil.mergeArrays(result, InternalInspectionToolsProvider.getPublicClasses()); + ); } }