Search in sources :

Example 21 with LocalInspectionToolWrapper

use of com.intellij.codeInspection.ex.LocalInspectionToolWrapper in project intellij-community by JetBrains.

the class RemoveRedundantUncheckedSuppressionTest method configureLocalInspectionTools.

@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
    final PossibleHeapPollutionVarargsInspection varargsInspection = new PossibleHeapPollutionVarargsInspection();
    final UncheckedWarningLocalInspection warningLocalInspection = new UncheckedWarningLocalInspection();
    final RedundantSuppressInspection inspection = new RedundantSuppressInspection() {

        @NotNull
        @Override
        protected InspectionToolWrapper[] getInspectionTools(PsiElement psiElement, @NotNull InspectionManager manager) {
            return new InspectionToolWrapper[] { new LocalInspectionToolWrapper(varargsInspection), new LocalInspectionToolWrapper(warningLocalInspection) };
        }
    };
    return new LocalInspectionTool[] { new LocalInspectionTool() {

        @Nls
        @NotNull
        @Override
        public String getGroupDisplayName() {
            return inspection.getGroupDisplayName();
        }

        @Nls
        @NotNull
        @Override
        public String getDisplayName() {
            return inspection.getDisplayName();
        }

        @NotNull
        @Override
        public String getShortName() {
            return inspection.getShortName();
        }

        @NotNull
        @Override
        public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly, @NotNull LocalInspectionToolSession session) {
            return new JavaElementVisitor() {

                @Override
                public void visitClass(PsiClass aClass) {
                    checkMember(aClass, inspection, holder);
                }

                @Override
                public void visitMethod(PsiMethod method) {
                    checkMember(method, inspection, holder);
                }
            };
        }

        private void checkMember(PsiMember member, RedundantSuppressInspection inspection, ProblemsHolder holder) {
            final ProblemDescriptor[] problemDescriptors = inspection.checkElement(member, InspectionManager.getInstance(getProject()));
            if (problemDescriptors != null) {
                for (ProblemDescriptor problemDescriptor : problemDescriptors) {
                    holder.registerProblem(problemDescriptor);
                }
            }
        }
    }, varargsInspection, warningLocalInspection };
}
Also used : UncheckedWarningLocalInspection(com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection) NotNull(org.jetbrains.annotations.NotNull) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) NotNull(org.jetbrains.annotations.NotNull)

Example 22 with LocalInspectionToolWrapper

use of com.intellij.codeInspection.ex.LocalInspectionToolWrapper in project intellij-community by JetBrains.

the class SSBasedInspectionTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    SSBasedInspection inspection = new SSBasedInspection();
    List<Configuration> configurations = new ArrayList<>();
    SearchConfiguration configuration = new SearchConfiguration();
    MatchOptions options = new MatchOptions();
    options.setFileType(StdFileTypes.JAVA);
    options.setSearchPattern("int i;");
    configuration.setMatchOptions(options);
    configurations.add(configuration);
    configuration = new SearchConfiguration();
    options = new MatchOptions();
    options.setFileType(StdFileTypes.JAVA);
    options.setSearchPattern("f();");
    configuration.setMatchOptions(options);
    configurations.add(configuration);
    inspection.setConfigurations(configurations, myProject);
    myWrapper = new LocalInspectionToolWrapper(inspection);
}
Also used : Configuration(com.intellij.structuralsearch.plugin.ui.Configuration) SearchConfiguration(com.intellij.structuralsearch.plugin.ui.SearchConfiguration) ArrayList(java.util.ArrayList) SSBasedInspection(com.intellij.structuralsearch.inspection.highlightTemplate.SSBasedInspection) SearchConfiguration(com.intellij.structuralsearch.plugin.ui.SearchConfiguration) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper)

Example 23 with LocalInspectionToolWrapper

use of com.intellij.codeInspection.ex.LocalInspectionToolWrapper in project intellij-community by JetBrains.

the class UnnecessaryReturnInspectionTest method test.

public void test() throws Exception {
    final UnnecessaryReturnInspection inspection = new UnnecessaryReturnInspection();
    inspection.ignoreInThenBranch = true;
    final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
    final LanguageLevel level = levelProjectExtension.getLanguageLevel();
    try {
        levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
        doTest("com/siyeh/igtest/controlflow/unnecessary_return", new LocalInspectionToolWrapper(inspection), "java 1.8");
    } finally {
        levelProjectExtension.setLanguageLevel(level);
    }
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper)

Example 24 with LocalInspectionToolWrapper

use of com.intellij.codeInspection.ex.LocalInspectionToolWrapper in project intellij-community by JetBrains.

the class InvalidPropertyKeyInspectionTest method doTest.

private void doTest() throws Exception {
    LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(new InvalidPropertyKeyInspection());
    doTest("invalidPropertyKey/" + getTestName(true), tool, "java 1.5");
}
Also used : LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper)

Example 25 with LocalInspectionToolWrapper

use of com.intellij.codeInspection.ex.LocalInspectionToolWrapper in project intellij-community by JetBrains.

the class I18NInspectionTest method testFormTabbedPaneTitle.

public void testFormTabbedPaneTitle() throws Exception {
    LocalInspectionToolWrapper wrapper = new LocalInspectionToolWrapper(new I18nFormInspection());
    InspectionsKt.enableInspectionTool(getProject(), wrapper, getTestRootDisposable());
    doTest("i18n/" + getTestName(true), new LocalInspectionToolWrapper(new I18nInspection()), "java 1.4", false, false, wrapper);
}
Also used : I18nInspection(com.intellij.codeInspection.i18n.I18nInspection) I18nFormInspection(com.intellij.uiDesigner.i18n.I18nFormInspection) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper)

Aggregations

LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)26 NotNull (org.jetbrains.annotations.NotNull)11 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)6 Nullable (org.jetbrains.annotations.Nullable)6 GlobalInspectionToolWrapper (com.intellij.codeInspection.ex.GlobalInspectionToolWrapper)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)4 RefElement (com.intellij.codeInspection.reference.RefElement)3 TextRange (com.intellij.openapi.util.TextRange)3 List (java.util.List)3 AnalysisScope (com.intellij.analysis.AnalysisScope)2 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)2 IntentionManager (com.intellij.codeInsight.intention.IntentionManager)2 IntentionHintComponent (com.intellij.codeInsight.intention.impl.IntentionHintComponent)2 InspectionManager (com.intellij.codeInspection.InspectionManager)2 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)2 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)2 RedundantCastInspection (com.intellij.codeInspection.redundantCast.RedundantCastInspection)2 RefEntity (com.intellij.codeInspection.reference.RefEntity)2 RefManagerImpl (com.intellij.codeInspection.reference.RefManagerImpl)2 RefVisitor (com.intellij.codeInspection.reference.RefVisitor)2