Search in sources :

Example 1 with IssueRegistry

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;
}
Also used : Issue(com.android.tools.klint.detector.api.Issue) HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) ArrayList(java.util.ArrayList) IssueRegistry(com.android.tools.klint.client.api.IssueRegistry) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IssueRegistry (com.android.tools.klint.client.api.IssueRegistry)1 Issue (com.android.tools.klint.detector.api.Issue)1 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1