use of com.intellij.codeHighlighting.HighlightDisplayLevel in project kotlin by JetBrains.
the class AndroidLintInspectionBase method getDefaultLevel.
@NotNull
@Override
public HighlightDisplayLevel getDefaultLevel() {
final Severity defaultSeverity = myIssue.getDefaultSeverity();
if (defaultSeverity == null) {
return HighlightDisplayLevel.WARNING;
}
final HighlightDisplayLevel displayLevel = toHighlightDisplayLevel(defaultSeverity);
return displayLevel != null ? displayLevel : HighlightDisplayLevel.WARNING;
}
use of com.intellij.codeHighlighting.HighlightDisplayLevel in project android by JetBrains.
the class AndroidLintInspectionBase method getDefaultLevel.
@NotNull
@Override
public HighlightDisplayLevel getDefaultLevel() {
final Severity defaultSeverity = myIssue.getDefaultSeverity();
if (defaultSeverity == null) {
return HighlightDisplayLevel.WARNING;
}
final HighlightDisplayLevel displayLevel = toHighlightDisplayLevel(defaultSeverity);
return displayLevel != null ? displayLevel : HighlightDisplayLevel.WARNING;
}
use of com.intellij.codeHighlighting.HighlightDisplayLevel in project android 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()).getCurrentProfile();
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.codeHighlighting.HighlightDisplayLevel in project android by JetBrains.
the class NlLintHighlightingPass method getAnnotations.
@NotNull
private static LintAnnotationsModel getAnnotations(@NotNull NlModel model, @NotNull ProgressIndicator progress) {
ApplicationManager.getApplication().assertReadAccessAllowed();
LintAnnotationsModel lintModel = new LintAnnotationsModel();
XmlFile xmlFile = model.getFile();
AndroidLintExternalAnnotator annotator = new AndroidLintExternalAnnotator();
State state = annotator.collectInformation(xmlFile);
if (state != null) {
state = annotator.doAnnotate(state);
}
if (state == null) {
return lintModel;
}
for (ProblemData problemData : state.getProblems()) {
if (progress.isCanceled()) {
break;
}
TextRange range = problemData.getTextRange();
final PsiElement startElement = xmlFile.findElementAt(range.getStartOffset());
final PsiElement endElement = xmlFile.findElementAt(range.getEndOffset());
if (startElement == null || endElement == null) {
continue;
}
NlComponent component = model.findViewByPsi(startElement);
if (component == null) {
continue;
}
Issue issue = problemData.getIssue();
Pair<AndroidLintInspectionBase, HighlightDisplayLevel> pair = AndroidLintUtil.getHighlighLevelAndInspection(xmlFile.getProject(), issue, xmlFile);
if (pair == null) {
continue;
}
AndroidLintInspectionBase inspection = pair.getFirst();
if (inspection == null) {
continue;
}
HighlightDisplayLevel level = pair.getSecond();
HighlightDisplayKey key = HighlightDisplayKey.find(inspection.getShortName());
if (key == null) {
continue;
}
lintModel.addIssue(component, issue, problemData.getMessage(), inspection, level, startElement, endElement);
}
return lintModel;
}
use of com.intellij.codeHighlighting.HighlightDisplayLevel in project intellij-community by JetBrains.
the class RegExpInspectionTestCase method highlightTest.
protected void highlightTest(@Language("RegExp") String code) {
final LocalInspectionTool inspection = getInspection();
myFixture.enableInspections(inspection);
final HighlightDisplayKey displayKey = HighlightDisplayKey.find(inspection.getShortName());
if (displayKey != null) {
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(RegExpFileType.INSTANCE, code);
myFixture.testHighlighting();
}
Aggregations