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