use of com.intellij.codeInspection.InspectionProfile in project kotlin by JetBrains.
the class AndroidLintUtil method getHighlighLevelAndInspection.
@Nullable
public static Pair<AndroidLintInspectionBase, HighlightDisplayLevel> getHighlighLevelAndInspection(@NotNull Project project, @NotNull Issue issue, @NotNull PsiElement context) {
final String inspectionShortName = AndroidLintInspectionBase.getInspectionShortNameByIssue(project, issue);
if (inspectionShortName == null) {
return null;
}
final HighlightDisplayKey key = HighlightDisplayKey.find(inspectionShortName);
if (key == null) {
return null;
}
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
if (!profile.isToolEnabled(key, context)) {
if (!issue.isEnabledByDefault()) {
// Lint will skip issues (and not report them) for issues that have been disabled,
// except for those issues that are explicitly enabled via Gradle. Therefore, if
// we get this far, lint has found this issue to be explicitly enabled, so we let
// that setting override a local enabled/disabled state in the IDE profile.
} else {
return null;
}
}
final AndroidLintInspectionBase inspection = (AndroidLintInspectionBase) profile.getUnwrappedTool(inspectionShortName, context);
if (inspection == null)
return null;
final HighlightDisplayLevel errorLevel = profile.getErrorLevel(key, context);
return Pair.create(inspection, errorLevel != null ? errorLevel : HighlightDisplayLevel.WARNING);
}
use of com.intellij.codeInspection.InspectionProfile 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.InspectionProfile 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);
}
Aggregations