protected boolean hasCycleInHierarchy(final JvmGenericType type, final Set<JvmGenericType> processedSuperTypes) { boolean _contains = processedSuperTypes.contains(type); if (_contains) { return true; } processedSuperTypes.add(type); final Function1<JvmTypeReference, JvmType> _function = new Function1<JvmTypeReference, JvmType>() { @Override public JvmType apply(final JvmTypeReference it) { return it.getType(); } }; Iterable<JvmGenericType> _filter = Iterables.<JvmGenericType>filter(ListExtensions.<JvmTypeReference, JvmType>map(type.getSuperTypes(), _function), JvmGenericType.class); for (final JvmGenericType genericType : _filter) { boolean _hasCycleInHierarchy = this.hasCycleInHierarchy(genericType, processedSuperTypes); if (_hasCycleInHierarchy) { return true; } } processedSuperTypes.remove(type); return false; }
protected boolean hasCycleInHierarchy(JvmGenericType type, Set<JvmGenericType> processedSuperTypes) { JvmDeclaredType container = type; do { if (processedSuperTypes.contains(container)) return true; container = container.getDeclaringType(); } while (container != null); processedSuperTypes.add(type); for (JvmTypeReference superTypeRef : type.getSuperTypes()) { if (superTypeRef.getType() instanceof JvmGenericType) { if (hasCycleInHierarchy((JvmGenericType) superTypeRef.getType(), processedSuperTypes)) return true; } } processedSuperTypes.remove(type); return false; }
@Override public void setExtendedInterfaces(final Iterable<? extends TypeReference> superinterfaces) { this.checkMutable(); ConditionUtils.checkIterable(superinterfaces, "superinterfaces"); this.getDelegate().getSuperTypes().clear(); for (final TypeReference typeRef : superinterfaces) { { boolean _isInferred = typeRef.isInferred(); if (_isInferred) { throw new IllegalArgumentException("Cannot use inferred type as extended interface."); } EList<JvmTypeReference> _superTypes = this.getDelegate().getSuperTypes(); JvmTypeReference _jvmTypeReference = this.getCompilationUnit().toJvmTypeReference(typeRef); _superTypes.add(_jvmTypeReference); } } }
@Override public void apply(final JvmGenericType it) { it.setPackageName(packageName); EList<JvmTypeReference> _superTypes = it.getSuperTypes(); JvmTypeReference _typeRef = EMFPatternLanguageJvmModelInferrer.this._typeReferenceBuilder.typeRef(BasePatternMatch.class); EMFPatternLanguageJvmModelInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); } };
private Iterable<JvmOperation> superTypeJvmOperations(final JvmGenericType type) { if ((type == null)) { return CollectionLiterals.<JvmOperation>emptyList(); } JvmType _type = IterableExtensions.<JvmTypeReference>head(type.getSuperTypes()).getType(); return Iterables.<JvmOperation>filter(((JvmGenericType) _type).getAllFeatures(), JvmOperation.class); } }
@Override public void apply(final JvmGenericType it) { it.setPackageName(packageName); EList<JvmTypeReference> _superTypes = it.getSuperTypes(); JvmTypeReference _typeRef = EMFPatternLanguageJvmModelInferrer.this._typeReferenceBuilder.typeRef(matchClass); JvmTypeReference _typeRef_1 = EMFPatternLanguageJvmModelInferrer.this._typeReferenceBuilder.typeRef(BaseMatcher.class, _typeRef); EMFPatternLanguageJvmModelInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef_1); } };
private boolean setSuperClassType(final JvmGenericType e, final WithExtendsClause dslElement, final Class<?> defaultSuperClass) { boolean _xifexpression = false; ExtendsClause _extendsClause = dslElement.getExtendsClause(); boolean _tripleNotEquals = (_extendsClause != null); if (_tripleNotEquals) { EList<JvmTypeReference> _superTypes = e.getSuperTypes(); JvmTypeReference _cloneWithProxies = this._jvmTypesBuilder.cloneWithProxies(dslElement.getExtendsClause().getSuperType()); _xifexpression = this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _cloneWithProxies); } else { EList<JvmTypeReference> _superTypes_1 = e.getSuperTypes(); JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(defaultSuperClass); _xifexpression = this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_1, _typeRef); } return _xifexpression; }
@Override public void registerClass(final String qualifiedName) throws IllegalArgumentException { final JvmGenericType newType = TypesFactory.eINSTANCE.createJvmGenericType(); newType.setVisibility(JvmVisibility.PUBLIC); EList<JvmTypeReference> _superTypes = newType.getSuperTypes(); JvmTypeReference _typeForName = this.compilationUnit.getTypeReferences().getTypeForName(Object.class, this.compilationUnit.getXtendFile()); _superTypes.add(_typeForName); this.setNameAndAccept(newType, qualifiedName); }
@Check public void checkSuperTypes(AnonymousClass anonymousClass) { JvmGenericType inferredType = associations.getInferredType(anonymousClass); if (inferredType != null) { JvmTypeReference superTypeRef = Iterables.getLast(inferredType.getSuperTypes()); JvmType superType = superTypeRef.getType(); if(superType instanceof JvmGenericType && ((JvmGenericType) superType).isFinal()) error("Attempt to override final class", anonymousClass.getConstructorCall(), XCONSTRUCTOR_CALL__CONSTRUCTOR, INSIGNIFICANT_INDEX, OVERRIDDEN_FINAL); } }
@Override public void setImplementedInterfaces(final Iterable<? extends TypeReference> superInterfaces) { this.checkMutable(); ConditionUtils.checkIterable(superInterfaces, "superIntefaces"); ConditionUtils.checkInferredTypeReferences("implemented interface", ((TypeReference[])Conversions.unwrapArray(superInterfaces, TypeReference.class))); final Function1<JvmTypeReference, Boolean> _function = (JvmTypeReference it) -> { return Boolean.valueOf(((it.getType() instanceof JvmGenericType) && ((JvmGenericType) it.getType()).isInterface())); }; final Iterable<JvmTypeReference> oldInterfaces = IterableExtensions.<JvmTypeReference>filter(this.getDelegate().getSuperTypes(), _function); CollectionExtensions.<JvmTypeReference>removeAll(this.getDelegate().getSuperTypes(), oldInterfaces); final Function1<TypeReference, JvmTypeReference> _function_1 = (TypeReference it) -> { return this.getCompilationUnit().toJvmTypeReference(it); }; Iterables.<JvmTypeReference>addAll(this.getDelegate().getSuperTypes(), IterableExtensions.map(superInterfaces, _function_1)); }
@Override public void apply(final JvmGenericType it) { String _packageName = model.getPackageName(); it.setPackageName(_packageName); it.setFinal(true); EList<JvmTypeReference> _superTypes = it.getSuperTypes(); JvmTypeReference _typeRef = PatternGroupClassInferrer.this.builder.typeRef(BaseGeneratedPatternGroup.class); PatternGroupClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); } };
protected void _visit(final JvmGenericType jvmType, final INode originNode, final ImportsAcceptor acceptor) { boolean _isAnonymous = jvmType.isAnonymous(); if (_isAnonymous) { this.visit(IterableExtensions.<JvmTypeReference>last(jvmType.getSuperTypes()).getType(), originNode, acceptor); } else { this._visit(((JvmDeclaredType) jvmType), originNode, acceptor); } }
@Override public void apply(final JvmGenericType it) { it.setVisibility(JvmVisibility.PRIVATE); it.setStatic(true); EList<JvmTypeReference> _superTypes = it.getSuperTypes(); JvmTypeReference _typeRef = PatternQuerySpecificationClassInferrer.this.builder.typeRef(BaseGeneratedEMFPQuery.class); PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); PatternQuerySpecificationClassInferrer.this.inferPQueryMembers(it, pattern, specBuilder); } };
@Override public void apply(final JvmGenericType it) { it.setPackageName(processorPackageName); CharSequence _javadocProcessorClass = PatternMatchProcessorClassInferrer.this._javadocInferrer.javadocProcessorClass(pattern); String _string = _javadocProcessorClass.toString(); PatternMatchProcessorClassInferrer.this._eMFJvmTypesBuilder.setDocumentation(it, _string); it.setAbstract(true); EList<JvmTypeReference> _superTypes = it.getSuperTypes(); JvmTypeReference _typeRef = PatternMatchProcessorClassInferrer.this.builder.typeRef(matchClass); JvmTypeReference _typeRef_1 = PatternMatchProcessorClassInferrer.this.builder.typeRef(IMatchProcessor.class, _typeRef); PatternMatchProcessorClassInferrer.this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef_1); } };
@Override public void setExtendedClass(final TypeReference superclass) { this.checkMutable(); ConditionUtils.checkInferredTypeReferences("extended class", superclass); JvmTypeReference _xifexpression = null; if ((superclass != null)) { _xifexpression = this.getCompilationUnit().toJvmTypeReference(superclass); } else { _xifexpression = this.getCompilationUnit().getTypeReferences().getTypeForName(Object.class, this.getCompilationUnit().getXtendFile()); } final JvmTypeReference newTypeRef = _xifexpression; final Function1<JvmTypeReference, Boolean> _function = (JvmTypeReference it) -> { return Boolean.valueOf(((it.getType() instanceof JvmGenericType) && (!((JvmGenericType) it.getType()).isInterface()))); }; final JvmTypeReference oldType = IterableExtensions.<JvmTypeReference>findFirst(this.getDelegate().getSuperTypes(), _function); if ((oldType != null)) { this.getDelegate().getSuperTypes().remove(oldType); } this.getDelegate().getSuperTypes().add(newTypeRef); }
@Override public Iterable<? extends TypeReference> getExtendedInterfaces() { List<TypeReference> _xblockexpression = null; { final Function1<JvmTypeReference, Boolean> _function = (JvmTypeReference it) -> { JvmType _type = it.getType(); return Boolean.valueOf(((JvmGenericType) _type).isInterface()); }; final Iterable<JvmTypeReference> filtered = IterableExtensions.<JvmTypeReference>filter(this.getDelegate().getSuperTypes(), _function); final Function1<JvmTypeReference, TypeReference> _function_1 = (JvmTypeReference it) -> { return this.getCompilationUnit().toTypeReference(it); }; _xblockexpression = IterableExtensions.<TypeReference>toList(IterableExtensions.<JvmTypeReference, TypeReference>map(filtered, _function_1)); } return _xblockexpression; }
@Override public Iterable<? extends TypeReference> getImplementedInterfaces() { List<TypeReference> _xblockexpression = null; { final Function1<JvmTypeReference, Boolean> _function = (JvmTypeReference it) -> { JvmType _type = it.getType(); return Boolean.valueOf(((JvmGenericType) _type).isInterface()); }; final Iterable<JvmTypeReference> filtered = IterableExtensions.<JvmTypeReference>filter(this.getDelegate().getSuperTypes(), _function); final Function1<JvmTypeReference, TypeReference> _function_1 = (JvmTypeReference it) -> { return this.getCompilationUnit().toTypeReference(it); }; _xblockexpression = IterableExtensions.<TypeReference>toList(IterableExtensions.<JvmTypeReference, TypeReference>map(filtered, _function_1)); } return _xblockexpression; }
@Override @SuppressWarnings("deprecation") public void accept(JvmTypeReference capturingTypeReference) { casted.setEquivalent(capturingTypeReference); IFeatureScopeSession mySession = addThisAndSuper(nestedSession, resolvedTypes.getReferenceOwner(), localClass, superTypeReference, false); if(type.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE && ((JvmGenericType) type).isInterface() || type.eClass() == TypesPackage.Literals.JVM_ANNOTATION_TYPE) { localClass.getSuperTypes().add(0, typesBuilder.newTypeRef(localClass, Object.class)); inferAnonymousClassConstructor(anonymousClass, localClass); } else { for(JvmMember superMember: type.getMembers()) { if (superMember instanceof JvmConstructor) { JvmConstructor superTypeConstructor = (JvmConstructor) superMember; boolean visible = mySession.isVisible(superTypeConstructor); inferAnonymousClassConstructor(anonymousClass, localClass, superTypeConstructor, visible); } } } } });
public JvmGenericType inferPatternGroupClass(final PatternModel model, final JvmTypeReferenceBuilder builder, final EMFPatternLanguageGeneratorConfig config, final boolean includePrivate) { JvmGenericType _xblockexpression = null; { this.builder = builder; final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { it.setPackageName(this.groupPackageName(model, includePrivate)); it.setFinal(true); EList<JvmTypeReference> _superTypes = it.getSuperTypes(); JvmTypeReference _typeRef = this.builder.typeRef(BaseGeneratedPatternGroup.class); this._eMFJvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef); this._eMFJvmTypesBuilder.setFileHeader(it, this._eMFPatternLanguageJvmModelInferrerUtil.getFileComment(model)); }; _xblockexpression = this._eMFJvmTypesBuilder.toClass(model, this.groupClassName(model, includePrivate), _function); } return _xblockexpression; }
protected void initialize(XtendInterface source, JvmGenericType inferredJvmType) { inferredJvmType.setVisibility(source.getVisibility()); inferredJvmType.setStatic(source.isStatic() && !isTopLevel(source)); inferredJvmType.setAbstract(true); inferredJvmType.setStrictFloatingPoint(source.isStrictFloatingPoint()); translateAnnotationsTo(source.getAnnotations(), inferredJvmType); for (JvmTypeReference intf : source.getExtends()) { inferredJvmType.getSuperTypes().add(jvmTypesBuilder.cloneWithProxies(intf)); } fixTypeParameters(inferredJvmType); for (XtendMember member : source.getMembers()) { if (member instanceof XtendField || (member instanceof XtendFunction && ((XtendFunction) member).getName() != null)) { transform(member, inferredJvmType, false); } } jvmTypesBuilder.copyDocumentationTo(source, inferredJvmType); nameClashResolver.resolveNameClashes(inferredJvmType); }