Search in sources :

Example 1 with BAnnotationAttributeSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttributeSymbol in project ballerina by ballerina-lang.

the class SymbolEnter method visit.

public void visit(BLangAnnotAttribute annotationAttribute) {
    BAnnotationAttributeSymbol annotationAttributeSymbol = Symbols.createAnnotationAttributeSymbol(names.fromIdNode(annotationAttribute.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
    annotationAttributeSymbol.docTag = DocTag.FIELD;
    annotationAttributeSymbol.expr = annotationAttribute.expr;
    annotationAttribute.symbol = annotationAttributeSymbol;
    ((BAnnotationSymbol) env.scope.owner).attributes.add(annotationAttributeSymbol);
    defineSymbol(annotationAttribute.pos, annotationAttributeSymbol);
}
Also used : BAnnotationAttributeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttributeSymbol)

Example 2 with BAnnotationAttributeSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttributeSymbol in project ballerina by ballerina-lang.

the class SemanticAnalyzer method visit.

@Override
public void visit(BLangDocumentation docNode) {
    Set<BLangIdentifier> visitedAttributes = new HashSet<>();
    for (BLangDocumentationAttribute attribute : docNode.attributes) {
        if (!visitedAttributes.add(attribute.documentationField)) {
            this.dlog.warning(attribute.pos, DiagnosticCode.DUPLICATE_DOCUMENTED_ATTRIBUTE, attribute.documentationField);
            continue;
        }
        Name attributeName = names.fromIdNode(attribute.documentationField);
        BSymbol attributeSymbol = this.env.scope.lookup(attributeName).symbol;
        if (attributeSymbol == null) {
            this.dlog.warning(attribute.pos, DiagnosticCode.NO_SUCH_DOCUMENTABLE_ATTRIBUTE, attribute.documentationField, attribute.docTag.getValue());
            continue;
        }
        int ownerSymTag = env.scope.owner.tag;
        if ((ownerSymTag & SymTag.ANNOTATION) == SymTag.ANNOTATION) {
            if (attributeSymbol.tag != SymTag.ANNOTATION_ATTRIBUTE || ((BAnnotationAttributeSymbol) attributeSymbol).docTag != attribute.docTag) {
                this.dlog.warning(attribute.pos, DiagnosticCode.NO_SUCH_DOCUMENTABLE_ATTRIBUTE, attribute.documentationField, attribute.docTag.getValue());
                continue;
            }
        } else {
            if (attributeSymbol.tag != SymTag.VARIABLE || ((BVarSymbol) attributeSymbol).docTag != attribute.docTag) {
                this.dlog.warning(attribute.pos, DiagnosticCode.NO_SUCH_DOCUMENTABLE_ATTRIBUTE, attribute.documentationField, attribute.docTag.getValue());
                continue;
            }
        }
        attribute.type = attributeSymbol.type;
    }
}
Also used : BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) BLangDocumentationAttribute(org.wso2.ballerinalang.compiler.tree.expressions.BLangDocumentationAttribute) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier) BAnnotationAttributeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttributeSymbol) BLangAnnotationAttachmentPoint(org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachmentPoint) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) BVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol) HashSet(java.util.HashSet) Name(org.wso2.ballerinalang.compiler.util.Name)

Aggregations

BAnnotationAttributeSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttributeSymbol)2 HashSet (java.util.HashSet)1 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)1 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)1 BLangAnnotationAttachmentPoint (org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachmentPoint)1 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)1 BLangIdentifier (org.wso2.ballerinalang.compiler.tree.BLangIdentifier)1 BLangDocumentationAttribute (org.wso2.ballerinalang.compiler.tree.expressions.BLangDocumentationAttribute)1 Name (org.wso2.ballerinalang.compiler.util.Name)1