Java 类com.intellij.lang.documentation.DocumentationProvider 实例源码

项目:intellij-ce-playground    文件:DocumentationComponent.java   
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setEnabled(false);
  if (myElement != null) {
    final PsiElement element = myElement.getElement();
    final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
    final PsiElement originalElement = DocumentationManager.getOriginalElement(element);
    if (provider instanceof ExternalDocumentationProvider) {
      presentation.setEnabled(element != null && ((ExternalDocumentationProvider)provider).hasDocumentationFor(element, originalElement));
    }
    else {
      final List<String> urls = provider.getUrlFor(element, originalElement);
      presentation.setEnabled(element != null && urls != null && !urls.isEmpty());
    }
  }
}
项目:intellij-ce-playground    文件:HtmlDocumentationProvider.java   
@Override
public String generateDoc(PsiElement element, PsiElement originalElement) {
  final XmlTag tag = PsiTreeUtil.getParentOfType(originalElement, XmlTag.class, false);
  String result = generateDocForHtml(element, false, tag, originalElement);

  DocumentationProvider styleProvider = getStyleProvider();
  if (result == null && styleProvider !=null) {
    result = styleProvider.generateDoc(element, originalElement);
  }

  if (result == null && ourScriptProvider !=null) {
    result = ourScriptProvider.generateDoc(element, originalElement);
  }

  if (result == null && element instanceof XmlAttributeValue) {
    result = generateDocForHtml(element.getParent(), false, tag, originalElement);
  }

  return result;
}
项目:intellij-ce-playground    文件:HtmlDocumentationProvider.java   
@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;
}
项目:intellij-ce-playground    文件:ExtensionPointDocumentationProviderTest.java   
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));
}
项目:tools-idea    文件:DocumentationComponent.java   
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setEnabled(false);
  if (myElement != null) {
    final PsiElement element = myElement.getElement();
    final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
    final PsiElement originalElement = DocumentationManager.getOriginalElement(element);
    if (provider instanceof ExternalDocumentationProvider) {
      presentation.setEnabled(element != null && ((ExternalDocumentationProvider)provider).hasDocumentationFor(element, originalElement));
    }
    else {
      final List<String> urls = provider.getUrlFor(element, originalElement);
      presentation.setEnabled(element != null && urls != null && !urls.isEmpty());
    }
  }
}
项目:consulo    文件:DocumentationComponent.java   
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setEnabled(false);
  if (myElement != null) {
    final PsiElement element = myElement.getElement();
    final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
    final PsiElement originalElement = DocumentationManager.getOriginalElement(element);
    if (provider instanceof ExternalDocumentationProvider) {
      presentation.setEnabled(element != null && ((ExternalDocumentationProvider)provider).hasDocumentationFor(element, originalElement));
    }
    else {
      final List<String> urls = provider.getUrlFor(element, originalElement);
      presentation.setEnabled(element != null && urls != null && !urls.isEmpty());
    }
  }
}
项目:consulo-javascript    文件:JSDocumentationProvider.java   
@Override
public List<String> getUrlFor(PsiElement element, PsiElement originalElement)
{
    String possibleCssName = findPossibleCssName(element);

    if(possibleCssName != null)
    {
        try
        {
            final DocumentationProvider documentationProvider = getCssProvider(element.getProject());
            final Method method = documentationProvider.getClass().getMethod("getUrlFor", new Class[]{String.class});
            final Object o = method.invoke(null, new Object[]{possibleCssName});

            if(o instanceof String)
            {
                return Collections.singletonList((String) o);
            }
        }
        catch(Exception e)
        {
        }
    }
    return null;
}
项目:intellij-ce-playground    文件:LanguageDocumentation.java   
@Override
public DocumentationProvider forLanguage(@NotNull final Language l) {
  final List<DocumentationProvider> providers = allForLanguage(l);
  if (providers.size() < 2) {
    return super.forLanguage(l);
  }
  return CompositeDocumentationProvider.wrapProviders(providers);
}
项目:intellij-ce-playground    文件:CtrlMouseHandler.java   
@Nullable
private static String doGenerateInfo(@NotNull PsiElement element,
                                     @NotNull PsiElement atPointer,
                                     @NotNull DocumentationProvider documentationProvider)
{
  String info = documentationProvider.getQuickNavigateInfo(element, atPointer);
  if (info != null) {
    return info;
  }

  if (element instanceof PsiFile) {
    final VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
    if (virtualFile != null) {
      return virtualFile.getPresentableUrl();
    }
  }

  info = getQuickNavigateInfo(element);
  if (info != null) {
    return info;
  }

  if (element instanceof NavigationItem) {
    final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
    if (presentation != null) {
      return presentation.getPresentableText();
    }
  }

  return null;
}
项目:intellij-ce-playground    文件:EnterHandler.java   
@Nullable
private PsiComment createJavaDocStub(final CodeInsightSettings settings,
                                        final PsiComment comment,
                                        final Project project) {
  if (settings.JAVADOC_STUB_ON_ENTER) {
    final DocumentationProvider langDocumentationProvider =
      LanguageDocumentation.INSTANCE.forLanguage(comment.getParent().getLanguage());

    @Nullable final CodeDocumentationProvider docProvider;
    if (langDocumentationProvider instanceof CompositeDocumentationProvider) {
      docProvider = ((CompositeDocumentationProvider)langDocumentationProvider).getFirstCodeDocumentationProvider();
    } else {
      docProvider = langDocumentationProvider instanceof CodeDocumentationProvider ?
                                                      (CodeDocumentationProvider)langDocumentationProvider : null;
    }

    if (docProvider != null) {
      if (docProvider.findExistingDocComment(comment) != comment) return comment;
      String docStub;

      DumbService.getInstance(project).setAlternativeResolveEnabled(true);
      try {
        docStub = docProvider.generateDocumentationContentStub(comment);
      }
      finally {
        DumbService.getInstance(project).setAlternativeResolveEnabled(false);
      }

      if (docStub != null && docStub.length() != 0) {
        myOffset = CharArrayUtil.shiftForwardUntil(myDocument.getCharsSequence(), myOffset, LINE_SEPARATOR);
        myOffset = CharArrayUtil.shiftForward(myDocument.getCharsSequence(), myOffset, LINE_SEPARATOR);
        myDocument.insertString(myOffset, docStub);
      }
    }

    PsiDocumentManager.getInstance(project).commitAllDocuments();
    return PsiTreeUtil.getNonStrictParentOfType(myFile.findElementAt(myOffset), PsiComment.class);
  }
  return comment;
}
项目:intellij-ce-playground    文件:ExternalJavaDocAction.java   
@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);
  }
}
项目:intellij-ce-playground    文件:HtmlDocumentationTest.java   
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));
}
项目:intellij-ce-playground    文件:HtmlDocumentationProvider.java   
@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;
}
项目:intellij-ce-playground    文件:HtmlDocumentationProvider.java   
@Override
public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) {
  PsiElement result = createNavigationElementHTML(psiManager, link, context);

  DocumentationProvider styleProvider = getStyleProvider();
  if (result== null && styleProvider !=null) {
    result = styleProvider.getDocumentationElementForLink(psiManager, link, context);
  }
  if (result== null && ourScriptProvider != null && !DumbService.isDumb(psiManager.getProject())) {
    result = ourScriptProvider.getDocumentationElementForLink(psiManager, link,context);
  }
  return result;
}
项目:intellij-ce-playground    文件:HtmlDocumentationProvider.java   
@Nullable
private DocumentationProvider getStyleProvider() {
  if (myStyleProvider == null) {
    Language cssLanguage = Language.findLanguageByID("CSS");
    if (cssLanguage != null) {
      myStyleProvider = LanguageDocumentation.INSTANCE.forLanguage(cssLanguage);
    }
  }
  return myStyleProvider;
}
项目:intellij-ce-playground    文件:AndroidDomTest.java   
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));
}
项目:intellij-ce-playground    文件:MavenDomTestCase.java   
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);
}
项目:tools-idea    文件:LanguageDocumentation.java   
@Override
public DocumentationProvider forLanguage(@NotNull final Language l) {
  final List<DocumentationProvider> providers = allForLanguage(l);
  if (providers.size() < 2) {
    return super.forLanguage(l);
  }
  return CompositeDocumentationProvider.wrapProviders(providers);
}
项目:tools-idea    文件:CtrlMouseHandler.java   
@Nullable
private static String doGenerateInfo(@NotNull PsiElement element,
                                     @NotNull PsiElement atPointer,
                                     @NotNull DocumentationProvider documentationProvider)
{
  String info = documentationProvider.getQuickNavigateInfo(element, atPointer);
  if (info != null) {
    return info;
  }

  if (element instanceof PsiFile) {
    final VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
    if (virtualFile != null) {
      return virtualFile.getPresentableUrl();
    }
  }

  info = getQuickNavigateInfo(element);
  if (info != null) {
    return info;
  }

  if (element instanceof NavigationItem) {
    final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
    if (presentation != null) {
      return presentation.getPresentableText();
    }
  }

  return null;
}
项目:tools-idea    文件:EnterHandler.java   
@Nullable
private PsiComment createJavaDocStub(final CodeInsightSettings settings,
                                        final PsiComment comment,
                                        final Project project) {
  if (settings.JAVADOC_STUB_ON_ENTER) {
    final DocumentationProvider langDocumentationProvider =
      LanguageDocumentation.INSTANCE.forLanguage(comment.getParent().getLanguage());

    @Nullable final CodeDocumentationProvider docProvider;
    if (langDocumentationProvider instanceof CompositeDocumentationProvider) {
      docProvider = ((CompositeDocumentationProvider)langDocumentationProvider).getFirstCodeDocumentationProvider();
    } else {
      docProvider = langDocumentationProvider instanceof CodeDocumentationProvider ?
                                                      (CodeDocumentationProvider)langDocumentationProvider : null;
    }

    if (docProvider != null) {
      if (docProvider.findExistingDocComment(comment) != comment) return comment;
      String docStub = docProvider.generateDocumentationContentStub(comment);

      if (docStub != null && docStub.length() != 0) {
        myOffset = CharArrayUtil.shiftForwardUntil(myDocument.getCharsSequence(), myOffset, LINE_SEPARATOR);
        myOffset = CharArrayUtil.shiftForward(myDocument.getCharsSequence(), myOffset, LINE_SEPARATOR);
        myDocument.insertString(myOffset, docStub);
      }
    }

    PsiDocumentManager.getInstance(project).commitAllDocuments();
    return PsiTreeUtil.getNonStrictParentOfType(myFile.findElementAt(myOffset), PsiComment.class);
  }
  return comment;
}
项目:tools-idea    文件:ExternalJavaDocAction.java   
@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);
  }
}
项目:tools-idea    文件:HtmlDocumentationTest.java   
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));
}
项目:tools-idea    文件:MavenDomTestCase.java   
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);
}
项目:consulo    文件:LanguageDocumentation.java   
@Override
public DocumentationProvider forLanguage(@Nonnull final Language l) {
  final List<DocumentationProvider> providers = allForLanguage(l);
  if (providers.size() < 2) {
    return super.forLanguage(l);
  }
  return CompositeDocumentationProvider.wrapProviders(providers);
}
项目:consulo    文件:CtrlMouseHandler.java   
@Nullable
private static String doGenerateInfo(@Nonnull PsiElement element, @Nonnull PsiElement atPointer, @Nonnull DocumentationProvider documentationProvider) {
  String info = documentationProvider.getQuickNavigateInfo(element, atPointer);
  if (info != null) {
    return info;
  }

  if (element instanceof PsiFile) {
    final VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
    if (virtualFile != null) {
      return virtualFile.getPresentableUrl();
    }
  }

  info = getQuickNavigateInfo(element);
  if (info != null) {
    return info;
  }

  if (element instanceof NavigationItem) {
    final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
    if (presentation != null) {
      return presentation.getPresentableText();
    }
  }

  return null;
}
项目:consulo    文件:EnterHandler.java   
@Nullable
private PsiComment createJavaDocStub(final CodeInsightSettings settings,
                                     final PsiComment comment,
                                     final Project project) {
  if (settings.JAVADOC_STUB_ON_ENTER) {
    final DocumentationProvider langDocumentationProvider =
            LanguageDocumentation.INSTANCE.forLanguage(comment.getParent().getLanguage());

    @Nullable final CodeDocumentationProvider docProvider;
    if (langDocumentationProvider instanceof CompositeDocumentationProvider) {
      docProvider = ((CompositeDocumentationProvider)langDocumentationProvider).getFirstCodeDocumentationProvider();
    } else {
      docProvider = langDocumentationProvider instanceof CodeDocumentationProvider ?
                    (CodeDocumentationProvider)langDocumentationProvider : null;
    }

    if (docProvider != null) {
      if (docProvider.findExistingDocComment(comment) != comment) return comment;
      String docStub;

      DumbService.getInstance(project).setAlternativeResolveEnabled(true);
      try {
        docStub = docProvider.generateDocumentationContentStub(comment);
      }
      finally {
        DumbService.getInstance(project).setAlternativeResolveEnabled(false);
      }

      if (docStub != null && docStub.length() != 0) {
        myOffset = CharArrayUtil.shiftForwardUntil(myDocument.getCharsSequence(), myOffset, LINE_SEPARATOR);
        myOffset = CharArrayUtil.shiftForward(myDocument.getCharsSequence(), myOffset, LINE_SEPARATOR);
        myDocument.insertString(myOffset, docStub);
      }
    }

    PsiDocumentManager.getInstance(project).commitAllDocuments();
    return PsiTreeUtil.getNonStrictParentOfType(myFile.findElementAt(myOffset), PsiComment.class);
  }
  return comment;
}
项目:consulo    文件:ExternalJavaDocAction.java   
@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);
  }
}
项目:intellij-ce-playground    文件:CtrlMouseHandler.java   
@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);
}
项目:intellij-ce-playground    文件:CtrlMouseHandler.java   
DocInfo(@Nullable String text, @Nullable DocumentationProvider provider, @Nullable PsiElement documentationAnchor) {
  this.text = text;
  docProvider = provider;
  this.documentationAnchor = documentationAnchor;
}
项目:intellij-ce-playground    文件:CtrlMouseHandler.java   
QuickDocHyperlinkListener(@NotNull DocumentationProvider provider, @NotNull PsiElement context) {
  myProvider = provider;
  myContext = context;
}
项目:intellij-ce-playground    文件:ExternalJavaDocAction.java   
@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);
    }
  }
}
项目:intellij-ce-playground    文件:HtmlDocumentationProvider.java   
public static void registerScriptDocumentationProvider(final DocumentationProvider provider) {
  ourScriptProvider = provider;
}
项目:intellij-ce-playground    文件:AndroidLayoutDomTest.java   
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));
}
项目:tools-idea    文件:CtrlMouseHandler.java   
@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);
}
项目:tools-idea    文件:CtrlMouseHandler.java   
DocInfo(@Nullable String text, @Nullable DocumentationProvider provider, @Nullable PsiElement documentationAnchor) {
  this.text = text;
  docProvider = provider;
  this.documentationAnchor = documentationAnchor;
}
项目:tools-idea    文件:CtrlMouseHandler.java   
QuickDocHyperlinkListener(@NotNull DocumentationProvider provider, @NotNull PsiElement context) {
  myProvider = provider;
  myContext = context;
}
项目:tools-idea    文件:ExternalJavaDocAction.java   
@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);
    }
  }
}
项目:tools-idea    文件:HtmlDocumentationProvider.java   
public static void registerStyleDocumentationProvider(DocumentationProvider documentationProvider) {
  ourStyleProvider = documentationProvider;
}
项目:tools-idea    文件:HtmlDocumentationProvider.java   
public static void registerScriptDocumentationProvider(final DocumentationProvider provider) {
  ourScriptProvider = provider;
}
项目:consulo    文件:CtrlMouseHandler.java   
@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);
}