Search in sources :

Example 1 with BuiltinIssueRegistry

use of com.android.tools.klint.checks.BuiltinIssueRegistry in project kotlin by JetBrains.

the class LintInspectionDescriptionLinkHandler method getDescription.

@Override
public String getDescription(@NotNull final String refSuffix, @NotNull final Editor editor) {
    final Project project = editor.getProject();
    if (project == null) {
        LOG.error(editor);
        return null;
    }
    final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    if (file == null) {
        return null;
    }
    Issue issue = new BuiltinIssueRegistry().getIssue(refSuffix);
    if (issue != null) {
        String html = issue.getExplanation(TextFormat.HTML);
        // IntelliJ seems to treat newlines in the HTML as needing to also be converted to <br> (whereas
        // Lint includes these for HTML readability but they shouldn't add additional lines since it has
        // already added <br> as well) so strip these out
        html = html.replace("\n", "");
        return html;
    }
    // TODO: What about custom registries for custom rules, AARs etc?
    LOG.warn("No description for inspection '" + refSuffix + "'");
    return InspectionsBundle.message("inspection.tool.description.under.construction.text");
}
Also used : Project(com.intellij.openapi.project.Project) Issue(com.android.tools.klint.detector.api.Issue) PsiFile(com.intellij.psi.PsiFile) BuiltinIssueRegistry(com.android.tools.klint.checks.BuiltinIssueRegistry)

Aggregations

BuiltinIssueRegistry (com.android.tools.klint.checks.BuiltinIssueRegistry)1 Issue (com.android.tools.klint.detector.api.Issue)1 Project (com.intellij.openapi.project.Project)1 PsiFile (com.intellij.psi.PsiFile)1