use of com.intellij.codeInspection.ex.InspectionProfileImpl in project intellij-community by JetBrains.
the class InspectionProfileLoadUtil method load.
@NotNull
public static InspectionProfileImpl load(@NotNull Path file, @NotNull InspectionToolRegistrar registrar, @NotNull InspectionProfileManager profileManager) throws JDOMException, IOException, InvalidDataException {
Element element = JdomKt.loadElement(file);
InspectionProfileImpl profile = new InspectionProfileImpl(getProfileName(file, element), registrar, (BaseInspectionProfileManager) profileManager);
final Element profileElement = element.getChild("profile");
if (profileElement != null) {
element = profileElement;
}
profile.readExternal(element);
return profile;
}
use of com.intellij.codeInspection.ex.InspectionProfileImpl in project intellij-community by JetBrains.
the class ExternalToolPass method collectInformationWithProgress.
@Override
protected void collectInformationWithProgress(@NotNull ProgressIndicator progress) {
final FileViewProvider viewProvider = myFile.getViewProvider();
final Set<Language> relevantLanguages = viewProvider.getLanguages();
int externalAnnotatorsInRoots = 0;
for (Language language : relevantLanguages) {
PsiFile psiRoot = viewProvider.getPsi(language);
if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(psiRoot))
continue;
final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, psiRoot);
externalAnnotatorsInRoots += externalAnnotators.size();
}
setProgressLimit(externalAnnotatorsInRoots);
InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(myProject).getCurrentProfile();
for (Language language : relevantLanguages) {
PsiFile psiRoot = viewProvider.getPsi(language);
if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(psiRoot))
continue;
final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, psiRoot);
if (!externalAnnotators.isEmpty()) {
DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
boolean errorFound = daemonCodeAnalyzer.getFileStatusMap().wasErrorFound(myDocument);
for (ExternalAnnotator externalAnnotator : externalAnnotators) {
String shortName = externalAnnotator.getPairedBatchInspectionShortName();
if (shortName != null) {
HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
LOG.assertTrue(key != null, "Paired tool '" + shortName + "' not found for external annotator: " + externalAnnotator);
if (!profile.isToolEnabled(key, myFile))
continue;
}
final Object collectedInfo;
Editor editor = getEditor();
if (editor != null) {
collectedInfo = externalAnnotator.collectInformation(psiRoot, editor, errorFound);
} else {
collectedInfo = externalAnnotator.collectInformation(psiRoot);
}
advanceProgress(1);
if (collectedInfo != null) {
myAnnotator2DataMap.put(externalAnnotator, new MyData(psiRoot, collectedInfo));
}
}
}
}
}
use of com.intellij.codeInspection.ex.InspectionProfileImpl 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);
}
}
use of com.intellij.codeInspection.ex.InspectionProfileImpl in project intellij-community by JetBrains.
the class HtmlMissingClosingTagInspectionTest method highlightTest.
protected void highlightTest(@Language("HTML") String code) {
final LocalInspectionTool inspection = getInspection();
myFixture.enableInspections(inspection);
final HighlightDisplayKey displayKey = HighlightDisplayKey.find(inspection.getShortName());
final Project project = myFixture.getProject();
final InspectionProfileImpl currentProfile = ProjectInspectionProfileManager.getInstance(project).getCurrentProfile();
final HighlightDisplayLevel errorLevel = currentProfile.getErrorLevel(displayKey, null);
if (errorLevel == HighlightDisplayLevel.DO_NOT_SHOW) {
currentProfile.setErrorLevel(displayKey, HighlightDisplayLevel.WARNING, project);
}
myFixture.configureByText(HtmlFileType.INSTANCE, code);
myFixture.testHighlighting();
}
Aggregations