Search in sources :

Example 6 with AnnotationAttributeValueNode

use of org.ballerinalang.plugins.idea.psi.AnnotationAttributeValueNode in project ballerina by ballerina-lang.

the class BallerinaDocumentationProvider method getParamDescriptions.

/**
 * Returns the parameters from the {@code Param}  doc annotations.
 *
 * @param annotations list of all annotations
 * @return list of parameter strings
 */
@NotNull
private static List<String> getParamDescriptions(List<PsiElement> annotations) {
    List<String> params = new LinkedList<>();
    for (PsiElement annotation : annotations) {
        AnnotationAttributeValueNode valueNode = getAnnotationAttributeNode(annotation, DOC_PARAM);
        if (valueNode == null) {
            continue;
        }
        String text = valueNode.getText();
        // We ignore the " in the beginning and end. We also replace the ":" with " -" to increase the
        // readability of the docs.
        params.add(text.substring(1, text.length() - 1).replaceFirst(DOC_SEPARATOR, " -"));
    }
    return params;
}
Also used : AnnotationAttributeValueNode(org.ballerinalang.plugins.idea.psi.AnnotationAttributeValueNode) LinkedList(java.util.LinkedList) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AnnotationAttributeValueNode (org.ballerinalang.plugins.idea.psi.AnnotationAttributeValueNode)6 PsiElement (com.intellij.psi.PsiElement)5 NotNull (org.jetbrains.annotations.NotNull)5 LinkedList (java.util.LinkedList)3 AnnotationAttachmentNode (org.ballerinalang.plugins.idea.psi.AnnotationAttachmentNode)2 ParameterListNode (org.ballerinalang.plugins.idea.psi.ParameterListNode)2 ParameterNode (org.ballerinalang.plugins.idea.psi.ParameterNode)2 ResourceDefinitionNode (org.ballerinalang.plugins.idea.psi.ResourceDefinitionNode)2 SimpleLiteralNode (org.ballerinalang.plugins.idea.psi.SimpleLiteralNode)2 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1 IElementType (com.intellij.psi.tree.IElementType)1 RuleIElementType (org.antlr.jetbrains.adaptor.lexer.RuleIElementType)1 TokenIElementType (org.antlr.jetbrains.adaptor.lexer.TokenIElementType)1 ANTLRPsiNode (org.antlr.jetbrains.adaptor.psi.ANTLRPsiNode)1 AliasNode (org.ballerinalang.plugins.idea.psi.AliasNode)1 AnnotationReferenceNode (org.ballerinalang.plugins.idea.psi.AnnotationReferenceNode)1 AnonStructTypeNameNode (org.ballerinalang.plugins.idea.psi.AnonStructTypeNameNode)1 AnyIdentifierNameNode (org.ballerinalang.plugins.idea.psi.AnyIdentifierNameNode)1 AssignmentStatementNode (org.ballerinalang.plugins.idea.psi.AssignmentStatementNode)1 AttachmentPointNode (org.ballerinalang.plugins.idea.psi.AttachmentPointNode)1