@Override public GeneratorConfig getGeneratorConfig() { return this.delegate.getGeneratorConfig(); }
protected void _toJavaStatement(XSwitchExpression expr, ITreeAppendable b, boolean isReferenced) { GeneratorConfig config = b.getGeneratorConfig(); boolean compileToSwitch; if (config != null && config.getJavaSourceVersion().isAtLeast(JAVA7)) { compileToSwitch = isCompiledToJava7Switch(expr); } else { compileToSwitch = isCompiledToJavaSwitch(expr); } if (compileToSwitch) { _toJavaSwitchStatement(expr, b, isReferenced); } else { _toJavaIfElseStatement(expr, b, isReferenced); } }
protected void _toJavaStatement(final XClosure closure, final ITreeAppendable b, boolean isReferenced) { if (!isReferenced) throw new IllegalArgumentException("a closure definition does not cause any side-effects"); LightweightTypeReference type = getLightweightType(closure); JvmOperation operation = findImplementingOperation(type); if (operation != null) { b.newLine().append("final "); b.append(type); b.append(" "); String variableName = b.declareSyntheticVariable(closure, "_function"); b.append(variableName).append(" = "); GeneratorConfig config = b.getGeneratorConfig(); if (config != null && config.getJavaSourceVersion().isAtLeast(JAVA8) && canCompileToJavaLambda(closure, type, operation)) { toLambda(closure, b, type, operation, false); } else { toAnonymousClass(closure, b, type, operation); } b.append(";"); } }
protected void appendOperationVisibility(final ITreeAppendable b, JvmOperation operation) { b.newLine(); JvmDeclaredType declaringType = operation.getDeclaringType(); GeneratorConfig config = b.getGeneratorConfig(); if (config != null && config.getJavaSourceVersion().isAtLeast(JAVA6) || declaringType instanceof JvmGenericType && !((JvmGenericType) declaringType).isInterface()) { b.append("@").append(Override.class).newLine(); } switch(operation.getVisibility()) { case DEFAULT: break; case PUBLIC: b.append("public "); return; case PROTECTED: b.append("protected "); return; case PRIVATE: b.append("private "); return; } }
GeneratorConfig config = b.getGeneratorConfig(); if (config != null && config.getJavaSourceVersion().isAtLeast(JAVA7)) { b.append(numberLiterals.toJavaLiteral(expr, false));
protected void _toJavaExpression(final XClosure closure, final ITreeAppendable b) { if (b.hasName(closure)) { b.trace(closure, false).append(getVarName(closure, b)); } else { LightweightTypeReference type = getLightweightType(closure); JvmOperation operation = findImplementingOperation(type); if (operation != null) { GeneratorConfig config = b.getGeneratorConfig(); if (config != null && config.getJavaSourceVersion().isAtLeast(JAVA8) && canCompileToJavaLambda(closure, type, operation)) { toLambda(closure, b.trace(closure, false), type, operation, true); } else { toAnonymousClass(closure, b.trace(closure, false), type, operation); } } } }