use of com.android.tools.klint.client.api.IssueRegistry in project kotlin by JetBrains.
the class AndroidLintExternalAnnotator method getIssuesFromInspections.
@NotNull
static List<Issue> getIssuesFromInspections(@NotNull Project project, @Nullable PsiElement context) {
final List<Issue> result = new ArrayList<Issue>();
final IssueRegistry fullRegistry = new IntellijLintIssueRegistry();
for (Issue issue : fullRegistry.getIssues()) {
final String inspectionShortName = AndroidLintInspectionBase.getInspectionShortNameByIssue(project, issue);
if (inspectionShortName == null) {
continue;
}
final HighlightDisplayKey key = HighlightDisplayKey.find(inspectionShortName);
if (key == null) {
continue;
}
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
final boolean enabled = context != null ? profile.isToolEnabled(key, context) : profile.isToolEnabled(key);
if (!enabled) {
continue;
} else if (!issue.isEnabledByDefault()) {
// If an issue is marked as not enabled by default, lint won't run it, even if it's in the set
// of issues provided by an issue registry. Since in the IDE we're enforcing the enabled-state via
// inspection profiles, mark the issue as enabled to allow users to turn on a lint check directly
// via the inspections UI.
issue.setEnabledByDefault(true);
}
result.add(issue);
}
return result;
}
Aggregations