Java Code Examples for com.sun.source.tree.LambdaExpressionTree#BodyKind
The following examples show how to use
com.sun.source.tree.LambdaExpressionTree#BodyKind .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScalaCodeWriter.java From vertx-codetrans with Apache License 2.0 | 6 votes |
@Override public void renderLambda(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body){ append("("); IntStream.range(0, parameterNames.size()).forEach(i -> { if(i > 0) append(", "); append(parameterNames.get(i)); append(": "); append(parameterTypes.get(i).translateName("scala")); }); append(") => {\n"); indent(); body.render(this); if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) append("\n"); unindent(); append("}"); }
Example 2
Source File: GroovyWriter.java From vertx-codetrans with Apache License 2.0 | 6 votes |
@Override public void renderLambda(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body) { append("{"); for (int i = 0; i < parameterNames.size(); i++) { if (i == 0) { append(" "); } else { append(", "); } append(parameterNames.get(i)); } append(" ->\n"); indent(); body.render(this); if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) { append("\n"); } unindent(); append("}"); }
Example 3
Source File: KotlinCodeWriter.java From vertx-codetrans with Apache License 2.0 | 6 votes |
@Override public void renderLambda(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body) { append("{"); if (!parameterNames.isEmpty()) { for (int i = 0; i < parameterNames.size(); i++) { if (i == 0) { append(" "); } else { append(", "); } append(parameterNames.get(i)); } append(" ->\n"); } else { append("\n"); } indent(); body.render(this); if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) { append("\n"); } unindent(); append("}"); }
Example 4
Source File: ScalaCodeBuilder.java From vertx-codetrans with Apache License 2.0 | 5 votes |
@Override public ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo parameterizedTypeInfo, String s, CodeModel codeModel, CodeModel codeModel1, CodeModel codeModel2) { imports.add("scala.util.Failure"); imports.add("scala.util.Success"); return new ExpressionModel(this) { public void render(CodeWriter writer) { asyncResults.add(s); writer.append("{\n"); writer.indent(); writer.append("case Success(result) => "); writer.indent(); if (codeModel1 != null) { writer.append("{\n"); codeModel1.render(writer); writer.unindent(); writer.append("}\n"); } else { writer.append("println(\"Success\")\n"); writer.unindent(); } writer.append("case Failure(cause) => "); writer.indent(); if (codeModel2 != null) { writer.append("{\n"); writer.append("println(s\"$cause\")"); // codeModel2.render(writer) writer.unindent(); writer.append("\n}\n"); } else { writer.append("println(\"Failure\")\n"); writer.unindent(); } writer.unindent(); writer.append("}"); } }; }
Example 5
Source File: ScalaCodeWriter.java From vertx-codetrans with Apache License 2.0 | 5 votes |
@Override public void renderMapForEach(ExpressionModel map, String keyName, TypeInfo keyType, String valueName, TypeInfo valueType, LambdaExpressionTree.BodyKind bodyKind, CodeModel block){ map.render(this); append(".foreach{\n"); indent(); append("case "); unindent(); renderLambda(bodyKind, Arrays.asList(keyType, valueType), Arrays.asList(keyName, valueName), block); append("}"); }
Example 6
Source File: KotlinCodeWriter.java From vertx-codetrans with Apache License 2.0 | 5 votes |
@Override public void renderMapForEach(ExpressionModel map, String keyName, TypeInfo keyType, String valueName, TypeInfo valueType, LambdaExpressionTree.BodyKind bodyKind, CodeModel block) { append("for ((").append(keyName).append(", ").append(valueName).append(") in "); map.render(this); append(") {\n"); indent(); block.render(this); if (bodyKind == LambdaExpressionTree.BodyKind.EXPRESSION) { append("\n"); } unindent(); append("}\n"); }
Example 7
Source File: LambdaExpressionModel.java From vertx-codetrans with Apache License 2.0 | 5 votes |
public LambdaExpressionModel(CodeBuilder builder, LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body) { super(builder); this.bodyKind = bodyKind; this.parameterTypes = parameterTypes; this.parameterNames = parameterNames; this.body = body; }
Example 8
Source File: CodeWriter.java From vertx-codetrans with Apache License 2.0 | 4 votes |
public abstract void renderMapForEach(ExpressionModel map, String keyName, TypeInfo keyType, String valueName, TypeInfo valueType, LambdaExpressionTree.BodyKind bodyKind, CodeModel block);
Example 9
Source File: GroovyCodeBuilder.java From vertx-codetrans with Apache License 2.0 | 4 votes |
@Override public ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo resultType, String resultName, CodeModel body, CodeModel succeededBody, CodeModel failedBody) { return new LambdaExpressionModel(this, bodyKind, Collections.singletonList(resultType), Collections.singletonList(resultName), body); }
Example 10
Source File: GroovyWriter.java From vertx-codetrans with Apache License 2.0 | 4 votes |
@Override public void renderMapForEach(ExpressionModel map, String keyName, TypeInfo keyType, String valueName, TypeInfo valueType, LambdaExpressionTree.BodyKind bodyKind, CodeModel block) { map.render(this); append(".each "); renderLambda(bodyKind, Arrays.asList(keyType, valueType), Arrays.asList(keyName, valueName), block); }
Example 11
Source File: KotlinCodeBuilder.java From vertx-codetrans with Apache License 2.0 | 4 votes |
@Override public ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo resultType, String resultName, CodeModel body, CodeModel succeededBody, CodeModel failedBody) { return new LambdaExpressionModel(this, bodyKind, Collections.singletonList(resultType), Collections.singletonList(resultName), body); }
Example 12
Source File: LambdaExpressionModel.java From vertx-codetrans with Apache License 2.0 | 4 votes |
public LambdaExpressionTree.BodyKind getBodyKind() { return bodyKind; }
Example 13
Source File: CodeBuilder.java From vertx-codetrans with Apache License 2.0 | votes |
ExpressionModel asyncResultHandler(LambdaExpressionTree.BodyKind bodyKind, ParameterizedTypeInfo resultType, String resultName, CodeModel body, CodeModel succeededBody, CodeModel failedBody);
Example 14
Source File: CodeWriter.java From vertx-codetrans with Apache License 2.0 | votes |
public abstract void renderLambda(LambdaExpressionTree.BodyKind bodyKind, List<TypeInfo> parameterTypes, List<String> parameterNames, CodeModel body);