当前位置: 首页>>代码示例>>Java>>正文


Java DocumentationManager.getProviderFromElement方法代码示例

本文整理汇总了Java中com.intellij.codeInsight.documentation.DocumentationManager.getProviderFromElement方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentationManager.getProviderFromElement方法的具体用法?Java DocumentationManager.getProviderFromElement怎么用?Java DocumentationManager.getProviderFromElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.codeInsight.documentation.DocumentationManager的用法示例。


在下文中一共展示了DocumentationManager.getProviderFromElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testExtensionPointDocumentation

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
public void testExtensionPointDocumentation() {
  myFixture.configureByFiles("extensionPointDocumentation.xml", "bar/MyExtensionPoint.java");

  final PsiElement docElement =
    DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(),
                                                                     myFixture.getFile());
  DocumentationProvider provider = DocumentationManager.getProviderFromElement(docElement);

  String epDefinition = "[" + myModule.getName() + "] foo<br/>" +
                        "<b>bar</b> (extensionPointDocumentation.xml)<br/>" +
                        "<a href=\"psi_element://bar.MyExtensionPoint\"><code>MyExtensionPoint</code></a>";

  assertEquals(epDefinition,
               provider.getQuickNavigateInfo(docElement, null));

  assertEquals("<em>EP Definition</em><br/>" +
               epDefinition +
               "<br/><br/>" +
               "<em>EP Implementation</em>" +
               "<html><head>    <style type=\"text/css\">        #error {            background-color: #eeeeee;            margin-bottom: 10px;        }        p {            margin: 5px 0;        }    </style></head>" +
               "<body><small><b>bar</b></small><PRE>public interface <b>MyExtensionPoint</b></PRE>\n" +
               "   MyExtensionPoint JavaDoc.</body></html>",
               provider.generateDoc(docElement, null));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ExtensionPointDocumentationProviderTest.java

