Java Code Examples for org.eclipse.xtext.xbase.compiler.output.ITreeAppendable#getObject()
The following examples show how to use
org.eclipse.xtext.xbase.compiler.output.ITreeAppendable#getObject() .
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: TypeConvertingCompiler.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
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"); } }
Example 2
Source File: TypeConvertingCompiler.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void doReassignThisInClosure(final ITreeAppendable b, JvmType prevType) { final String proposedName = prevType.getSimpleName()+".this"; if (!b.hasObject(proposedName)) { b.declareSyntheticVariable(prevType, proposedName); 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"); } } } } }
Example 3
Source File: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
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; }
Example 4
Source File: XtendCompiler.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * 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); } }
Example 5
Source File: XtendGenerator.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public 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) { Pair<String, JvmDeclaredType> _mappedTo = Pair.<String, JvmDeclaredType>of("this", ((JvmDeclaredType)element)); boolean _hasName = b.hasName(_mappedTo); 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, ""); } } 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; }
Example 6
Source File: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
private String reassignSuperType(final ITreeAppendable b, final JvmDeclaredType declaredType, final GeneratorConfig config) { String _xblockexpression = null; { JvmTypeReference _extendedClass = declaredType.getExtendedClass(); JvmType _type = null; if (_extendedClass!=null) { _type=_extendedClass.getType(); } final JvmType superType = _type; boolean _hasObject = b.hasObject("super"); if (_hasObject) { final Object element = b.getObject("this"); if ((element instanceof JvmDeclaredType)) { final Object superElement = b.getObject("super"); final String superVariable = b.getName(superElement); boolean _equals = "super".equals(superVariable); if (_equals) { String _simpleName = ((JvmDeclaredType)element).getSimpleName(); final String proposedName = (_simpleName + ".super"); b.declareVariable(superElement, proposedName); } } } boolean _isAtLeast = config.getJavaSourceVersion().isAtLeast(JavaVersion.JAVA8); if (_isAtLeast) { Iterable<JvmTypeReference> _extendedInterfaces = declaredType.getExtendedInterfaces(); for (final JvmTypeReference interfaceRef : _extendedInterfaces) { { final JvmType interfaze = interfaceRef.getType(); String _simpleName_1 = interfaze.getSimpleName(); final String simpleVarName = (_simpleName_1 + ".super"); boolean _hasObject_1 = b.hasObject(simpleVarName); if (_hasObject_1) { final Object element_1 = b.getObject(simpleVarName); boolean _notEquals = (!Objects.equal(element_1, interfaceRef)); if (_notEquals) { String _qualifiedName = interfaze.getQualifiedName(); final String qualifiedVarName = (_qualifiedName + ".super"); b.declareVariable(interfaze, qualifiedVarName); } } else { b.declareVariable(interfaze, simpleVarName); } } } } String _xifexpression = null; if ((superType != null)) { _xifexpression = b.declareVariable(superType, "super"); } _xblockexpression = _xifexpression; } return _xblockexpression; }