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;
}
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;
}
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));
}
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);
}
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();
}
Aggregations