protected void ensureSuperTypeObject(JvmDeclaredType element) { if (element.getSuperTypes().isEmpty()) { JvmTypeReference objectType = references.getTypeForName(Object.class, element); if (objectType != null) element.getSuperTypes().add(objectType); } }
protected static <R extends LocalVariableCapturer> R findLocalClassSupertype(JvmDeclaredType type) { JvmTypeReference superType = Iterables.getLast(type.getSuperTypes(), null); if (superType == null) { return null; } return findLocalClassSupertype(superType); }
@Override public Boolean caseJvmDeclaredType(JvmDeclaredType object) { if (collectedSuperTypes.add(object)) { for (JvmTypeReference superType : object.getSuperTypes()) { doSwitch(superType); } return Boolean.TRUE; } return Boolean.FALSE; }
public static void captureLocalVariables(JvmDeclaredType localType, ITypeComputationState state) { captureLocalVariables(Iterables.getLast(localType.getSuperTypes()), state); }
private Iterable<JvmDeclaredType> getSuperClasses(final JvmDeclaredType type) { final Function1<JvmTypeReference, JvmType> _function = (JvmTypeReference it) -> { return it.getType(); }; return Iterables.<JvmDeclaredType>filter(ListExtensions.<JvmTypeReference, JvmType>map(type.getSuperTypes(), _function), JvmDeclaredType.class); }
@Override public Boolean caseJvmDeclaredType(JvmDeclaredType object) { if (!object.eIsProxy()) { level++; for (JvmTypeReference superType : object.getSuperTypes()) { doSwitch(superType); } level--; } return Boolean.FALSE; }
public JvmTypeReference getExtendedClass(JvmDeclaredType type) { for(JvmTypeReference candidate: type.getSuperTypes()) { JvmType candidateType = candidate.getType(); if (candidateType instanceof JvmGenericType && !((JvmGenericType) candidateType).isInterface()) return candidate; } return null; }
public boolean isCompatibleWith(final JvmType type, final Class<?> clazz) { return (this._typeReferences.is(type, clazz) || ((type instanceof JvmDeclaredType) && IterableExtensions.<JvmTypeReference>exists(((JvmDeclaredType) type).getSuperTypes(), ((Function1<JvmTypeReference, Boolean>) (JvmTypeReference it) -> { return Boolean.valueOf(this._typeReferences.is(it, clazz)); })))); }
protected void computeAllOperationsFromSuperTypes(JvmDeclaredType type, Multimap<String, AbstractResolvedOperation> processedOperations, Set<JvmType> processedTypes) { for (JvmTypeReference superType: type.getSuperTypes()) { JvmType rawSuperType = superType.getType(); if (rawSuperType instanceof JvmDeclaredType && !rawSuperType.eIsProxy() && processedTypes.add(rawSuperType)) { computeAllOperations((JvmDeclaredType) rawSuperType, processedOperations); computeAllOperationsFromSuperTypes((JvmDeclaredType) rawSuperType, processedOperations, processedTypes); } } }
protected String getDeclaratorName(JvmFeature feature) { JvmDeclaredType declarator = feature.getDeclaringType(); if (declarator.isLocal()) { return "new " + Iterables.getLast(declarator.getSuperTypes()).getType().getSimpleName()+ "(){}"; } else { return declarator.getSimpleName(); } }
public JvmGenericType getSuperType(AnonymousClass anonymousClass) { JvmConstructor constructor = anonymousClass.getConstructorCall().getConstructor(); if(constructor != null && ! constructor.eIsProxy()) { JvmDeclaredType declaringType = constructor.getDeclaringType(); JvmType superType = Iterables.getLast(declaringType.getSuperTypes()).getType(); if(superType instanceof JvmGenericType) return (JvmGenericType) superType; } return null; }
protected SignatureHashBuilder appendSuperTypeSignatures(JvmDeclaredType type) { for(JvmTypeReference superType: type.getSuperTypes()) { append("super "); append(superType.getIdentifier()); append("\n"); } return this; }
protected int getMaxDistanceToObject(JvmTypeReference type) { type = primitives.asWrapperTypeIfPrimitive(type); if (typeRefs.is(type, Object.class)) return 0; JvmType jvmType = type.getType(); int maxDistance = 1; if (jvmType instanceof JvmDeclaredType) { EList<JvmTypeReference> list = ((JvmDeclaredType) jvmType).getSuperTypes(); for (JvmTypeReference jvmTypeReference : list) { int result = 1 + getMaxDistanceToObject(jvmTypeReference); if (result > maxDistance) maxDistance = result; } } return maxDistance; } }
protected IEObjectDescription doGetSingleElement(JvmDeclaredType declarator, QualifiedName name, String firstSegment, int dollarIndex) { if (declarator.isLocal()) { JvmTypeReference superTypeReference = Iterables.getLast(declarator.getSuperTypes()); if (InferredTypeIndicator.isInferred(superTypeReference)) return findNestedTypeInLocalTypeNonResolving(declarator, name, firstSegment, dollarIndex); } Iterable<JvmDeclaredType> nestedTypes = declarator.findAllNestedTypesByName(firstSegment); for(JvmDeclaredType nested: nestedTypes) { JvmType nestedType = findNestedType(nested, 0, name); if (nestedType != null) { return toDescription(name, nestedType, dollarIndex, 0); } } return null; }
@Override protected List<JvmTypeParameter> getDeclaredTypeParameters() { if (isAnonymousClassConstructorCall()) { JvmDeclaredType anonymousType = getConstructor().getDeclaringType(); JvmTypeReference superType = Iterables.getLast(anonymousType.getSuperTypes()); JvmType rawSuperType = superType.getType(); if (rawSuperType instanceof JvmTypeParameterDeclarator) { return ((JvmTypeParameterDeclarator) rawSuperType).getTypeParameters(); } return Collections.emptyList(); } return new FeatureLinkHelper().getDeclaredTypeParameters(getConstructor()); } }
public IScope createMemberScope(JvmType containerType, Predicate<JvmMember> filter, Function<JvmMember, QualifiedName> names, IScope outer) { if (containerType == null || containerType.eIsProxy()) return outer; if (containerType instanceof JvmDeclaredType) { IScope result = outer; List<JvmTypeReference> superTypes = ((JvmDeclaredType) containerType).getSuperTypes(); for(JvmTypeReference superType: superTypes) { if (superType.getType() != null) result = createMemberScope(superType.getType(), filter, names, result); } List<JvmMember> members = ((JvmDeclaredType) containerType).getMembers(); return Scopes.scopeFor(Iterables.filter(members, filter), names, result); } return outer; }
public IScope createMemberScope(JvmType containerType, Predicate<JvmMember> filter, Function<JvmMember, QualifiedName> names, IScope outer) { if (containerType == null || containerType.eIsProxy()) return outer; if (containerType instanceof JvmDeclaredType) { IScope result = outer; List<JvmTypeReference> superTypes = ((JvmDeclaredType) containerType).getSuperTypes(); for(JvmTypeReference superType: superTypes) { if (superType.getType() != null) result = createMemberScope(superType.getType(), filter, names, result); } List<JvmMember> members = ((JvmDeclaredType) containerType).getMembers(); return Scopes.scopeFor(Iterables.filter(members, filter), names, result); } return outer; }
private void setSuperTypes(String name, BinarySuperTypeSignature signature, String superName, String[] interfaces) { InternalEList<JvmTypeReference> superTypes = (InternalEList<JvmTypeReference>) result.getSuperTypes(); if (signature != null) { List<BinaryGenericTypeSignature> superTypeSignatures = signature.getSuperTypes(); if (result.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE && ((JvmGenericType) result).isInterface()) { if (superTypeSignatures.size() > 1) { superTypeSignatures = superTypeSignatures.subList(1, superTypeSignatures.size()); } } for (int i = 0; i < superTypeSignatures.size(); i++) { superTypes.addUnique(proxies.createTypeReference(superTypeSignatures.get(i), typeParameters)); } } else { if (superName != null && result.eClass() != TypesPackage.Literals.JVM_ANNOTATION_TYPE) { superTypes.addUnique(proxies.createTypeReference(BinarySignatures.createObjectTypeSignature(superName), typeParameters)); } setInterfaces(interfaces, typeParameters, superTypes); if (superTypes.isEmpty() && !Proxies.JAVA_LANG_OBJECT.equals(name)) { superTypes.addUnique(proxies.createObjectTypeReference()); } } }
protected void appendConstructedTypeName(XConstructorCall constructorCall, ITreeAppendable typeAppendable) { JvmDeclaredType type = constructorCall.getConstructor().getDeclaringType(); if (type instanceof JvmGenericType && ((JvmGenericType) type).isAnonymous()) { typeAppendable.append(Iterables.getLast(type.getSuperTypes()).getType()); } else { typeAppendable.append(constructorCall.getConstructor().getDeclaringType()); } }
protected void registerSimpleNamesOfInnerClasses(JvmDeclaredType thisType, LinkedHashSet<JvmType> handled) { if (!handled.add(thisType)) return; List<JvmDeclaredType> nested = EcoreUtil2.typeSelect(thisType.getMembers(), JvmDeclaredType.class); for (JvmDeclaredType jvmDeclaredType : nested) { getThisTypeSimpleNames().add(jvmDeclaredType.getSimpleName()); getThisTypeQualifiedNames().add(jvmDeclaredType.getQualifiedName(getInnerTypeSeparator())); thisCollidesWithJavaLang |= CodeGenUtil2.isJavaLangType(jvmDeclaredType.getSimpleName()); } for (JvmTypeReference superType: thisType.getSuperTypes()) { if (superType.getType() instanceof JvmDeclaredType) { registerSimpleNamesOfInnerClasses((JvmDeclaredType) superType.getType(), handled); } } }