use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addRestArgument.
public void addRestArgument(DiagnosticPos pos, Set<Whitespace> ws) {
BLangRestArgsExpression varArgs = (BLangRestArgsExpression) TreeBuilder.createVarArgsNode();
varArgs.pos = pos;
varArgs.addWS(ws);
varArgs.expr = (BLangExpression) this.exprNodeStack.pop();
addExpressionNode(varArgs);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addKeyValueRecord.
public void addKeyValueRecord(Set<Whitespace> ws) {
BLangRecordKeyValue keyValue = (BLangRecordKeyValue) TreeBuilder.createRecordKeyValue();
keyValue.addWS(ws);
keyValue.valueExpr = (BLangExpression) exprNodeStack.pop();
keyValue.key = new BLangRecordKey((BLangExpression) exprNodeStack.pop());
recordLiteralNodes.peek().keyValuePairs.add(keyValue);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class SqlQueryBuilder method visit.
@Override
public void visit(BLangGroupBy groupBy) {
List<? extends ExpressionNode> varList = groupBy.getVariables();
Iterator<? extends ExpressionNode> iterator = varList.iterator();
groupByClause = new StringBuilder("group by ");
BLangExpression expr = (BLangExpression) iterator.next();
expr.accept(this);
groupByClause.append(exprStack.pop());
while (iterator.hasNext()) {
expr = (BLangExpression) iterator.next();
groupByClause.append(", ");
expr.accept(this);
groupByClause.append(exprStack.pop());
}
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class SqlQueryBuilder method visit.
@Override
public void visit(BLangOrderBy orderBy) {
List<? extends ExpressionNode> varRefs = orderBy.getVariables();
Iterator<? extends ExpressionNode> iterator = varRefs.iterator();
BLangExpression expr = (BLangExpression) iterator.next();
orderByClause = new StringBuilder("order by ");
expr.accept(this);
orderByClause.append(exprStack.pop());
while (iterator.hasNext()) {
orderByClause.append(",").append(" ");
expr = (BLangExpression) iterator.next();
expr.accept(this);
orderByClause.append(exprStack.pop());
}
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class Generator method fieldAnnotation.
/**
* Get description annotation of the field.
* @param node parent node.
* @param param field.
* @return description of the field.
*/
private static String fieldAnnotation(BLangNode node, BLangNode param) {
String subName = "";
if (param instanceof BLangVariable) {
BLangVariable paramVariable = (BLangVariable) param;
subName = (paramVariable.getName() == null) ? paramVariable.type.tsymbol.name.value : paramVariable.getName().getValue();
} else if (param instanceof BLangEnum.Enumerator) {
BLangEnum.Enumerator paramEnumVal = (BLangEnum.Enumerator) param;
subName = paramEnumVal.getName().getValue();
}
for (AnnotationAttachmentNode annotation : getAnnotationAttachments(node)) {
BLangRecordLiteral bLangRecordLiteral = (BLangRecordLiteral) annotation.getExpression();
if (bLangRecordLiteral.getKeyValuePairs().size() != 1) {
continue;
}
BLangExpression bLangLiteral = bLangRecordLiteral.getKeyValuePairs().get(0).getValue();
String attribVal = bLangLiteral.toString();
if (annotation.getAnnotationName().getValue().equals("Field") && attribVal.startsWith(subName + ":")) {
return attribVal.split(subName + ":")[1].trim();
}
}
// annotation's value
for (AnnotationAttachmentNode annotation : getAnnotationAttachments(node)) {
BLangRecordLiteral bLangRecordLiteral = (BLangRecordLiteral) annotation.getExpression();
if (bLangRecordLiteral.getKeyValuePairs().size() != 1) {
continue;
}
if (annotation.getAnnotationName().getValue().equals("Field")) {
BLangExpression bLangLiteral = bLangRecordLiteral.getKeyValuePairs().get(0).getValue();
return bLangLiteral.toString();
}
}
return "";
}
Aggregations