private String withOrWithoutParens(ModelASTArgumentList argList) { if (argList == null) { return name + "()"; } else { String argGroovy = argList.toGroovy(); if (!(this instanceof ModelASTTreeStep) && argList instanceof ModelASTSingleArgument && // Special-casing for list/map args since they still need parentheses. !argGroovy.startsWith("[")) { return name + " " + argGroovy; } else { return name + "(" + argGroovy + ")"; } } }
private String withOrWithoutParens(ModelASTArgumentList argList) { if (argList == null) { return name + "()"; } else { String argGroovy = argList.toGroovy(); if (!(this instanceof ModelASTTreeStep) && argList instanceof ModelASTSingleArgument && // Special-casing for list/map args since they still need parentheses. !argGroovy.startsWith("[")) { return name + " " + argGroovy; } else { return name + "(" + argGroovy + ")"; } } }
@Override public String toGroovy() { StringBuilder result = new StringBuilder(); if (!children.isEmpty()) { result.append(name).append(" {\n"); for (ModelASTWhenContent child : children) { result.append(child.toGroovy()).append("\n"); } result.append("}\n"); } else { result.append(name).append(" ").append(getArgs().toGroovy()); } return result.toString(); }
@Override public String toGroovy() { StringBuilder result = new StringBuilder(); if (!children.isEmpty()) { result.append(name).append(" {\n"); for (ModelASTWhenContent child : children) { result.append(child.toGroovy()).append("\n"); } result.append("}\n"); } else { result.append(name).append(" ").append(getArgs().toGroovy()); } return result.toString(); }
public String codeBlockAsString() { if (getArgs() == null) { return null; } else if (isLiteralSingleArg()) { Object v = getSingleValue().getValue(); if (v instanceof String) { List<String> retList = new ArrayList<>(); for (String s : v.toString().split("\\r?\\n")) { retList.add(s.trim()); } return StringUtils.join(retList, "\n"); } else { return v.toString(); } } else { return getArgs().toGroovy(); } }
public String codeBlockAsString() { if (getArgs() == null) { return null; } else if (isLiteralSingleArg()) { Object v = getSingleValue().getValue(); if (v instanceof String) { List<String> retList = new ArrayList<>(); for (String s : v.toString().split("\\r?\\n")) { retList.add(s.trim()); } return StringUtils.join(retList, "\n"); } else { return v.toString(); } } else { return getArgs().toGroovy(); } }