@Override public String declareVariable(Object key, String proposedName) { return this.delegate.declareVariable(key, proposedName); }
protected String reassignThisType(final ITreeAppendable b, final JvmDeclaredType declaredType) { String _xblockexpression = null; { boolean _hasObject = b.hasObject("this"); if (_hasObject) { final Object element = b.getObject("this"); if ((element instanceof JvmDeclaredType)) { boolean _isLocal = ((JvmDeclaredType)element).isLocal(); if (_isLocal) { b.declareVariable(element, ""); } else { String _simpleName = ((JvmDeclaredType)element).getSimpleName(); final String proposedName = (_simpleName + ".this"); b.declareVariable(element, proposedName); } } } String _xifexpression = null; if ((declaredType != null)) { _xifexpression = b.declareVariable(declaredType, "this"); } _xblockexpression = _xifexpression; } return _xblockexpression; }
if (_hasName) { Pair<String, JvmDeclaredType> _mappedTo_1 = Pair.<String, JvmDeclaredType>of("this", ((JvmDeclaredType)element)); b.declareVariable(element, b.getName(_mappedTo_1)); } else { b.declareVariable(element, ""); b.declareVariable(element, proposedName); _xifexpression = b.declareVariable(declaredType, "this");
protected void reassignThisInClosure(final ITreeAppendable b, JvmType rawClosureType) { boolean registerClosureAsThis = rawClosureType instanceof JvmGenericType; if (b.hasObject("this")) { Object element = b.getObject("this"); if (element instanceof JvmType) { // Don't reassign if the types are equal, since the 'this' of the enclosing type is shadowed if (element != rawClosureType) doReassignThisInClosure(b, (JvmType) element); } else { registerClosureAsThis = false; } } if (registerClosureAsThis) { b.declareVariable(rawClosureType, "this"); } }
protected void appendClosureParameterVarArgs(JvmFormalParameter closureParam, LightweightTypeReference parameterType, ITreeAppendable appendable) { appendable.append("final "); appendable.append(parameterType); appendable.append("... "); final String proposedParamName = makeJavaIdentifier(closureParam.getName()); String name = appendable.declareVariable(closureParam, proposedParamName); appendable.append(name); }
protected void appendClosureParameter(JvmFormalParameter closureParam, LightweightTypeReference parameterType, ITreeAppendable appendable) { appendable.append("final "); appendable.append(parameterType); appendable.append(" "); final String proposedParamName = makeJavaIdentifier(closureParam.getName()); String name = appendable.declareVariable(closureParam, proposedParamName); appendable.append(name); }
String _simpleName = ((JvmDeclaredType)element).getSimpleName(); final String proposedName = (_simpleName + ".super"); b.declareVariable(superElement, proposedName); String _qualifiedName = interfaze.getQualifiedName(); final String qualifiedVarName = (_qualifiedName + ".super"); b.declareVariable(interfaze, qualifiedVarName); b.declareVariable(interfaze, simpleVarName); _xifexpression = b.declareVariable(superType, "super");
protected void appendForLoopParameter(XForLoopExpression expr, ITreeAppendable appendable) { appendable.append("final "); JvmTypeReference paramType = getForLoopParameterType(expr); serialize(paramType, expr, appendable); appendable.append(" "); final String name = makeJavaIdentifier(expr.getDeclaredParam().getName()); String varName = appendable.declareVariable(expr.getDeclaredParam(), name); appendable.trace(expr.getDeclaredParam(), TypesPackage.Literals.JVM_FORMAL_PARAMETER__NAME, 0).append(varName); }
/** * Symmetric to {@link XtendGenerator#reassignThisType(ITreeAppendable, JvmDeclaredType)} */ @Override protected void doReassignThisInClosure(ITreeAppendable b, JvmType prevType) { if (prevType instanceof JvmDeclaredType && ((JvmDeclaredType) prevType).isLocal()) { if (b.hasName(Pair.of("this", prevType))) { b.declareVariable(prevType, b.getName(Pair.of("this", prevType))); } else { b.declareSyntheticVariable(prevType, ""); } if (b.hasObject("super")) { Object superElement = b.getObject("super"); if (superElement instanceof JvmType) { // Don't reassign the super of the enclosing type if it has already been reassigned String superVariable = b.getName(superElement); if ("super".equals(superVariable)) { b.declareSyntheticVariable(superElement, prevType.getSimpleName()+".super"); } } } } else { super.doReassignThisInClosure(b, prevType); } }
protected ITreeAppendable _generateMember(final JvmField it, final ITreeAppendable appendable, final GeneratorConfig config) { ITreeAppendable _xblockexpression = null; { appendable.newLine(); this.generateJavaDoc(it, appendable, config); final ITreeAppendable tracedAppendable = appendable.trace(it); this.generateAnnotations(it.getAnnotations(), tracedAppendable, true, config); this.generateModifier(it, tracedAppendable, config); this._errorSafeExtensions.serializeSafely(it.getType(), "Object", tracedAppendable); tracedAppendable.append(" "); final String name = tracedAppendable.declareVariable(it, this.makeJavaIdentifier(it.getSimpleName())); this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(name); this.generateInitialization(it, tracedAppendable, config); _xblockexpression = tracedAppendable.append(";"); } return _xblockexpression; }
b.newLine().append("final "); b.append(type).append(" "); selfVariable = b.declareVariable(type.getType(), "_self"); b.append(selfVariable); b.append(" = this;");
protected LightweightTypeReference appendVariableTypeAndName(XVariableDeclaration varDeclaration, ITreeAppendable appendable) { if (!varDeclaration.isWriteable()) { appendable.append("final "); } LightweightTypeReference type = null; if (varDeclaration.getType() != null) { serialize(varDeclaration.getType(), varDeclaration, appendable); type = getLightweightType((JvmIdentifiableElement) varDeclaration); } else { type = getLightweightType(varDeclaration.getRight()); if (type.isAny()) { type = getTypeForVariableDeclaration(varDeclaration.getRight()); } appendable.append(type); } appendable.append(" "); appendable.append(appendable.declareVariable(varDeclaration, makeJavaIdentifier(varDeclaration.getName()))); return type; }
String loopParam = debugAppendable.declareVariable(parameter, parameter.getName()); debugAppendable.append(loopParam); debugAppendable.append(" : ");
public void generateParameter(final JvmFormalParameter it, final ITreeAppendable appendable, final boolean vararg, final GeneratorConfig config) { final ITreeAppendable tracedAppendable = appendable.trace(it); this.generateAnnotations(it.getAnnotations(), tracedAppendable, false, config); tracedAppendable.append("final "); if (vararg) { JvmTypeReference _parameterType = it.getParameterType(); boolean _not = (!(_parameterType instanceof JvmGenericArrayTypeReference)); if (_not) { tracedAppendable.append("/* Internal Error: Parameter was vararg but not an array type. */"); } else { JvmTypeReference _parameterType_1 = it.getParameterType(); this._errorSafeExtensions.serializeSafely(((JvmGenericArrayTypeReference) _parameterType_1).getComponentType(), "Object", tracedAppendable); } tracedAppendable.append("..."); } else { this._errorSafeExtensions.serializeSafely(it.getParameterType(), "Object", tracedAppendable); } tracedAppendable.append(" "); final String name = tracedAppendable.declareVariable(it, this.makeJavaIdentifier(it.getSimpleName())); this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(name); }
JvmTypeReference type = catchClause.getDeclaredParam().getParameterType(); final String declaredParamName = makeJavaIdentifier(catchClause.getDeclaredParam().getName()); final String name = appendable.declareVariable(catchClause.getDeclaredParam(), declaredParamName); appendable.append("if ("); JvmTypeReference typeToUse = type;
appendable.newLine().append("final "); //$NON-NLS-1$ appendable.append(type).append(" "); //$NON-NLS-1$ selfVariable = appendable.declareVariable(type.getType(), "_self"); //$NON-NLS-1$ appendable.append(selfVariable); appendable.append(" = this;"); //$NON-NLS-1$
Object thisElement = appendable.getObject("this"); if (thisElement instanceof JvmType) { appendable.declareVariable(thisElement, ((JvmType) thisElement).getSimpleName()+".this"); if (appendable.hasObject("super")) { Object superElement = appendable.getObject("super"); if (superElement instanceof JvmType) { appendable.declareVariable(superElement, ((JvmType) thisElement).getSimpleName()+".super");