示例2: update

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  PsiElement element = getElement(dataContext, editor);
  final PsiElement originalElement = getOriginalElement(CommonDataKeys.PSI_FILE.getData(dataContext), editor);
  DocumentationManager.storeOriginalElement(CommonDataKeys.PROJECT.getData(dataContext), originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
  boolean enabled;
  if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider edProvider = (ExternalDocumentationProvider)provider;
    enabled = edProvider.hasDocumentationFor(element, originalElement) || edProvider.canPromptToConfigureDocumentation(element);
  }
  else {
    final List<String> urls = provider.getUrlFor(element, originalElement);
    enabled = urls != null && !urls.isEmpty();
  }
  if (editor != null) {
    presentation.setEnabled(enabled);
    if (ActionPlaces.isMainMenuOrActionSearch(event.getPlace())) {
      presentation.setVisible(true);
    }
    else {
      presentation.setVisible(enabled);
    }
  }
  else{
    presentation.setEnabled(enabled);
    presentation.setVisible(true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ExternalJavaDocAction.java

示例3: DocumentationTestContext

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
DocumentationTestContext(String... fileNames) {
  copyAdditionalFiles(fileNames);
  psiFile = myFixture.configureByFile(fileNames[0]);
  originalElement = psiFile.findElementAt(myFixture.getEditor().getCaretModel().getOffset());
  element = DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(), psiFile, originalElement);

  if (element == null) {
    element = originalElement;
  }

  documentationProvider = DocumentationManager.getProviderFromElement(element);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:XmlDocumentationTest.java

示例4: doTest

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:HtmlDocumentationTest.java

示例5: doTestExternalDoc

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
protected void doTestExternalDoc(String expectedPart) {
  final PsiElement originalElement = myFixture.getFile().findElementAt(
    myFixture.getEditor().getCaretModel().getOffset());
  final PsiElement docTargetElement = DocumentationManager.getInstance(getProject()).
    findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(docTargetElement);
  final List<String> urls = provider.getUrlFor(docTargetElement, originalElement);
  final String doc = ((ExternalDocumentationProvider)provider).fetchExternalDocumentation(myFixture.getProject(), docTargetElement, urls);
  assertNotNull(doc);
  assertTrue("Can't find " + expectedPart + " in " + doc, doc.contains(expectedPart));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:AndroidDomTest.java

示例6: assertDocumentation

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
protected void assertDocumentation(String expectedText) throws IOException {
  PsiElement originalElement = getElementAtCaret(myProjectPom);
  PsiElement targetElement = DocumentationManager.getInstance(myProject)
    .findTargetElement(getEditor(), getTestPsiFile(), originalElement);

  DocumentationProvider provider = DocumentationManager.getProviderFromElement(targetElement);
  assertEquals(expectedText, provider.generateDoc(targetElement, originalElement));

  // should work for lookup as well as for tags
  PsiElement lookupElement = provider.getDocumentationElementForLookupItem(PsiManager.getInstance(myProject),
                                                                           originalElement.getText(),
                                                                           originalElement);
  assertSame(targetElement, lookupElement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:MavenDomTestCase.java

示例7: update

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
  final PsiElement originalElement = getOriginalElement(LangDataKeys.PSI_FILE.getData(dataContext), editor);
  DocumentationManager.storeOriginalElement(PlatformDataKeys.PROJECT.getData(dataContext), originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
  boolean enabled;
  if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider edProvider = (ExternalDocumentationProvider)provider;
    enabled = edProvider.hasDocumentationFor(element, originalElement) || edProvider.canPromptToConfigureDocumentation(element);
  }
  else {
    final List<String> urls = provider.getUrlFor(element, originalElement);
    enabled = urls != null && !urls.isEmpty();
  }
  if (editor != null) {
    presentation.setEnabled(enabled);
    if (event.getPlace().equals(ActionPlaces.MAIN_MENU)) {
      presentation.setVisible(true);
    }
    else {
      presentation.setVisible(enabled);
    }
  }
  else{
    presentation.setEnabled(enabled);
    presentation.setVisible(true);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:ExternalJavaDocAction.java

示例8: DocumentationTestContext

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
DocumentationTestContext(String... fileNames) throws Exception {
  configureByFiles(null,fileNames);
  psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
  originalElement = psiFile.findElementAt(myEditor.getCaretModel().getOffset());
  element = DocumentationManager.getInstance(myProject).findTargetElement(myEditor, myFile, originalElement);

  if (element == null) {
    element = originalElement;
  }

  documentationProvider = DocumentationManager.getProviderFromElement(element);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:XmlDocumentationTest.java

示例9: doTest

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
private void doTest(String text) throws Exception {
  configureByText(StdFileTypes.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));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:HtmlDocumentationTest.java

示例10: update

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
  PsiElement element = getElement(dataContext, editor);
  final PsiElement originalElement = getOriginalElement(dataContext.getData(CommonDataKeys.PSI_FILE), editor);
  DocumentationManager.storeOriginalElement(dataContext.getData(CommonDataKeys.PROJECT), originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
  boolean enabled;
  if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider edProvider = (ExternalDocumentationProvider)provider;
    enabled = edProvider.hasDocumentationFor(element, originalElement) || edProvider.canPromptToConfigureDocumentation(element);
  }
  else {
    final List<String> urls = provider.getUrlFor(element, originalElement);
    enabled = urls != null && !urls.isEmpty();
  }
  if (editor != null) {
    presentation.setEnabled(enabled);
    if (ActionPlaces.isMainMenuOrActionSearch(event.getPlace())) {
      presentation.setVisible(true);
    }
    else {
      presentation.setVisible(enabled);
    }
  }
  else{
    presentation.setEnabled(enabled);
    presentation.setVisible(true);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:33,代码来源:ExternalJavaDocAction.java

示例11: generateInfo

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@NotNull
private static DocInfo generateInfo(PsiElement element, PsiElement atPointer) {
  final DocumentationProvider documentationProvider = DocumentationManager.getProviderFromElement(element, atPointer);
  String result = doGenerateInfo(element, atPointer, documentationProvider);
  return result == null ? DocInfo.EMPTY : new DocInfo(result, documentationProvider, element);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:CtrlMouseHandler.java

示例12: actionPerformed

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;
  }

  Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  PsiElement element = getElement(dataContext, editor);
  if (element == null) {
    Messages.showMessageDialog(
      project,
      IdeBundle.message("message.please.select.element.for.javadoc"),
      IdeBundle.message("title.no.element.selected"),
      Messages.getErrorIcon()
    );
    return;
  }


  PsiFile context = CommonDataKeys.PSI_FILE.getData(dataContext);

  PsiElement originalElement = getOriginalElement(context, editor);
  DocumentationManager.storeOriginalElement(project, originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);

  if (provider instanceof ExternalDocumentationHandler && ((ExternalDocumentationHandler)provider).handleExternal(element, originalElement)) {
    return;
  }

  final List<String> urls = provider.getUrlFor(element, originalElement);
  if (urls != null && !urls.isEmpty()) {
    showExternalJavadoc(urls, PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext));
  }
  else if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider externalDocumentationProvider = (ExternalDocumentationProvider)provider;
    if (externalDocumentationProvider.canPromptToConfigureDocumentation(element)) {
      externalDocumentationProvider.promptToConfigureDocumentation(element);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:ExternalJavaDocAction.java

示例13: testDimenUnitsCompletion1

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
public void testDimenUnitsCompletion1() throws Exception {
  final VirtualFile file = copyFileToProject(getTestName(true) + ".xml");
  myFixture.configureFromExistingVirtualFile(file);
  myFixture.complete(CompletionType.BASIC);

  final List<String> lookupElementStrings = myFixture.getLookupElementStrings();
  assertNotNull(lookupElementStrings);
  UsefulTestCase.assertSameElements(lookupElementStrings, "3dp", "3px", "3sp", "3pt", "3mm", "3in");

  final PsiElement originalElement = myFixture.getFile().findElementAt(
    myFixture.getEditor().getCaretModel().getOffset());
  assertNotNull(originalElement);


  final 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;
    }
  }
  assertNotNull(dpElement);
  assertNotNull(pxElement);
  DocumentationProvider provider;
  PsiElement docTargetElement;

  lookup.setCurrentItem(dpElement);
  docTargetElement = DocumentationManager.getInstance(getProject()).
    findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
  assertNotNull(docTargetElement);
  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);
  assertNotNull(docTargetElement);
  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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:AndroidLayoutDomTest.java

示例14: actionPerformed

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;
  }

  PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
  if (element == null) {
    Messages.showMessageDialog(
      project,
      IdeBundle.message("message.please.select.element.for.javadoc"),
      IdeBundle.message("title.no.element.selected"),
      Messages.getErrorIcon()
    );
    return;
  }


  PsiFile context = LangDataKeys.PSI_FILE.getData(dataContext);
  Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  PsiElement originalElement = getOriginalElement(context, editor);
  DocumentationManager.storeOriginalElement(project, originalElement, element);
  final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);

  if (provider instanceof ExternalDocumentationHandler && ((ExternalDocumentationHandler)provider).handleExternal(element, originalElement)) {
    return;
  }

  final List<String> urls = provider.getUrlFor(element, originalElement);
  if (urls != null && !urls.isEmpty()) {
    showExternalJavadoc(urls);
  }
  else if (provider instanceof ExternalDocumentationProvider) {
    final ExternalDocumentationProvider externalDocumentationProvider = (ExternalDocumentationProvider)provider;
    if (externalDocumentationProvider.canPromptToConfigureDocumentation(element)) {
      externalDocumentationProvider.promptToConfigureDocumentation(element);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:42,代码来源:ExternalJavaDocAction.java

示例15: generateInfo

import com.intellij.codeInsight.documentation.DocumentationManager; //导入方法依赖的package包/类
@Nonnull
private static DocInfo generateInfo(PsiElement element, PsiElement atPointer) {
  final DocumentationProvider documentationProvider = DocumentationManager.getProviderFromElement(element, atPointer);
  String result = doGenerateInfo(element, atPointer, documentationProvider);
  return result == null ? DocInfo.EMPTY : new DocInfo(result, documentationProvider, element);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:CtrlMouseHandler.java


注:本文中的com.intellij.codeInsight.documentation.DocumentationManager.getProviderFromElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。