use of org.wso2.ballerinalang.compiler.tree.BLangAction 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.tree.BLangAction in project ballerina by ballerina-lang.
the class Generator method createDocForNode.
/**
* Create documentation for connectors.
* @param connectorNode ballerina connector node.
* @return documentation for connectors.
*/
public static ConnectorDoc createDocForNode(BLangConnector connectorNode) {
String connectorName = connectorNode.getName().value;
List<Variable> parameters = new ArrayList<>();
List<Documentable> actions = new ArrayList<>();
// Iterate through the connector parameters
if (connectorNode.getParameters().size() > 0) {
for (BLangVariable param : connectorNode.getParameters()) {
String dataType = type(param);
String desc = paramAnnotation(connectorNode, param);
Variable variable = new Variable(param.getName().value, dataType, desc);
parameters.add(variable);
}
}
// Iterate through the actions of the connectors
if (connectorNode.getActions().size() > 0) {
for (BLangAction action : connectorNode.getActions()) {
actions.add(createDocForNode(action));
}
}
return new ConnectorDoc(connectorName, description(connectorNode), actions, parameters);
}
use of org.wso2.ballerinalang.compiler.tree.BLangAction in project ballerina by ballerina-lang.
the class SymbolEnter method defineConnectorInitFunction.
private void defineConnectorInitFunction(BLangConnector connector, SymbolEnv conEnv) {
BLangFunction initFunction = createInitFunction(connector.pos, connector.getName().getValue(), Names.INIT_FUNCTION_SUFFIX);
// Add connector as a parameter to the init function
BLangVariable param = (BLangVariable) TreeBuilder.createVariableNode();
param.pos = connector.pos;
param.setName(this.createIdentifier(Names.CONNECTOR.getValue()));
BLangUserDefinedType connectorType = (BLangUserDefinedType) TreeBuilder.createUserDefinedTypeNode();
connectorType.pos = connector.pos;
connectorType.typeName = connector.name;
connectorType.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode();
param.setTypeNode(connectorType);
initFunction.addParameter(param);
// Add connector level variables to the init function
connector.varDefs.stream().filter(f -> f.var.expr != null).forEachOrdered(v -> initFunction.body.addStatement(createAssignmentStmt(v.var)));
addInitReturnStatement(initFunction.body);
connector.initFunction = initFunction;
BLangAction initAction = createNativeInitAction(connector.pos);
connector.initAction = initAction;
defineNode(connector.initFunction, conEnv);
defineNode(connector.initAction, conEnv);
connector.symbol.initFunctionSymbol = connector.initFunction.symbol;
}
use of org.wso2.ballerinalang.compiler.tree.BLangAction in project ballerina by ballerina-lang.
the class TaintAnalyzer method visit.
public void visit(BLangAction actionNode) {
BSymbol actionSymbol = actionNode.symbol;
SymbolEnv actionEnv = SymbolEnv.createResourceActionSymbolEnv(actionNode, actionSymbol.scope, env);
visitInvokable(actionNode, actionEnv);
}
use of org.wso2.ballerinalang.compiler.tree.BLangAction 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);
}
Aggregations