Search in sources :

Example 96 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addEndpointType.

public void addEndpointType(DiagnosticPos pos, Set<Whitespace> ws) {
    BLangNameReference nameReference = nameReferenceStack.pop();
    BLangUserDefinedType constraintType = (BLangUserDefinedType) TreeBuilder.createUserDefinedTypeNode();
    constraintType.pos = pos;
    constraintType.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
    constraintType.typeName = (BLangIdentifier) nameReference.name;
    constraintType.addWS(nameReference.ws);
    addType(constraintType);
}
Also used : BLangNameReference(org.wso2.ballerinalang.compiler.tree.BLangNameReference) BLangUserDefinedType(org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType)

Example 97 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.

the class BLangPackageBuilder method startDocumentationAttachment.

public void startDocumentationAttachment(DiagnosticPos currentPos) {
    BLangDocumentation docAttachmentNode = (BLangDocumentation) TreeBuilder.createDocumentationNode();
    docAttachmentNode.pos = currentPos;
    docAttachmentStack.push(docAttachmentNode);
}
Also used : BLangDocumentation(org.wso2.ballerinalang.compiler.tree.BLangDocumentation)

Example 98 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.

the class BLangPackageBuilder method generateObjectVarNode.

private VariableNode generateObjectVarNode(DiagnosticPos pos, Set<Whitespace> ws, boolean isField, String identifier, boolean exprAvailable) {
    BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
    var.pos = pos;
    IdentifierNode name = this.createIdentifier(identifier);
    var.setName(name);
    var.addWS(ws);
    var.isField = isField;
    if (!isField) {
        var.setTypeNode(this.typeNodeStack.pop());
    }
    if (exprAvailable) {
        var.setInitialExpression(this.exprNodeStack.pop());
    }
    return var;
}
Also used : IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 99 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.

the class BLangPackageBuilder method startEnumDef.

public void startEnumDef(DiagnosticPos pos) {
    BLangEnum bLangEnum = (BLangEnum) TreeBuilder.createEnumNode();
    bLangEnum.pos = pos;
    attachAnnotations(bLangEnum);
    attachDocumentations(bLangEnum);
    attachDeprecatedNode(bLangEnum);
    this.enumStack.add(bLangEnum);
}
Also used : BLangEnum(org.wso2.ballerinalang.compiler.tree.BLangEnum)

Example 100 with DiagnosticPos

use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addImportPackageDeclaration.

public void addImportPackageDeclaration(DiagnosticPos pos, Set<Whitespace> ws, String orgName, List<String> nameComps, String version, String alias) {
    List<BLangIdentifier> pkgNameComps = new ArrayList<>();
    nameComps.forEach(e -> pkgNameComps.add((BLangIdentifier) this.createIdentifier(e)));
    BLangIdentifier versionNode = (BLangIdentifier) this.createIdentifier(version);
    BLangIdentifier aliasNode = (alias != null && !alias.isEmpty()) ? (BLangIdentifier) this.createIdentifier(alias) : pkgNameComps.get(pkgNameComps.size() - 1);
    BLangImportPackage importDcl = (BLangImportPackage) TreeBuilder.createImportPackageNode();
    importDcl.pos = pos;
    importDcl.addWS(ws);
    importDcl.pkgNameComps = pkgNameComps;
    importDcl.version = versionNode;
    importDcl.orgName = (BLangIdentifier) this.createIdentifier(orgName);
    importDcl.alias = aliasNode;
    this.compUnit.addTopLevelNode(importDcl);
    if (this.imports.contains(importDcl)) {
        this.dlog.warning(pos, DiagnosticCode.REDECLARED_IMPORT_PACKAGE, importDcl.getQualifiedPackageName());
    } else {
        this.imports.add(importDcl);
    }
}
Also used : ArrayList(java.util.ArrayList) BLangImportPackage(org.wso2.ballerinalang.compiler.tree.BLangImportPackage) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier)

Aggregations

DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)56 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)33 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)22 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)17 ArrayList (java.util.ArrayList)15 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)14 Whitespace (org.ballerinalang.model.Whitespace)13 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)12 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)11 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)11 IdentifierNode (org.ballerinalang.model.tree.IdentifierNode)9 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)9 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)9 BLangNameReference (org.wso2.ballerinalang.compiler.tree.BLangNameReference)9 BLangBinaryExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangBinaryExpr)9 BLangExpressionStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)9 BLangIdentifier (org.wso2.ballerinalang.compiler.tree.BLangIdentifier)8 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)8 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)8 BLangXMLQuotedString (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)8