Search in sources :

Example 11 with TopLevelNode

use of org.ballerinalang.model.tree.TopLevelNode in project ballerina by ballerina-lang.

the class CommandUtil method getEnumDocumentationByPosition.

/**
 * Get the Documentation attachment for the enum.
 * @param bLangPackage      BLangPackage built
 * @param line              Start line of the enum in the source
 * @return {@link String}   Documentation attachment for the enum
 */
static DocAttachmentInfo getEnumDocumentationByPosition(BLangPackage bLangPackage, int line) {
    for (TopLevelNode topLevelNode : bLangPackage.topLevelNodes) {
        if (topLevelNode instanceof BLangEnum) {
            BLangEnum enumNode = (BLangEnum) topLevelNode;
            DiagnosticPos enumPos = CommonUtil.toZeroBasedPosition(enumNode.getPosition());
            int enumStart = enumPos.getStartLine();
            if (enumStart == line) {
                return getEnumNodeDocumentation(enumNode, line);
            }
        }
    }
    return null;
}
Also used : DiagnosticPos(org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos) BLangEnum(org.wso2.ballerinalang.compiler.tree.BLangEnum) TopLevelNode(org.ballerinalang.model.tree.TopLevelNode)

Aggregations

TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)11 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)7 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)5 Swagger (io.swagger.models.Swagger)2 ArrayList (java.util.ArrayList)2 BFile (org.ballerinalang.composer.service.ballerina.parser.service.model.BFile)2 ServiceNode (org.ballerinalang.model.tree.ServiceNode)2 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)2 BLangCompilationUnit (org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit)2 BLangEnum (org.wso2.ballerinalang.compiler.tree.BLangEnum)2 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)2 BLangImportPackage (org.wso2.ballerinalang.compiler.tree.BLangImportPackage)2 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)2 BLangObject (org.wso2.ballerinalang.compiler.tree.BLangObject)2 BLangResource (org.wso2.ballerinalang.compiler.tree.BLangResource)2 BLangTransformer (org.wso2.ballerinalang.compiler.tree.BLangTransformer)2 SwaggerConverter (io.swagger.v3.parser.converter.SwaggerConverter)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1