use of org.wso2.ballerinalang.compiler.tree.BLangIdentifier in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addXMLNSDeclaration.
public void addXMLNSDeclaration(DiagnosticPos pos, Set<Whitespace> ws, String namespaceUri, String prefix, boolean isTopLevel) {
BLangXMLNS xmlns = (BLangXMLNS) TreeBuilder.createXMLNSNode();
BLangIdentifier prefixIdentifer = (BLangIdentifier) TreeBuilder.createIdentifierNode();
prefixIdentifer.pos = pos;
prefixIdentifer.value = prefix;
addLiteralValue(pos, removeNthFromStart(ws, 1), TypeTags.STRING, namespaceUri);
xmlns.namespaceURI = (BLangLiteral) exprNodeStack.pop();
xmlns.prefix = prefixIdentifer;
xmlns.pos = pos;
xmlns.addWS(ws);
if (isTopLevel) {
this.compUnit.addTopLevelNode(xmlns);
return;
}
BLangXMLNSStatement xmlnsStmt = (BLangXMLNSStatement) TreeBuilder.createXMLNSDeclrStatementNode();
xmlnsStmt.xmlnsDecl = xmlns;
xmlnsStmt.pos = pos;
addStmtToCurrentBlock(xmlnsStmt);
}
use of org.wso2.ballerinalang.compiler.tree.BLangIdentifier in project ballerina by ballerina-lang.
the class BLangPackageBuilder method populateStructNode.
private BLangStruct populateStructNode(DiagnosticPos pos, Set<Whitespace> ws, IdentifierNode name, boolean isAnonymous) {
BLangStruct structNode = (BLangStruct) this.structStack.pop();
structNode.pos = pos;
structNode.addWS(ws);
structNode.name = (BLangIdentifier) name;
structNode.isAnonymous = isAnonymous;
this.varListStack.pop().forEach(variableNode -> {
((BLangVariable) variableNode).docTag = DocTag.FIELD;
structNode.addField(variableNode);
});
return structNode;
}
use of org.wso2.ballerinalang.compiler.tree.BLangIdentifier 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);
}
use of org.wso2.ballerinalang.compiler.tree.BLangIdentifier 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);
}
}
use of org.wso2.ballerinalang.compiler.tree.BLangIdentifier in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addConstraintType.
public void addConstraintType(DiagnosticPos pos, Set<Whitespace> ws, String typeName) {
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);
Set<Whitespace> refTypeWS = removeNthFromLast(ws, 2);
BLangBuiltInRefTypeNode refType = (BLangBuiltInRefTypeNode) TreeBuilder.createBuiltInReferenceTypeNode();
refType.typeKind = TreeUtils.stringToTypeKind(typeName);
refType.pos = pos;
refType.addWS(refTypeWS);
BLangConstrainedType constrainedType = (BLangConstrainedType) TreeBuilder.createConstrainedTypeNode();
constrainedType.type = refType;
constrainedType.constraint = constraintType;
constrainedType.pos = pos;
constrainedType.addWS(ws);
addType(constrainedType);
}
Aggregations