use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class TreeVisitor method visit.
@Override
public void visit(BLangEndpoint endpointNode) {
if (!ScopeResolverConstants.getResolverByClass(cursorPositionResolver).isCursorBeforeNode(endpointNode.getPosition(), endpointNode, this, this.documentServiceContext)) {
SymbolEnv endpointEnv = SymbolEnv.createPkgLevelSymbolEnv(endpointNode, endpointNode.symbol.scope, symbolEnv);
this.isWithinEndpointContext(endpointNode.getPosition(), endpointEnv, endpointNode.getName().getValue());
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class TreeVisitor method visit.
// Statements
@Override
public void visit(BLangBlockStmt blockNode) {
SymbolEnv blockEnv = SymbolEnv.createBlockEnv(blockNode, symbolEnv);
this.blockStmtStack.push(blockNode);
// Cursor position is calculated against the Block statement scope resolver
this.cursorPositionResolver = BlockStatementScopeResolver.class;
// Reset the previous node to null
this.setPreviousNode(null);
if (blockNode.stmts.isEmpty()) {
this.isCursorWithinBlock((DiagnosticPos) (this.blockOwnerStack.peek()).getPosition(), blockEnv);
} else {
blockNode.stmts.forEach(stmt -> this.acceptNode(stmt, blockEnv));
}
this.blockStmtStack.pop();
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class TreeVisitor method visit.
@Override
public void visit(BLangObject objectNode) {
BSymbol objectSymbol = objectNode.symbol;
SymbolEnv objectEnv = SymbolEnv.createPkgLevelSymbolEnv(objectNode, objectSymbol.scope, symbolEnv);
blockOwnerStack.push(objectNode);
this.cursorPositionResolver = ObjectTypeScopeResolver.class;
objectNode.fields.forEach(field -> acceptNode(field, objectEnv));
// TODO: visit annotation and doc attachments
objectNode.functions.forEach(f -> acceptNode(f, objectEnv));
blockOwnerStack.pop();
this.cursorPositionResolver = TopLevelNodeScopeResolver.class;
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class TreeVisitor method visit.
public void visit(BLangAction actionNode) {
String actionName = actionNode.getName().getValue();
BSymbol actionSymbol = actionNode.symbol;
SymbolEnv actionEnv = SymbolEnv.createResourceActionSymbolEnv(actionNode, actionSymbol.scope, symbolEnv);
if (this.isWithinParameterContext(actionName, NODE_TYPE_ACTION)) {
this.populateSymbols(this.resolveAllVisibleSymbols(actionEnv), actionEnv);
setTerminateVisitor(true);
} else if (!ScopeResolverConstants.getResolverByClass(cursorPositionResolver).isCursorBeforeNode(actionNode.getPosition(), actionNode, this, this.documentServiceContext)) {
// TODO: Handle Annotation attachments
// Visit the endpoints
actionNode.endpoints.forEach(bLangEndpoint -> this.acceptNode(bLangEndpoint, actionEnv));
// Cursor position is calculated against the resource parameter scope resolver since both are similar
cursorPositionResolver = ResourceParamScopeResolver.class;
actionNode.workers.forEach(w -> this.acceptNode(w, actionEnv));
// Cursor position is calculated against the Block statement scope resolver
cursorPositionResolver = BlockStatementScopeResolver.class;
this.blockOwnerStack.push(actionNode);
acceptNode(actionNode.body, actionEnv);
this.blockOwnerStack.pop();
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class TreeVisitor method visit.
public void visit(BLangService serviceNode) {
if (!ScopeResolverConstants.getResolverByClass(cursorPositionResolver).isCursorBeforeNode(serviceNode.getPosition(), serviceNode, this, this.documentServiceContext)) {
BSymbol serviceSymbol = serviceNode.symbol;
SymbolEnv serviceEnv = SymbolEnv.createPkgLevelSymbolEnv(serviceNode, serviceSymbol.scope, symbolEnv);
// Reset the previous node
this.setPreviousNode(null);
if (!(serviceNode.resources.isEmpty() && serviceNode.vars.isEmpty() && serviceNode.endpoints.isEmpty())) {
// Visit the endpoints
serviceNode.endpoints.forEach(bLangEndpoint -> this.acceptNode(bLangEndpoint, serviceEnv));
// Since the service does not contains a block statement, we consider the block owner only.
// Here it is service
this.blockOwnerStack.push(serviceNode);
serviceNode.vars.forEach(v -> {
this.cursorPositionResolver = ServiceScopeResolver.class;
this.acceptNode(v, serviceEnv);
});
serviceNode.resources.forEach(r -> {
this.cursorPositionResolver = ServiceScopeResolver.class;
this.acceptNode(r, serviceEnv);
});
if (terminateVisitor) {
this.acceptNode(null, null);
}
this.blockOwnerStack.pop();
} else {
this.isCursorWithinBlock(serviceNode.getPosition(), serviceEnv);
}
}
}
Aggregations