Search in sources :

Example 16 with DocumentationProvider

use of com.intellij.lang.documentation.DocumentationProvider in project intellij-community by JetBrains.

the class HtmlDocumentationProvider method getUrlFor.

@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement) {
    String result = getUrlForHtml(element, PsiTreeUtil.getParentOfType(originalElement, XmlTag.class, false));
    DocumentationProvider styleProvider = getStyleProvider();
    if (result == null && styleProvider != null) {
        return styleProvider.getUrlFor(element, originalElement);
    }
    return result != null ? Collections.singletonList(result) : null;
}
Also used : DocumentationProvider(com.intellij.lang.documentation.DocumentationProvider)

Example 17 with DocumentationProvider

use of com.intellij.lang.documentation.DocumentationProvider in project intellij-community by JetBrains.

the class HtmlDocumentationProvider method getDocumentationElementForLookupItem.

@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
    PsiElement result = createNavigationElementHTML(psiManager, object.toString(), element);
    DocumentationProvider styleProvider = getStyleProvider();
    if (result == null && styleProvider != null) {
        result = styleProvider.getDocumentationElementForLookupItem(psiManager, object, element);
    }
    if (result == null && ourScriptProvider != null) {
        result = ourScriptProvider.getDocumentationElementForLookupItem(psiManager, object, element);
    }
    if (result == null && object instanceof String && element != null) {
        result = XmlDocumentationProvider.findDeclWithName((String) object, element);
    }
    return result;
}
Also used : PsiElement(com.intellij.psi.PsiElement) DocumentationProvider(com.intellij.lang.documentation.DocumentationProvider)

Example 18 with DocumentationProvider

use of com.intellij.lang.documentation.DocumentationProvider in project intellij-community by JetBrains.

the class HtmlDocumentationTest method doTest.

private static void doTest(String text) throws Exception {
    configureFromFileText("test.html", text);
    PsiElement originalElement = getFile().findElementAt(myEditor.getCaretModel().getOffset());
    PsiElement element = DocumentationManager.getInstance(getProject()).findTargetElement(getEditor(), getFile());
    DocumentationProvider documentationProvider = DocumentationManager.getProviderFromElement(originalElement);
    assertNotNull("inline help is null", documentationProvider.generateDoc(element, originalElement));
    assertNotNull("external help is null", documentationProvider.getUrlFor(element, originalElement));
}
Also used : PsiElement(com.intellij.psi.PsiElement) DocumentationProvider(com.intellij.lang.documentation.DocumentationProvider)

Example 19 with DocumentationProvider

use of com.intellij.lang.documentation.DocumentationProvider in project intellij-plugins by JetBrains.

the class DocumentationTest method testDocumentationInLookup.

public void testDocumentationInLookup() {
    myFixture.configureByFiles("standardCompletion.html", "angular.js");
    PsiElement context = myFixture.getFile().findElementAt(myFixture.getEditor().getCaretModel().getOffset() - 1);
    assertNotNull(context);
    myFixture.completeBasic();
    LookupElement[] elements = myFixture.getLookupElements();
    assertNotNull(elements);
    LookupElement lookupElement = ContainerUtil.find(elements, element -> element.getAllLookupStrings().contains("ng-controller"));
    assertNotNull(lookupElement);
    DocumentationProvider documentationProvider = DocumentationManager.getProviderFromElement(myFixture.getFile());
    PsiElement docElement = documentationProvider.getDocumentationElementForLookupItem(getPsiManager(), lookupElement.getObject(), context);
    assertNotNull(docElement);
    assertDocumentation(docElement, context);
}
Also used : LookupElement(com.intellij.codeInsight.lookup.LookupElement) PsiElement(com.intellij.psi.PsiElement) DocumentationProvider(com.intellij.lang.documentation.DocumentationProvider)

Example 20 with DocumentationProvider

use of com.intellij.lang.documentation.DocumentationProvider in project intellij-plugins by JetBrains.

the class FlexCssElementDescriptorProvider method generateDocForSelector.

public String generateDocForSelector(@NotNull String selectorName, @Nullable PsiElement context) {
    PsiElement[] declarations = getDeclarationsForSimpleSelector(selectorName, context);
    JSClass[] classes = new JSClass[declarations.length];
    for (int i = 0; i < declarations.length; i++) {
        PsiElement declaration = declarations[i];
        assert declaration instanceof JSClass;
        classes[i] = (JSClass) declaration;
    }
    Arrays.sort(classes, (c1, c2) -> Comparing.compare(c1.getQualifiedName(), c2.getQualifiedName()));
    StringBuilder builder = new StringBuilder();
    for (int i = 0, n = classes.length; i < n; i++) {
        JSClass jsClass = classes[i];
        PsiFile file = jsClass.getContainingFile();
        if (file != null) {
            DocumentationProvider provider = DocumentationManager.getProviderFromElement(jsClass);
            String docForDeclaration = provider.generateDoc(jsClass, jsClass);
            if (docForDeclaration != null) {
                builder.append(docForDeclaration);
                if (i != n - 1) {
                    builder.append("<br><br>\n\n");
                }
            }
        }
    }
    return builder.toString();
}
Also used : PsiFile(com.intellij.psi.PsiFile) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement) ModuleUtilCore.findModuleForPsiElement(com.intellij.openapi.module.ModuleUtilCore.findModuleForPsiElement) DocumentationProvider(com.intellij.lang.documentation.DocumentationProvider)

Aggregations

DocumentationProvider (com.intellij.lang.documentation.DocumentationProvider)24 PsiElement (com.intellij.psi.PsiElement)15 FlexDocumentationProvider (com.intellij.javascript.flex.FlexDocumentationProvider)3 ExternalDocumentationProvider (com.intellij.lang.documentation.ExternalDocumentationProvider)3 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)3 JSDocumentationProvider (com.intellij.lang.javascript.documentation.JSDocumentationProvider)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiFile (com.intellij.psi.PsiFile)3 CssDocumentationProvider (com.intellij.psi.css.impl.util.CssDocumentationProvider)3 LookupElement (com.intellij.codeInsight.lookup.LookupElement)2 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)2 Editor (com.intellij.openapi.editor.Editor)2 DocCommentFixer (com.intellij.codeInsight.documentation.DocCommentFixer)1 LookupEx (com.intellij.codeInsight.lookup.LookupEx)1 CodeDocumentationProvider (com.intellij.lang.documentation.CodeDocumentationProvider)1 CompositeDocumentationProvider (com.intellij.lang.documentation.CompositeDocumentationProvider)1 ExternalDocumentationHandler (com.intellij.lang.documentation.ExternalDocumentationHandler)1 ModuleUtilCore.findModuleForPsiElement (com.intellij.openapi.module.ModuleUtilCore.findModuleForPsiElement)1 Project (com.intellij.openapi.project.Project)1 PopupStep (com.intellij.openapi.ui.popup.PopupStep)1