Search in sources :

Example 41 with PsiDocTag

use of com.intellij.psi.javadoc.PsiDocTag in project intellij-community by JetBrains.

the class MethodJavaDocHelper method getTagForParameter.

public PsiDocTag getTagForParameter(PsiParameter parameter) {
    if (!myDoCorrectJavaDoc)
        return null;
    if (parameter == null)
        return null;
    final String name = parameter.getName();
    final PsiDocTag[] paramTags = myDocComment.findTagsByName("param");
    for (final PsiDocTag paramTag : paramTags) {
        final PsiElement[] dataElements = paramTag.getDataElements();
        if (dataElements.length > 0 && dataElements[0].getText().equals(name)) {
            return paramTag;
        }
    }
    return null;
}
Also used : PsiDocTag(com.intellij.psi.javadoc.PsiDocTag) PsiElement(com.intellij.psi.PsiElement)

Example 42 with PsiDocTag

use of com.intellij.psi.javadoc.PsiDocTag in project intellij-community by JetBrains.

the class ClsDocCommentImpl method appendMirrorText.

@Override
public void appendMirrorText(final int indentLevel, @NotNull final StringBuilder buffer) {
    buffer.append("/**");
    for (PsiDocTag tag : getTags()) {
        goNextLine(indentLevel + 1, buffer);
        buffer.append("* ");
        buffer.append(tag.getText());
    }
    goNextLine(indentLevel + 1, buffer);
    buffer.append("*/");
}
Also used : PsiDocTag(com.intellij.psi.javadoc.PsiDocTag)

Example 43 with PsiDocTag

use of com.intellij.psi.javadoc.PsiDocTag in project markdown-doclet by Abnaxos.

the class DocCommentProcessor method generateUmlDiagrams.

/**
 * Generates all PlantUML diagrams in the given `PsiDocComment`. It returns a Map of
 * file names and the URLs where the image for that file has been saved to. Use this
 * URL for the `<img>` tag.
 *
 * @param docComment    The `PsiDocComment`.
 *
 * @return A map mapping the file names to the image URLs.
 *
 * @see TempFileManager#saveTempFile(byte[], String)
 */
private Map<String, URL> generateUmlDiagrams(PsiDocComment docComment) {
    TempFileManager tempFiles = Plugin.tempFileManager();
    Map<String, URL> urls = null;
    for (PsiDocTag tag : docComment.getTags()) {
        if (tag instanceof PsiInlineDocTag) {
            continue;
        } else if (tag.getName().equals("uml") || tag.getName().equals("startuml")) {
            if (urls == null) {
                urls = new HashMap<>();
            }
            String text = stripLead(tag.getText());
            text = stripFirstWord(text)[1];
            String[] stripped = stripFirstWord(text);
            String fileName = stripped[0];
            text = stripped[1];
            String plantUml = "@startuml " + fileName + "\n" + "skinparam backgroundColor transparent\n" + text + "\n@enduml";
            Plugin.print("UML Diagram Source", plantUml);
            ByteArrayOutputStream image = new ByteArrayOutputStream();
            try {
                new SourceStringReader(plantUml).generateImage(image);
            } catch (IOException e) {
                LOG.error("Error generating UML", e, fileName, String.valueOf(docComment.toString()), String.valueOf(docComment.getContainingFile()));
            }
            try {
                urls.put(fileName, tempFiles.saveTempFile(image.toByteArray(), "png"));
            } catch (IOException e) {
                LOG.error("Error generating UML", e, fileName, String.valueOf(docComment.toString()), String.valueOf(docComment.getContainingFile()));
            }
        }
    }
    return MoreObjects.firstNonNull(urls, Collections.<String, URL>emptyMap());
}
Also used : PsiDocTag(com.intellij.psi.javadoc.PsiDocTag) PsiInlineDocTag(com.intellij.psi.javadoc.PsiInlineDocTag) HashMap(java.util.HashMap) SourceStringReader(net.sourceforge.plantuml.SourceStringReader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) URL(java.net.URL)

Aggregations

PsiDocTag (com.intellij.psi.javadoc.PsiDocTag)43 PsiDocComment (com.intellij.psi.javadoc.PsiDocComment)15 PsiDocTagValue (com.intellij.psi.javadoc.PsiDocTagValue)7 ASTNode (com.intellij.lang.ASTNode)5 PsiInlineDocTag (com.intellij.psi.javadoc.PsiInlineDocTag)5 ArrayList (java.util.ArrayList)5 PsiDocToken (com.intellij.psi.javadoc.PsiDocToken)4 MethodJavaDocHelper (com.intellij.refactoring.util.javadoc.MethodJavaDocHelper)4 NotNull (org.jetbrains.annotations.NotNull)4 PsiDocParamRef (com.intellij.psi.impl.source.javadoc.PsiDocParamRef)3 IncorrectOperationException (com.intellij.util.IncorrectOperationException)3 TextRange (com.intellij.openapi.util.TextRange)2 PsiElement (com.intellij.psi.PsiElement)2 IElementType (com.intellij.psi.tree.IElementType)2 HashMap (com.intellij.util.containers.HashMap)2 TIntProcedure (gnu.trove.TIntProcedure)2 URL (java.net.URL)2 DocletSerializer (ch.raffael.mddoclet.DocletSerializer)1 MarkdownDoclet (ch.raffael.mddoclet.MarkdownDoclet)1 Options (ch.raffael.mddoclet.Options)1