Search in sources :

Example 6 with BLangXMLAttribute

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);
}
Also used : SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 7 with BLangXMLAttribute

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;
}
Also used : BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) BLangXMLQuotedString(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)

Example 8 with BLangXMLAttribute

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);
}
Also used : BLangXMLAttribute(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute)

Aggregations

SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)4 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)3 BLangXMLAttribute (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute)3 BLangXMLQName (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQName)2 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)1 BXMLAttributeSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLAttributeSymbol)1 BXMLNSSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLNSSymbol)1 BLangLocalXMLNS (org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangLocalXMLNS)1 BLangLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)1 BLangXMLQuotedString (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)1 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)1