Search in sources :

Example 21 with InspectionToolWrapper

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

the class DumpInspectionDescriptionsAction method actionPerformed.

@Override
public void actionPerformed(final AnActionEvent event) {
    final InspectionProfile profile = InspectionProfileManager.getInstance().getCurrentProfile();
    final InspectionToolWrapper[] tools = profile.getInspectionTools(null);
    final Collection<String> classes = ContainerUtil.newTreeSet();
    final Map<String, Collection<String>> groups = ContainerUtil.newTreeMap();
    final String tempDirectory = FileUtil.getTempDirectory();
    final File descDirectory = new File(tempDirectory, "inspections");
    if (!descDirectory.mkdirs() && !descDirectory.isDirectory()) {
        LOG.error("Unable to create directory: " + descDirectory.getAbsolutePath());
        return;
    }
    for (InspectionToolWrapper toolWrapper : tools) {
        classes.add(getInspectionClass(toolWrapper).getName());
        final String group = getGroupName(toolWrapper);
        Collection<String> names = groups.get(group);
        if (names == null)
            groups.put(group, (names = ContainerUtil.newTreeSet()));
        names.add(toolWrapper.getShortName());
        final URL url = getDescriptionUrl(toolWrapper);
        if (url != null) {
            doDump(new File(descDirectory, toolWrapper.getShortName() + ".html"), new Processor() {

                @Override
                public void process(BufferedWriter writer) throws Exception {
                    writer.write(ResourceUtil.loadText(url));
                }
            });
        }
    }
    doNotify("Inspection descriptions dumped to\n" + descDirectory.getAbsolutePath());
    final File fqnListFile = new File(tempDirectory, "inspection_fqn_list.txt");
    final boolean fqnOk = doDump(fqnListFile, new Processor() {

        @Override
        public void process(BufferedWriter writer) throws Exception {
            for (String name : classes) {
                writer.write(name);
                writer.newLine();
            }
        }
    });
    if (fqnOk) {
        doNotify("Inspection class names dumped to\n" + fqnListFile.getAbsolutePath());
    }
    final File groupsFile = new File(tempDirectory, "inspection_groups.txt");
    final boolean groupsOk = doDump(groupsFile, new Processor() {

        @Override
        public void process(BufferedWriter writer) throws Exception {
            for (Map.Entry<String, Collection<String>> entry : groups.entrySet()) {
                writer.write(entry.getKey());
                writer.write(':');
                writer.newLine();
                for (String name : entry.getValue()) {
                    writer.write("  ");
                    writer.write(name);
                    writer.newLine();
                }
            }
        }
    });
    if (groupsOk) {
        doNotify("Inspection groups dumped to\n" + fqnListFile.getAbsolutePath());
    }
}
Also used : InspectionProfile(com.intellij.codeInspection.InspectionProfile) URL(java.net.URL) BufferedWriter(java.io.BufferedWriter) Collection(java.util.Collection) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) File(java.io.File)

Example 22 with InspectionToolWrapper

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

the class JavaAwareInspectionProfileCoverter method fillErrorLevels.

@Override
protected void fillErrorLevels(InspectionProfileImpl profile) {
    super.fillErrorLevels(profile);
    //javadoc attributes
    InspectionToolWrapper toolWrapper = profile.getInspectionTool(JavaDocLocalInspectionBase.SHORT_NAME, (PsiElement) null);
    JavaDocLocalInspectionBase inspection = (JavaDocLocalInspectionBase) toolWrapper.getTool();
    inspection.myAdditionalJavadocTags = myAdditionalJavadocTags;
}
Also used : JavaDocLocalInspectionBase(com.intellij.codeInspection.javaDoc.JavaDocLocalInspectionBase) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 23 with InspectionToolWrapper

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

the class HTMLExportFrameMaker method done.

@SuppressWarnings({ "HardCodedStringLiteral" })
public void done() {
    StringBuffer buf = new StringBuffer();
    if (myInspectionToolWrappers.isEmpty()) {
        buf.append("Everything is fine. Nothing is ruined.");
    } else {
        for (InspectionToolWrapper toolWrapper : myInspectionToolWrappers) {
            buf.append("<A HREF=\"");
            buf.append(toolWrapper.getFolderName());
            buf.append("-index.html\">");
            buf.append(toolWrapper.getDisplayName());
            buf.append("</A><BR>");
        }
    }
    HTMLExportUtil.writeFile(myRootFolder, "index.html", buf, myProject);
}
Also used : InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 24 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper 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 25 with InspectionToolWrapper

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

