/** * @param isReferenced unused in this context but necessary for dispatch signature */ protected void _toJavaStatement(XReturnExpression expr, ITreeAppendable b, boolean isReferenced) { if (expr.getExpression()!=null) { internalToJavaStatement(expr.getExpression(), b, true); b.newLine().append("return "); LightweightTypeReference returnTypeToCompile = findRealReturnType(expr); internalToConvertedExpression(expr.getExpression(), b, returnTypeToCompile); b.append(";"); } else { b.newLine().append("return;"); } }
private LightweightTypeReference findRealReturnType(XExpression expression) { if (expression == null) return null; JvmIdentifiableElement logicalContainer = getLogicalContainerProvider().getLogicalContainer(expression); if (logicalContainer instanceof JvmOperation) { return getLightweightType(logicalContainer); } if (expression instanceof XClosure) { IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(expression); LightweightTypeReference type = resolvedTypes.getExpectedType(expression); if (type == null) { type = resolvedTypes.getActualType(expression); } if (type == null) { return null; } FunctionTypeReference functionType = type.tryConvertToFunctionTypeReference(false); if (functionType != null) { return functionType.getReturnType(); } return null; } XExpression containerExpression = EcoreUtil2.getContainerOfType(expression.eContainer(), XExpression.class); if (containerExpression == null) { LightweightTypeReference returnType = getLightweightReturnType(expression); return returnType; } return findRealReturnType(containerExpression); }