Search in sources :

Example 16 with InspectionProfileImpl

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

the class InspectionToolsConfigurable method importInspectionProfile.

public static InspectionProfileImpl importInspectionProfile(@NotNull Element rootElement, @NotNull BaseInspectionProfileManager profileManager, @NotNull Project project) {
    InspectionProfileImpl profile = new InspectionProfileImpl("TempProfile", InspectionToolRegistrar.getInstance(), profileManager);
    if (Comparing.strEqual(rootElement.getName(), "component")) {
        //import right from .idea/inspectProfiles/xxx.xml
        rootElement = rootElement.getChildren().get(0);
    }
    final Set<String> levels = new HashSet<>();
    for (Element inspectElement : rootElement.getChildren("inspection_tool")) {
        addLevelIfNotNull(levels, inspectElement);
        for (Element s : inspectElement.getChildren("scope")) {
            addLevelIfNotNull(levels, s);
        }
    }
    for (Iterator<String> iterator = levels.iterator(); iterator.hasNext(); ) {
        String level = iterator.next();
        if (profileManager.getOwnSeverityRegistrar().getSeverity(level) != null) {
            iterator.remove();
        }
    }
    if (!levels.isEmpty()) {
        if (!ApplicationManager.getApplication().isUnitTestMode()) {
            if (Messages.showYesNoDialog(project, "Undefined severities detected: " + StringUtil.join(levels, ", ") + ". Do you want to create them?", "Warning", Messages.getWarningIcon()) == Messages.YES) {
                for (String level : levels) {
                    final TextAttributes textAttributes = CodeInsightColors.WARNINGS_ATTRIBUTES.getDefaultAttributes();
                    HighlightInfoType.HighlightInfoTypeImpl info = new HighlightInfoType.HighlightInfoTypeImpl(new HighlightSeverity(level, 50), TextAttributesKey.createTextAttributesKey(level));
                    profileManager.getOwnSeverityRegistrar().registerSeverity(new SeverityRegistrar.SeverityBasedTextAttributes(textAttributes.clone(), info), textAttributes.getErrorStripeColor());
                }
            }
        } else {
            throw new AssertionError("All of levels must exist in unit-test mode, but actual not exist levels = " + levels);
        }
    }
    profile.readExternal(rootElement);
    profile.setProjectLevel(false);
    profile.initInspectionTools(project);
    return profile;
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) Element(org.jdom.Element) HighlightInfoType(com.intellij.codeInsight.daemon.impl.HighlightInfoType) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) SeverityRegistrar(com.intellij.codeInsight.daemon.impl.SeverityRegistrar) HashSet(java.util.HashSet)

Example 17 with InspectionProfileImpl

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

the class DaemonCodeAnalyzerSettingsImpl method loadState.

@Override
public void loadState(Element state) {
    XmlSerializer.deserializeInto(this, state);
    ApplicationInspectionProfileManager inspectionProfileManager = ApplicationInspectionProfileManager.getInstanceImpl();
    inspectionProfileManager.getConverter().storeEditorHighlightingProfile(state, new InspectionProfileImpl(InspectionProfileConvertor.OLD_HIGHTLIGHTING_SETTINGS_PROFILE));
    inspectionProfileManager.setRootProfile(StringUtil.notNullize(state.getAttributeValue("profile"), "Default"));
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) ApplicationInspectionProfileManager(com.intellij.codeInspection.ex.ApplicationInspectionProfileManager)

Example 18 with InspectionProfileImpl

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

the class ViewOfflineResultsAction method showOfflineView.

//used in TeamCity
@SuppressWarnings({ "WeakerAccess", "UnusedReturnValue" })
public static InspectionResultsView showOfflineView(@NotNull Project project, @Nullable final String profileName, @NotNull final Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap, @NotNull String title) {
    InspectionProfileImpl profile;
    if (profileName != null) {
        profile = InspectionProjectProfileManager.getInstance(project).getProfile(profileName, false);
        if (profile == null) {
            profile = InspectionProfileManager.getInstance().getProfile(profileName, false);
        }
    } else {
        profile = null;
    }
    final InspectionProfileImpl inspectionProfile;
    if (profile != null) {
        inspectionProfile = profile;
    } else {
        inspectionProfile = new InspectionProfileImpl(profileName != null ? profileName : "Server Side") {

            @Override
            public HighlightDisplayLevel getErrorLevel(@NotNull final HighlightDisplayKey key, PsiElement element) {
                return InspectionProfileManager.getInstance().getCurrentProfile().getErrorLevel(key, element);
            }
        };
        for (String id : resMap.keySet()) {
            if (inspectionProfile.getToolsOrNull(id, project) != null) {
                inspectionProfile.enableTool(id, project);
            }
        }
    }
    return showOfflineView(project, resMap, inspectionProfile, title);
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) HighlightDisplayLevel(com.intellij.codeHighlighting.HighlightDisplayLevel) HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) PsiElement(com.intellij.psi.PsiElement)

Example 19 with InspectionProfileImpl

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

the class CodeInspectionAction method reloadProfiles.

private void reloadProfiles(SchemesCombo<InspectionProfileImpl> profilesCombo, InspectionProfileManager appProfileManager, InspectionProjectProfileManager projectProfileManager, Project project) {
    profilesCombo.resetSchemes(InspectionProfileSchemesModel.getSortedProfiles(appProfileManager, projectProfileManager));
    InspectionProfileImpl selectedProfile = getProfileToUse(project, appProfileManager, projectProfileManager);
    profilesCombo.selectScheme(selectedProfile);
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl)

Example 20 with InspectionProfileImpl

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

the class BaseInspection method isInspectionEnabled.

public static boolean isInspectionEnabled(@NonNls String shortName, PsiElement context) {
    final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(context.getProject());
    final InspectionProfileImpl profile = profileManager.getCurrentProfile();
    return profile.isToolEnabled(HighlightDisplayKey.find(shortName), context);
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) InspectionProjectProfileManager(com.intellij.profile.codeInspection.InspectionProjectProfileManager)

Aggregations

InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)24 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)7 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)5 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)5 Project (com.intellij.openapi.project.Project)5 NotNull (org.jetbrains.annotations.NotNull)5 SingleInspectionProfilePanel (com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel)3 ActionEvent (java.awt.event.ActionEvent)3 InspectionProfile (com.intellij.codeInspection.InspectionProfile)2 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)2 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)2 InspectionProfileModifiableModel (com.intellij.codeInspection.ex.InspectionProfileModifiableModel)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 PsiFile (com.intellij.psi.PsiFile)2 Element (org.jdom.Element)2 AnalysisScope (com.intellij.analysis.AnalysisScope)1 AnalysisUIOptions (com.intellij.analysis.AnalysisUIOptions)1 BaseAnalysisActionDialog (com.intellij.analysis.BaseAnalysisActionDialog)1 DescriptionAwareSchemeActions (com.intellij.application.options.schemes.DescriptionAwareSchemeActions)1 SchemesCombo (com.intellij.application.options.schemes.SchemesCombo)1