use of org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachmentPoint in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangVariable varNode) {
int ownerSymTag = env.scope.owner.tag;
if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE) {
// If the variable is parameter then the variable symbol is already defined
if (varNode.symbol == null) {
symbolEnter.defineNode(varNode, env);
}
}
BType lhsType = varNode.symbol.type;
varNode.type = lhsType;
// Here we validate annotation attachments for package level variables.
varNode.annAttachments.forEach(a -> {
a.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.CONST);
a.accept(this);
});
// Here we validate document attachments for package level variables.
varNode.docAttachments.forEach(doc -> {
doc.accept(this);
});
// Analyze the init expression
BLangExpression rhsExpr = varNode.expr;
if (rhsExpr == null) {
return;
}
// Here we create a new symbol environment to catch self references by keep the current
// variable symbol in the symbol environment
// e.g. int a = x + a;
SymbolEnv varInitEnv = SymbolEnv.createVarInitEnv(varNode, env, varNode.symbol);
// It will we done during the init-function of the respective construct is visited.
if ((ownerSymTag & SymTag.PACKAGE) == SymTag.PACKAGE || (ownerSymTag & SymTag.SERVICE) == SymTag.SERVICE || (ownerSymTag & SymTag.CONNECTOR) == SymTag.CONNECTOR) {
return;
}
// Return if this not a safe assignment
if (!varNode.safeAssignment) {
typeChecker.checkExpr(rhsExpr, varInitEnv, Lists.of(lhsType));
return;
}
handleSafeAssignment(varNode.pos, lhsType, rhsExpr, varInitEnv);
}
use of org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachmentPoint in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangAction actionNode) {
BSymbol actionSymbol = actionNode.symbol;
SymbolEnv actionEnv = SymbolEnv.createResourceActionSymbolEnv(actionNode, actionSymbol.scope, env);
actionNode.annAttachments.forEach(a -> {
a.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.ACTION);
this.analyzeDef(a, actionEnv);
});
actionNode.docAttachments.forEach(doc -> analyzeDef(doc, actionEnv));
if (Symbols.isNative(actionSymbol)) {
return;
}
actionNode.requiredParams.forEach(p -> this.analyzeDef(p, actionEnv));
actionNode.defaultableParams.forEach(p -> this.analyzeDef(p, actionEnv));
if (actionNode.restParam != null) {
this.analyzeDef(actionNode.restParam, actionEnv);
}
actionNode.endpoints.forEach(e -> analyzeDef(e, actionEnv));
analyzeStmt(actionNode.body, actionEnv);
this.processWorkers(actionNode, actionEnv);
}
use of org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachmentPoint in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangAnnotation annotationNode) {
SymbolEnv annotationEnv = SymbolEnv.createAnnotationEnv(annotationNode, annotationNode.symbol.scope, env);
annotationNode.annAttachments.forEach(annotationAttachment -> {
annotationAttachment.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.ANNOTATION);
annotationAttachment.accept(this);
});
annotationNode.docAttachments.forEach(doc -> analyzeDef(doc, annotationEnv));
}
use of org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachmentPoint 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.tree.BLangAnnotationAttachmentPoint in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangFunction funcNode) {
SymbolEnv funcEnv = SymbolEnv.createFunctionEnv(funcNode, funcNode.symbol.scope, env);
funcNode.annAttachments.forEach(annotationAttachment -> {
annotationAttachment.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.FUNCTION);
this.analyzeDef(annotationAttachment, funcEnv);
});
funcNode.docAttachments.forEach(doc -> analyzeDef(doc, funcEnv));
funcNode.requiredParams.forEach(p -> this.analyzeDef(p, funcEnv));
funcNode.defaultableParams.forEach(p -> this.analyzeDef(p, funcEnv));
if (funcNode.restParam != null) {
this.analyzeDef(funcNode.restParam, funcEnv);
}
// Check for native functions
if (Symbols.isNative(funcNode.symbol) || funcNode.interfaceFunction) {
return;
}
funcNode.endpoints.forEach(e -> {
symbolEnter.defineNode(e, funcEnv);
analyzeDef(e, funcEnv);
});
analyzeStmt(funcNode.body, funcEnv);
this.processWorkers(funcNode, funcEnv);
}
Aggregations