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;
}
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"));
}
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);
}
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);
}
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);
}
Aggregations