protected Iterable<JvmFeature> removeOverridden(Multimap<Triple<EClass, String, Integer>, JvmFeature> featureIndex, ITypeArgumentContext ctx) { Set<JvmFeature> result = Sets.newLinkedHashSet(featureIndex.values()); for (Collection<JvmFeature> featuresWithSameName : featureIndex.asMap().values()) { if (featuresWithSameName.size() > 1) { for (JvmFeature op1 : featuresWithSameName) { for (JvmFeature op2 : featuresWithSameName) { if (result.contains(op1) && op1.getDeclaringType() != op2.getDeclaringType() && internalIsOverridden(op1, op2, ctx, true)) result.remove(op2); } } } } return result; }
protected JvmDeclaredType internalGetDeclaringType() { JvmDeclaredType result = getDeclaringType(); if (result == null) { EObject container = eContainer(); if (container instanceof JvmFeature) { result = ((JvmFeature) container).getDeclaringType(); } } return result; }
@Override public LightweightTypeReference getResolvedDeclarator() { JvmFeature declaration = getDeclaration(); JvmDeclaredType declarator = declaration.getDeclaringType(); return getContextType().getSuperType(declarator); }
protected String getDeclaratorName(JvmFeature feature) { JvmDeclaredType declarator = feature.getDeclaringType(); if (declarator.isLocal()) { return "new " + Iterables.getLast(declarator.getSuperTypes()).getType().getSimpleName()+ "(){}"; } else { return declarator.getSimpleName(); } }
private void initializeLocalTypes(JvmFeature feature, XExpression expression) { if (expression != null) { TreeIterator<EObject> iterator = EcoreUtil2.getAllNonDerivedContents(expression, true); String nameStub = "__" + feature.getDeclaringType().getSimpleName(); while(iterator.hasNext()) { EObject next = iterator.next(); if (next.eClass() == XtendPackage.Literals.ANONYMOUS_CLASS) { inferLocalClass((AnonymousClass) next, nameStub, feature); iterator.prune(); } } } }
protected boolean isRawTypeInheritance() { List<LightweightTypeReference> superTypes = getContextType().getAllSuperTypes(); JvmDeclaredType declaringType = getDeclaration().getDeclaringType(); for(LightweightTypeReference superType: superTypes) { if (superType.getType() == declaringType && superType.isRawType()) { return true; } } return false; } }
/** Analyzing the type hierarchy of the given interface and * extract hierarchy information. * * @param jvmElement - the element to analyze * @param operations - filled with the operations inside and inherited by the element. * @param fields - filled with the fields inside and inherited by the element. * @param sarlSignatureProvider - provider of tools related to action signatures. * @see OverrideHelper */ public static void populateInterfaceElements( JvmDeclaredType jvmElement, Map<ActionPrototype, JvmOperation> operations, Map<String, JvmField> fields, IActionPrototypeProvider sarlSignatureProvider) { for (final JvmFeature feature : jvmElement.getAllFeatures()) { if (!"java.lang.Object".equals(feature.getDeclaringType().getQualifiedName())) { //$NON-NLS-1$ if (operations != null && feature instanceof JvmOperation) { final JvmOperation operation = (JvmOperation) feature; final ActionParameterTypes sig = sarlSignatureProvider.createParameterTypesFromJvmModel( operation.isVarArgs(), operation.getParameters()); final ActionPrototype actionKey = sarlSignatureProvider.createActionPrototype( operation.getSimpleName(), sig); operations.put(actionKey, operation); } else if (fields != null && feature instanceof JvmField) { fields.put(feature.getSimpleName(), (JvmField) feature); } } } }
output.add(((JvmFeature) call.getFeature()).getDeclaringType()); return true;
/** Initialize the local class to the given expression. * * @param context the generation context. * @param feature the feature which contains the expression. * @param expression the expression which contains the local class. */ protected void initializeLocalTypes(GenerationContext context, JvmFeature feature, XExpression expression) { if (expression != null) { int localTypeIndex = context.getLocalTypeIndex(); final TreeIterator<EObject> iterator = EcoreUtil2.getAllNonDerivedContents(expression, true); final String nameStub = "__" + feature.getDeclaringType().getSimpleName() + "_"; //$NON-NLS-1$ //$NON-NLS-2$ while (iterator.hasNext()) { final EObject next = iterator.next(); if (next.eClass() == XtendPackage.Literals.ANONYMOUS_CLASS) { inferLocalClass((AnonymousClass) next, nameStub + localTypeIndex, feature); iterator.prune(); ++localTypeIndex; } } context.setLocalTypeIndex(localTypeIndex); } }
for (final JvmFeature feature : ((JvmGenericType) interfaceReference.getType()).getAllFeatures()) { if (!"java.lang.Object".equals(//$NON-NLS-1$ feature.getDeclaringType().getQualifiedName())) { if (feature instanceof JvmOperation) { final JvmOperation operation = (JvmOperation) feature; final JvmGenericType parentType = (JvmGenericType) extendedClass.getType(); for (final JvmFeature feature : parentType.getAllFeatures()) { if (!"java.lang.Object".equals(feature.getDeclaringType().getQualifiedName()) //$NON-NLS-1$ && isVisible(jvmElement, feature) && !isHiddenMember(feature.getSimpleName())) {
b.append(((JvmFeature) call.getFeature()).getDeclaringType()); return true;
protected TypeParameterSubstitutor<?> getSubstitutor() { if (getContextType().getType() != getDeclaration().getDeclaringType()) { if (isRawTypeInheritance()) { return new RawTypeSubstitutor(getContextType().getOwner()); } } Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> mapping = getContextTypeParameterMapping(); TypeParameterSubstitutor<?> result = new TypeParameterByConstraintSubstitutor(mapping, getContextType().getOwner()) { @Override protected boolean isDeclaredTypeParameter(JvmTypeParameter typeParameter) { if (super.isDeclaredTypeParameter(typeParameter) || isResolvedTypeParameter(typeParameter) || getTypeParameterMapping().containsKey(typeParameter)) return true; return false; } @Override /* @Nullable */ protected LightweightMergedBoundTypeArgument getBoundTypeArgument(JvmTypeParameter type, ConstraintVisitingInfo info) { LightweightMergedBoundTypeArgument result = super.getBoundTypeArgument(type, info); if (result != null && result.getTypeReference().getType() == type) { return null; } return result; } }; return result; }
JvmDeclaredType declaringType = ((JvmFeature) feature).getDeclaringType(); final LightweightTypeReference declaringTypeReference = receiverType.getOwner().newParameterizedTypeReference(declaringType); final TypeConformanceComputationArgument rawConformanceCheck = new TypeConformanceComputationArgument(true, false, false, false, false, false);
JvmDeclaredType declaringType = ((JvmFeature) feature).getDeclaringType(); final LightweightTypeReference declaringTypeReference = receiverType.getOwner().newParameterizedTypeReference(declaringType); final TypeConformanceComputationArgument rawConformanceCheck = new TypeConformanceComputationArgument(true, false, false, false, false, false);