use of org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute in project ballerina by ballerina-lang.
the class TypeChecker method visit.
public void visit(BLangXMLAttribute bLangXMLAttribute) {
SymbolEnv xmlAttributeEnv = SymbolEnv.getXMLAttributeEnv(bLangXMLAttribute, env);
// check attribute name
checkExpr(bLangXMLAttribute.name, xmlAttributeEnv, Lists.of(symTable.stringType));
// check attribute value
checkExpr(bLangXMLAttribute.value, xmlAttributeEnv, Lists.of(symTable.stringType));
symbolEnter.defineNode(bLangXMLAttribute, env);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute in project ballerina by ballerina-lang.
the class TypeChecker method visit.
public void visit(BLangXMLQName bLangXMLQName) {
String prefix = bLangXMLQName.prefix.value;
resultTypes = Lists.of(types.checkType(bLangXMLQName, symTable.stringType, expTypes.get(0)));
if (env.node.getKind() == NodeKind.XML_ATTRIBUTE && prefix.isEmpty() && bLangXMLQName.localname.value.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
((BLangXMLAttribute) env.node).isNamespaceDeclr = true;
return;
}
if (env.node.getKind() == NodeKind.XML_ATTRIBUTE && prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
((BLangXMLAttribute) env.node).isNamespaceDeclr = true;
return;
}
if (prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
dlog.error(bLangXMLQName.pos, DiagnosticCode.INVALID_NAMESPACE_PREFIX, prefix);
bLangXMLQName.type = symTable.errType;
return;
}
BSymbol xmlnsSymbol = symResolver.lookupSymbol(env, names.fromIdNode(bLangXMLQName.prefix), SymTag.XMLNS);
if (prefix.isEmpty() && xmlnsSymbol == symTable.notFoundSymbol) {
return;
}
if (!prefix.isEmpty() && xmlnsSymbol == symTable.notFoundSymbol) {
dlog.error(bLangXMLQName.pos, DiagnosticCode.UNDEFINED_SYMBOL, prefix);
bLangXMLQName.type = symTable.errType;
return;
}
bLangXMLQName.namespaceURI = ((BXMLNSSymbol) xmlnsSymbol).namespaceURI;
bLangXMLQName.nsSymbol = (BXMLNSSymbol) xmlnsSymbol;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createXMLAttribute.
public void createXMLAttribute(DiagnosticPos pos, Set<Whitespace> ws) {
BLangXMLAttribute xmlAttribute = (BLangXMLAttribute) TreeBuilder.createXMLAttributeNode();
xmlAttribute.value = (BLangXMLQuotedString) exprNodeStack.pop();
xmlAttribute.name = (BLangExpression) exprNodeStack.pop();
xmlAttribute.pos = pos;
xmlAttribute.addWS(ws);
xmlAttributeNodeStack.push(xmlAttribute);
}
Aggregations