use of org.stjs.generator.javascript.NameValue in project st-js by st-js.
the class MultipleVariableWriter method visit.
public JS visit(WriterVisitor<JS> visitor, List<VariableTree> trees, GenerationContext<JS> context, boolean isStatement) {
if (trees.isEmpty()) {
return context.js().emptyStatement();
}
List<NameValue<JS>> vars = new ArrayList<NameValue<JS>>();
for (VariableTree tree : trees) {
JS init = null;
if (tree.getInitializer() != null) {
init = visitor.scan(tree.getInitializer(), context);
}
vars.add(NameValue.of(tree.getName(), init));
}
return context.withPosition(trees.get(0), context.js().variableDeclaration(isStatement, vars));
}
Aggregations