the class DaemonRespondToChangesTest method configureLocalInspectionTools.

@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
    if (isStressTest() && !getTestName(false).equals("TypingCurliesClearsEndOfFileErrorsInPhp_ItIsPerformanceTestBecauseItRunsTooLong")) {
        // all possible inspections
        List<InspectionToolWrapper> all = InspectionToolRegistrar.getInstance().createTools();
        List<LocalInspectionTool> locals = new ArrayList<>();
        all.stream().filter(tool -> tool instanceof LocalInspectionToolWrapper).forEach(tool -> {
            LocalInspectionTool e = ((LocalInspectionToolWrapper) tool).getTool();
            locals.add(e);
        });
        return locals.toArray(new LocalInspectionTool[locals.size()]);
    }
    return new LocalInspectionTool[] { new FieldCanBeLocalInspection(), new RequiredAttributesInspectionBase(), new CheckDtdReferencesInspection(), new AccessStaticViaInstance() };
}
Also used : TypedAction(com.intellij.openapi.editor.actionSystem.TypedAction) UIUtil(com.intellij.util.ui.UIUtil) com.intellij.testFramework(com.intellij.testFramework) VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet) DocumentMarkupModel(com.intellij.openapi.editor.impl.DocumentMarkupModel) ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) AccessToken(com.intellij.openapi.application.AccessToken) CompletionContributor(com.intellij.codeInsight.completion.CompletionContributor) com.intellij.lang(com.intellij.lang) PerformanceWatcher(com.intellij.diagnostic.PerformanceWatcher) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) CodeFoldingManager(com.intellij.codeInsight.folding.CodeFoldingManager) RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) EditorActionManager(com.intellij.openapi.editor.actionSystem.EditorActionManager) Module(com.intellij.openapi.module.Module) TextEditor(com.intellij.openapi.fileEditor.TextEditor) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PlainTextFileType(com.intellij.openapi.fileTypes.PlainTextFileType) TextRange(com.intellij.openapi.util.TextRange) HighlighterTargetArea(com.intellij.openapi.editor.markup.HighlighterTargetArea) MarkupModel(com.intellij.openapi.editor.markup.MarkupModel) ConsoleView(com.intellij.execution.ui.ConsoleView) DeleteCatchFix(com.intellij.codeInsight.daemon.impl.quickfix.DeleteCatchFix) com.intellij.util(com.intellij.util) LightweightHint(com.intellij.ui.LightweightHint) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl) InspectionProjectProfileManager(com.intellij.profile.codeInspection.InspectionProjectProfileManager) ProperTextRange(com.intellij.openapi.util.ProperTextRange) java.util(java.util) ExternalResourceManagerExImpl(com.intellij.javaee.ExternalResourceManagerExImpl) com.intellij.openapi.editor(com.intellij.openapi.editor) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) EditorInfo(com.intellij.codeInsight.EditorInfo) Annotator(com.intellij.lang.annotation.Annotator) ThreadDumper(com.intellij.diagnostic.ThreadDumper) InspectionToolRegistrar(com.intellij.codeInspection.ex.InspectionToolRegistrar) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) Segment(com.intellij.openapi.util.Segment) TextConsoleBuilderFactory(com.intellij.execution.filters.TextConsoleBuilderFactory) AccessStaticViaInstance(com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance) JavaLanguage(com.intellij.lang.java.JavaLanguage) DebugUtil(com.intellij.psi.impl.DebugUtil) StdFileTypes(com.intellij.openapi.fileTypes.StdFileTypes) Language(org.intellij.lang.annotations.Language) StringUtil(com.intellij.openapi.util.text.StringUtil) UnusedDeclarationInspectionBase(com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) IOException(java.io.IOException) StorageUtilKt(com.intellij.configurationStore.StorageUtilKt) AbstractIntentionAction(com.intellij.codeInsight.intention.AbstractIntentionAction) Disposable(com.intellij.openapi.Disposable) InlineRefactoringActionHandler(com.intellij.refactoring.inline.InlineRefactoringActionHandler) File(java.io.File) java.awt(java.awt) AtomicLong(java.util.concurrent.atomic.AtomicLong) RequiredAttributesInspectionBase(com.intellij.codeInspection.htmlInspections.RequiredAttributesInspectionBase) Result(com.intellij.openapi.application.Result) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) UndoManager(com.intellij.openapi.command.undo.UndoManager) LocalInspectionTool(com.intellij.codeInspection.LocalInspectionTool) ApplicationManagerEx(com.intellij.openapi.application.ex.ApplicationManagerEx) SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) HeavyProcessLatch(com.intellij.util.io.storage.HeavyProcessLatch) CheckDtdReferencesInspection(com.intellij.xml.util.CheckDtdReferencesInspection) GutterIconRenderer(com.intellij.openapi.editor.markup.GutterIconRenderer) ExternalAnnotator(com.intellij.lang.annotation.ExternalAnnotator) HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) PsiAwareTextEditorProvider(com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorProvider) MarkupModelEx(com.intellij.openapi.editor.ex.MarkupModelEx) AnnotationHolder(com.intellij.lang.annotation.AnnotationHolder) IdeActions(com.intellij.openapi.actionSystem.IdeActions) Nls(org.jetbrains.annotations.Nls) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType) ProjectManager(com.intellij.openapi.project.ProjectManager) RangeHighlighterEx(com.intellij.openapi.editor.ex.RangeHighlighterEx) SaveAndSyncHandlerImpl(com.intellij.ide.SaveAndSyncHandlerImpl) Disposer(com.intellij.openapi.util.Disposer) EditorHintListener(com.intellij.codeInsight.hint.EditorHintListener) EditorEx(com.intellij.openapi.editor.ex.EditorEx) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) Method(java.lang.reflect.Method) LightQuickFixTestCase(com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase) ProblemsHolder(com.intellij.codeInspection.ProblemsHolder) IntentionHintComponent(com.intellij.codeInsight.intention.impl.IntentionHintComponent) JavaFileType(com.intellij.ide.highlighter.JavaFileType) com.intellij.codeInsight.daemon(com.intellij.codeInsight.daemon) Collectors(java.util.stream.Collectors) com.intellij.codeHighlighting(com.intellij.codeHighlighting) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) ApplicationManager(com.intellij.openapi.application.ApplicationManager) GeneralSettings(com.intellij.ide.GeneralSettings) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) com.intellij.psi(com.intellij.psi) NotNull(org.jetbrains.annotations.NotNull) HintListener(com.intellij.ui.HintListener) WriteAction(com.intellij.openapi.application.WriteAction) DataContext(com.intellij.openapi.actionSystem.DataContext) NonNls(org.jetbrains.annotations.NonNls) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ContainerUtil(com.intellij.util.containers.ContainerUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) RenameProcessor(com.intellij.refactoring.rename.RenameProcessor) InspectionProfile(com.intellij.codeInspection.InspectionProfile) IntentionManager(com.intellij.codeInsight.intention.IntentionManager) Project(com.intellij.openapi.project.Project) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) CodeInsightTestFixtureImpl(com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl) FieldCanBeLocalInspection(com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection) TextEditorProvider(com.intellij.openapi.fileEditor.impl.text.TextEditorProvider) MarkupModelListener(com.intellij.openapi.editor.impl.event.MarkupModelListener) AbstractProjectComponent(com.intellij.openapi.components.AbstractProjectComponent) CommandProcessor(com.intellij.openapi.command.CommandProcessor) UnusedDeclarationInspection(com.intellij.codeInspection.deadCode.UnusedDeclarationInspection) FieldCanBeLocalInspection(com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection) AccessStaticViaInstance(com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance) CheckDtdReferencesInspection(com.intellij.xml.util.CheckDtdReferencesInspection) RequiredAttributesInspectionBase(com.intellij.codeInspection.htmlInspections.RequiredAttributesInspectionBase) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) LocalInspectionTool(com.intellij.codeInspection.LocalInspectionTool) LocalInspectionToolWrapper(com.intellij.codeInspection.ex.LocalInspectionToolWrapper)

Aggregations

InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)34 NotNull (org.jetbrains.annotations.NotNull)10 InspectionProfile (com.intellij.codeInspection.InspectionProfile)7 LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)6 File (java.io.File)6 Project (com.intellij.openapi.project.Project)5 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)4 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)3 TextRange (com.intellij.openapi.util.TextRange)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiFile (com.intellij.psi.PsiFile)3 Element (org.jdom.Element)3 AnalysisScope (com.intellij.analysis.AnalysisScope)2 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)2 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)2 IntentionManager (com.intellij.codeInsight.intention.IntentionManager)2 IntentionHintComponent (com.intellij.codeInsight.intention.impl.IntentionHintComponent)2 GlobalInspectionToolWrapper (com.intellij.codeInspection.ex.GlobalInspectionToolWrapper)2 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)2 InspectionResultsView (com.intellij.codeInspection.ui.InspectionResultsView)2