use of com.intellij.lang.documentation.DocumentationProvider in project intellij-plugins by JetBrains.
the class FlexCssPropertyDescriptor method getDocumentationString.
@Nullable
public String getDocumentationString(@Nullable PsiElement context) {
if (context == null)
return null;
PsiElement[] declarations = getDeclarations(context);
List<DocumentationElement> docElements = new ArrayList<>();
for (PsiElement declaration : declarations) {
PsiFile file = declaration.getContainingFile();
if (file != null) {
DocumentationProvider provider = DocumentationManager.getProviderFromElement(declaration);
String docForDeclaration = provider.generateDoc(declaration, declaration);
if (docForDeclaration != null) {
JSClass jsClass = PsiTreeUtil.getParentOfType(declaration, JSClass.class);
String header = jsClass != null ? jsClass.getQualifiedName() : file.getName();
docElements.add(new DocumentationElement(header, docForDeclaration));
}
}
}
Collections.sort(docElements, (e1, e2) -> Comparing.compare(e1.header, e2.header));
StringBuilder builder = new StringBuilder();
for (int i = 0, n = docElements.size(); i < n; i++) {
DocumentationElement docElement = docElements.get(i);
builder.append("<b>").append(docElement.header).append("</b>").append("<br>\n");
builder.append(docElement.documentation);
if (i != n - 1) {
builder.append("<br><br>\n\n");
}
}
return builder.toString();
}
use of com.intellij.lang.documentation.DocumentationProvider in project android by JetBrains.
the class AndroidDomTestCase method doTestExternalDoc.
protected final void doTestExternalDoc(String expectedPart) {
PsiElement originalElement = myFixture.getFile().findElementAt(myFixture.getEditor().getCaretModel().getOffset());
PsiElement docTargetElement = DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
DocumentationProvider provider = DocumentationManager.getProviderFromElement(docTargetElement);
List<String> urls = provider.getUrlFor(docTargetElement, originalElement);
String doc = ((ExternalDocumentationProvider) provider).fetchExternalDocumentation(myFixture.getProject(), docTargetElement, urls);
assertNotNull(doc);
assertTrue("Can't find " + expectedPart + " in " + doc, doc.contains(expectedPart));
}
use of com.intellij.lang.documentation.DocumentationProvider in project android by JetBrains.
the class AndroidLayoutDomTest method testDimenUnitsCompletion1.
public void testDimenUnitsCompletion1() throws Exception {
VirtualFile file = copyFileToProject(getTestName(true) + ".xml");
myFixture.configureFromExistingVirtualFile(file);
myFixture.complete(CompletionType.BASIC);
UsefulTestCase.assertSameElements(myFixture.getLookupElementStrings(), "3dp", "3px", "3sp", "3pt", "3mm", "3in");
PsiElement originalElement = myFixture.getFile().findElementAt(myFixture.getEditor().getCaretModel().getOffset());
LookupEx lookup = myFixture.getLookup();
LookupElement dpElement = null;
LookupElement pxElement = null;
for (LookupElement element : lookup.getItems()) {
if (element.getLookupString().endsWith("dp")) {
dpElement = element;
} else if (element.getLookupString().endsWith("px")) {
pxElement = element;
}
}
DocumentationProvider provider;
PsiElement docTargetElement;
lookup.setCurrentItem(dpElement);
docTargetElement = DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
provider = DocumentationManager.getProviderFromElement(docTargetElement);
assertEquals("<html><body><b>Density-independent Pixels</b> - an abstract unit that is based on the physical " + "density of the screen.</body></html>", provider.generateDoc(docTargetElement, originalElement));
lookup.setCurrentItem(pxElement);
docTargetElement = DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
provider = DocumentationManager.getProviderFromElement(docTargetElement);
assertEquals("<html><body><b>Pixels</b> - corresponds to actual pixels on the screen. Not recommended.</body></html>", provider.generateDoc(docTargetElement, originalElement));
}
use of com.intellij.lang.documentation.DocumentationProvider in project intellij-plugins by JetBrains.
the class FlexDocumentationTest method testFlexCssSelector.
@JSTestOptions({ JSTestOption.WithCssSupportLoader, JSTestOption.WithFlexFacet })
public void testFlexCssSelector() throws Exception {
DocumentationProvider cssDocumentationProvider = new CssDocumentationProvider();
PsiElement docElement = getDocElementForLookupItem(cssDocumentationProvider, getTestName(false) + ".css");
assertInstanceOf(docElement, JSClass.class);
}
Aggregations