use of org.wso2.ballerinalang.compiler.tree.BLangVariable in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addJoinCause.
public void addJoinCause(Set<Whitespace> ws, String identifier) {
BLangForkJoin forkJoin = (BLangForkJoin) this.forkJoinNodesStack.peek();
forkJoin.joinedBody = (BLangBlockStmt) this.blockNodeStack.pop();
Set<Whitespace> varWS = removeNthFromLast(ws, 3);
forkJoin.addWS(ws);
forkJoin.joinResultVar = (BLangVariable) this.generateBasicVarNode((DiagnosticPos) this.typeNodeStack.peek().getPosition(), varWS, identifier, false);
}
use of org.wso2.ballerinalang.compiler.tree.BLangVariable in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addFieldToObject.
void addFieldToObject(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable, int annotCount, boolean isPrivate) {
Set<Whitespace> wsForSemiColon = removeNthFromLast(ws, 0);
BLangObject objectNode = (BLangObject) this.objectStack.peek();
objectNode.addWS(wsForSemiColon);
BLangVariable field = addVar(pos, ws, identifier, exprAvailable, annotCount);
if (!isPrivate) {
field.flagSet.add(Flag.PUBLIC);
}
}
use of org.wso2.ballerinalang.compiler.tree.BLangVariable in project ballerina by ballerina-lang.
the class TreeVisitor method createVarDef.
private BLangVariableDef createVarDef(BLangVariable var) {
BLangVariableDef varDefNode = new BLangVariableDef();
varDefNode.var = var;
varDefNode.pos = var.pos;
return varDefNode;
}
use of org.wso2.ballerinalang.compiler.tree.BLangVariable in project ballerina by ballerina-lang.
the class ObjectTypeScopeResolver method isCursorBeforeNode.
/**
* Check whether the cursor is positioned before the given node start.
*
* @param nodePosition Position of the node
* @param node Node
* @param treeVisitor {@link TreeVisitor} current tree visitor instance
* @param completionContext Completion operation context
* @return {@link Boolean} Whether the cursor is before the node start or not
*/
@Override
public boolean isCursorBeforeNode(DiagnosticPos nodePosition, Node node, TreeVisitor treeVisitor, TextDocumentServiceContext completionContext) {
if (!(treeVisitor.getBlockOwnerStack().peek() instanceof BLangObject)) {
return false;
}
BLangObject ownerObject = (BLangObject) treeVisitor.getBlockOwnerStack().peek();
DiagnosticPos zeroBasedPos = CommonUtil.toZeroBasedPosition(nodePosition);
DiagnosticPos blockOwnerPos = CommonUtil.toZeroBasedPosition((DiagnosticPos) treeVisitor.getBlockOwnerStack().peek().getPosition());
int line = completionContext.get(DocumentServiceKeys.POSITION_KEY).getPosition().getLine();
int col = completionContext.get(DocumentServiceKeys.POSITION_KEY).getPosition().getCharacter();
boolean isLastField = false;
if ((!ownerObject.fields.isEmpty() && node instanceof BLangVariable && ownerObject.fields.indexOf(node) == ownerObject.fields.size() - 1 && ownerObject.functions.isEmpty()) || (!ownerObject.functions.isEmpty() && node instanceof BLangFunction && ownerObject.functions.indexOf(node) == ownerObject.functions.size() - 1)) {
isLastField = true;
}
if ((line < zeroBasedPos.getStartLine() || (line == zeroBasedPos.getStartLine() && col < zeroBasedPos.getStartColumn())) || (isLastField && ((blockOwnerPos.getEndLine() > line && zeroBasedPos.getEndLine() < line) || (blockOwnerPos.getEndLine() == line && blockOwnerPos.getEndColumn() > col)))) {
Map<Name, Scope.ScopeEntry> visibleSymbolEntries = treeVisitor.resolveAllVisibleSymbols(treeVisitor.getSymbolEnv());
treeVisitor.populateSymbols(visibleSymbolEntries, null);
treeVisitor.setTerminateVisitor(true);
return true;
}
return false;
}
use of org.wso2.ballerinalang.compiler.tree.BLangVariable 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);
}
Aggregations