Search in sources :

Example 31 with InspectionToolWrapper

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

the class AndroidLintInspectionBase method getInspectionShortNameByIssue.

public static String getInspectionShortNameByIssue(@NotNull Project project, @NotNull Issue issue) {
    synchronized (ISSUE_MAP_LOCK) {
        if (ourIssue2InspectionShortName == null) {
            ourIssue2InspectionShortName = new HashMap<Issue, String>();
            final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
            for (InspectionToolWrapper e : profile.getInspectionTools(null)) {
                final String shortName = e.getShortName();
                if (shortName.startsWith("AndroidKLint")) {
                    final InspectionProfileEntry entry = e.getTool();
                    if (entry instanceof AndroidLintInspectionBase) {
                        final Issue s = ((AndroidLintInspectionBase) entry).getIssue();
                        ourIssue2InspectionShortName.put(s, shortName);
                    }
                }
            }
        }
        return ourIssue2InspectionShortName.get(issue);
    }
}
Also used : InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 32 with InspectionToolWrapper

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

the class DomElementAnnotationsManagerImpl method getSuitableDomInspections.

public List<DomElementsInspection> getSuitableDomInspections(final DomFileElement fileElement, boolean enabledOnly) {
    Class rootType = fileElement.getRootElementClass();
    final InspectionProfile profile = getInspectionProfile(fileElement);
    final List<DomElementsInspection> inspections = new SmartList<>();
    for (final InspectionToolWrapper toolWrapper : profile.getInspectionTools(fileElement.getFile())) {
        if (!enabledOnly || profile.isToolEnabled(HighlightDisplayKey.find(toolWrapper.getShortName()), fileElement.getFile())) {
            ContainerUtil.addIfNotNull(inspections, getSuitableInspection(toolWrapper.getTool(), rootType));
        }
    }
    return inspections;
}
Also used : InspectionProfile(com.intellij.codeInspection.InspectionProfile) SmartList(com.intellij.util.SmartList) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 33 with InspectionToolWrapper

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

the class ExternalDocumentValidator method doValidation.

public static synchronized void doValidation(final XmlDocument document, final Validator.ValidationHost host) {
    final PsiFile containingFile = document.getContainingFile();
    if (containingFile == null) {
        return;
    }
    if (containingFile.getViewProvider() instanceof TemplateLanguageFileViewProvider) {
        return;
    }
    final FileType fileType = containingFile.getViewProvider().getFileType();
    if (fileType != XmlFileType.INSTANCE && fileType != XHtmlFileType.INSTANCE) {
        return;
    }
    for (Language lang : containingFile.getViewProvider().getLanguages()) {
        if ("ANT".equals(lang.getID()))
            return;
    }
    final XmlTag rootTag = document.getRootTag();
    if (rootTag == null)
        return;
    String namespace = rootTag.getNamespace();
    if (XmlUtil.ANT_URI.equals(namespace))
        return;
    final Project project = document.getProject();
    final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
    final InspectionToolWrapper toolWrapper = profile.getInspectionTool(INSPECTION_SHORT_NAME, containingFile);
    if (toolWrapper == null)
        return;
    if (!profile.isToolEnabled(HighlightDisplayKey.find(INSPECTION_SHORT_NAME), containingFile))
        return;
    SoftReference<ExternalDocumentValidator> validatorReference = project.getUserData(validatorInstanceKey);
    ExternalDocumentValidator validator = SoftReference.dereference(validatorReference);
    if (validator == null) {
        validator = new ExternalDocumentValidator();
        project.putUserData(validatorInstanceKey, new SoftReference<>(validator));
    }
    validator.runJaxpValidation(document, host);
}
Also used : Project(com.intellij.openapi.project.Project) Language(com.intellij.lang.Language) XHtmlFileType(com.intellij.ide.highlighter.XHtmlFileType) XmlFileType(com.intellij.ide.highlighter.XmlFileType) FileType(com.intellij.openapi.fileTypes.FileType) InspectionProfile(com.intellij.codeInspection.InspectionProfile) PsiFile(com.intellij.psi.PsiFile) TemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 34 with InspectionToolWrapper

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

the class PyCompatibilityInspectionAdvertiser method enableVersions.

private static void enableVersions(@NotNull Project project, @NotNull PsiElement file, @NotNull List<LanguageLevel> versions) {
    final InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
    final String shortName = getCompatibilityInspectionShortName();
    final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
    if (tool != null) {
        profile.modifyProfile(model -> {
            final PyCompatibilityInspection inspection = (PyCompatibilityInspection) model.getUnwrappedTool(shortName, file);
            inspection.ourVersions.addAll(ContainerUtil.map(versions, LanguageLevel::toString));
        });
        EditInspectionToolsSettingsAction.editToolSettings(project, profile, shortName);
    }
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

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