use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol 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;
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
@Override
public void visit(BLangEnum enumNode) {
BSymbol enumSymbol = enumNode.symbol;
SymbolEnv enumEnv = SymbolEnv.createPkgLevelSymbolEnv(enumNode, enumSymbol.scope, env);
enumNode.annAttachments.forEach(annotationAttachment -> {
annotationAttachment.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.ENUM);
annotationAttachment.accept(this);
});
enumNode.docAttachments.forEach(doc -> analyzeDef(doc, enumEnv));
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangResource resourceNode) {
BSymbol resourceSymbol = resourceNode.symbol;
SymbolEnv resourceEnv = SymbolEnv.createResourceActionSymbolEnv(resourceNode, resourceSymbol.scope, env);
resourceNode.annAttachments.forEach(a -> {
a.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.RESOURCE);
this.analyzeDef(a, resourceEnv);
});
defineResourceEndpoint(resourceNode, resourceEnv);
resourceNode.docAttachments.forEach(doc -> analyzeDef(doc, resourceEnv));
resourceNode.requiredParams.forEach(p -> analyzeDef(p, resourceEnv));
resourceNode.endpoints.forEach(e -> {
symbolEnter.defineNode(e, resourceEnv);
analyzeDef(e, resourceEnv);
});
analyzeStmt(resourceNode.body, resourceEnv);
this.processWorkers(resourceNode, resourceEnv);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangPostIncrement postIncrement) {
BLangExpression varRef = postIncrement.varRef;
if (varRef.getKind() != NodeKind.SIMPLE_VARIABLE_REF && varRef.getKind() != NodeKind.INDEX_BASED_ACCESS_EXPR && varRef.getKind() != NodeKind.FIELD_BASED_ACCESS_EXPR && varRef.getKind() != NodeKind.XML_ATTRIBUTE_ACCESS_EXPR) {
if (postIncrement.opKind == OperatorKind.ADD) {
dlog.error(varRef.pos, DiagnosticCode.OPERATOR_NOT_ALLOWED_VARIABLE, OperatorKind.INCREMENT, varRef);
} else {
dlog.error(varRef.pos, DiagnosticCode.OPERATOR_NOT_ALLOWED_VARIABLE, OperatorKind.DECREMENT, varRef);
}
return;
} else {
this.typeChecker.checkExpr(varRef, env).get(0);
}
this.typeChecker.checkExpr(postIncrement.increment, env).get(0);
if (varRef.type == symTable.intType || varRef.type == symTable.floatType) {
BSymbol opSymbol = this.symResolver.resolveBinaryOperator(postIncrement.opKind, varRef.type, postIncrement.increment.type);
postIncrement.modifiedExpr = getBinaryExpr(varRef, postIncrement.increment, postIncrement.opKind, opSymbol);
} else {
if (postIncrement.opKind == OperatorKind.ADD) {
dlog.error(varRef.pos, DiagnosticCode.OPERATOR_NOT_SUPPORTED, OperatorKind.INCREMENT, varRef.type);
} else {
dlog.error(varRef.pos, DiagnosticCode.OPERATOR_NOT_SUPPORTED, OperatorKind.DECREMENT, varRef.type);
}
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangObject objectNode) {
BSymbol objectSymbol = objectNode.symbol;
SymbolEnv objectEnv = SymbolEnv.createPkgLevelSymbolEnv(objectNode, objectSymbol.scope, env);
objectNode.fields.forEach(field -> analyzeDef(field, objectEnv));
objectNode.annAttachments.forEach(annotationAttachment -> {
annotationAttachment.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.STRUCT);
annotationAttachment.accept(this);
});
objectNode.docAttachments.forEach(doc -> analyzeDef(doc, objectEnv));
analyzeDef(objectNode.initFunction, objectEnv);
// Visit temporary init statements in the init function
SymbolEnv funcEnv = SymbolEnv.createFunctionEnv(objectNode.initFunction, objectNode.initFunction.symbol.scope, objectEnv);
objectNode.initFunction.initFunctionStmts.values().forEach(s -> analyzeNode(s, funcEnv));
objectNode.functions.forEach(f -> analyzeDef(f, objectEnv));
}
Aggregations