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 boolean isNameEqual(JvmFeature overriding, JvmFeature overridden) { return Objects.equal(overriding.getSimpleName(), overridden.getSimpleName()); }
protected void computeLocalTypes( Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmFeature feature) { for(JvmGenericType localClass: feature.getLocalClasses()) { computeTypes(preparedResolvedTypes, resolvedTypes, featureScopeSession, localClass); } }
public static String getPropertyName(final JvmFeature feature) { String _xifexpression = null; boolean _isStatic = feature.isStatic(); if (_isStatic) { _xifexpression = PropertyUtil.getPropertyName(feature, feature.getSimpleName(), 1, 2); } else { _xifexpression = PropertyUtil.getPropertyName(feature, feature.getSimpleName(), 0, 1); } return _xifexpression; }
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())) { if (feature instanceof JvmOperation) { if (!feature.isStatic()) { final JvmOperation operation = (JvmOperation) feature; final ActionParameterTypes sig = sarlSignatureProvider.createParameterTypesFromJvmModel( operation.isVarArgs(), operation.getParameters()); final ActionPrototype actionKey = sarlSignatureProvider.createActionPrototype( feature.getSimpleName(), sig); if (operation.isAbstract() && !operation.isDefault()) { if (operationsToImplement != null) { inheritedFields.put(feature.getSimpleName(), (JvmField) feature);
/** 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); } } } }
protected InstanceFeatureDescriptionWithoutReceiver( QualifiedName qualifiedName, JvmFeature feature, int bucketId, boolean visible) { super(qualifiedName, feature, bucketId, visible); if (feature.isStatic()) { throw new IllegalArgumentException(String.valueOf(feature)); } }
@Override public void accept(String simpleName, int order) { for(JvmType type: bucket.getTypes()) { if (type instanceof JvmDeclaredType) { List<JvmFeature> features = findAllFeaturesByName(type, simpleName, bucket.getResolvedFeaturesProvider()); if (order == 1) { allFeatures.addAll(features); } else { for(int i = 0, size = features.size(); i < size; i++) { JvmFeature feature = features.get(i); if (feature.eClass() == TypesPackage.Literals.JVM_OPERATION) { allFeatures.add(feature); } } } } } } });
protected void getAllLocalElements(TypeBucket bucket, JvmDeclaredType type, Set<String> restrictedNames, List<IEObjectDescription> result) { Iterable<JvmFeature> features = type.getAllFeatures(); for (JvmFeature feature : features) { if (feature.isStatic() && restrictedNames.contains(feature.getSimpleName())) { addDescriptions(feature, bucket, result); } } }
public StaticFeatureDescription(QualifiedName qualifiedName, JvmFeature feature, int bucketId, boolean visible) { super(qualifiedName, feature, bucketId, visible); if (!feature.isStatic()) { throw new IllegalArgumentException(String.valueOf(feature)); } }
@Override public void accept(String simpleName, int order) { for(JvmType type: bucket.getTypes()) { if (type instanceof JvmDeclaredType) { List<JvmFeature> features = findAllFeaturesByName(type, simpleName, bucket.getResolvedFeaturesProvider()); if (order == 1) { allFeatures.addAll(features); } else { for(int i = 0, size = features.size(); i < size; i++) { JvmFeature feature = features.get(i); if (feature.eClass() == TypesPackage.Literals.JVM_OPERATION) { allFeatures.add(feature); } } } } } } });
protected JvmDeclaredType internalGetDeclaringType() { JvmDeclaredType result = getDeclaringType(); if (result == null) { EObject container = eContainer(); if (container instanceof JvmFeature) { result = ((JvmFeature) container).getDeclaringType(); } } return result; }
protected void computeAllFeatures(List<JvmFeature> unfiltered, Multimap<String, AbstractResolvedOperation> processedOperations, List<JvmFeature> result) { for(JvmFeature feature: unfiltered) { if (feature instanceof JvmOperation) { String simpleName = feature.getSimpleName(); if (processedOperations.containsKey(simpleName)) { if (parent.isOverridden((JvmOperation) feature, processedOperations.get(simpleName))) { continue; } } BottomResolvedOperation resolvedOperation = parent.createResolvedOperation((JvmOperation) feature, type); processedOperations.put(simpleName, resolvedOperation); result.add(feature); } else { result.add(feature); } } }
@Override protected void getAllLocalElements(TypeBucket bucket, JvmDeclaredType type, Set<String> restrictedNames, List<IEObjectDescription> result) { Iterable<JvmFeature> features = type.getAllFeatures(); for(JvmFeature feature: features) { if (feature.isStatic() && restrictedNames.contains(feature.getSimpleName()) && helper.isPossibleExtension(feature) && helper.isMatchingFirstParameterDeepCheck((JvmOperation) feature)) { fastAddDescriptions(feature, bucket, result); } } }
protected void _recordExpressions(JvmFeature feature) { List<JvmGenericType> localClasses = feature.getLocalClasses(); for(int i = 0, size = localClasses.size(); i < size; i++) { recordExpressions(localClasses.get(i)); } recordAnnotationExpressions(feature); }
protected StaticExtensionFeatureDescription( QualifiedName qualifiedName, JvmFeature feature, XExpression syntacticReceiver, LightweightTypeReference syntacticReceiverType, int bucketId, boolean visible) { super(qualifiedName, feature, bucketId, visible); if (!feature.isStatic()) { throw new IllegalArgumentException(String.valueOf(feature)); } this.argument = syntacticReceiver; this.argumentType = syntacticReceiverType; }
@Override public void accept(String simpleName, int order) { for(JvmType type: types) { if (type instanceof JvmDeclaredType) { IResolvedFeatures resolvedFeatures = bucket.getResolvedFeaturesProvider().getResolvedFeatures(type).getParameterizedView(extensionType); List<JvmFeature> features = resolvedFeatures.getAllFeatures(simpleName); if (order == 1) { allFeatures.addAll(features); } else { for(int i = 0, size = features.size(); i < size; i++) { JvmFeature feature = features.get(i); if (feature.eClass() == TypesPackage.Literals.JVM_OPERATION) { allFeatures.add(feature); } } } } } } });
@Override public LightweightTypeReference getResolvedDeclarator() { JvmFeature declaration = getDeclaration(); JvmDeclaredType declarator = declaration.getDeclaringType(); return getContextType().getSuperType(declarator); }
protected void computeAllFeatures( JvmDeclaredType type, Multimap<String, AbstractResolvedOperation> processedOperations, Set<String> processedFields, ListMultimap<String, JvmFeature> result, Set<String> seenNames) { Iterable<JvmFeature> features = type.getAllFeatures(); for(JvmFeature feature: features) { if (!seenNames.contains(feature.getSimpleName())) { if (feature instanceof JvmOperation) { JvmOperation operation = (JvmOperation) feature; String simpleName = operation.getSimpleName(); if (processedOperations.containsKey(simpleName)) { if (isOverridden(operation, processedOperations.get(simpleName))) { continue; } } BottomResolvedOperation resolvedOperation = createResolvedOperation(operation); processedOperations.put(simpleName, resolvedOperation); result.put(simpleName, operation); } else if (feature instanceof JvmField && processedFields.add(feature.getSimpleName())) { result.put(feature.getSimpleName(), feature); } } } }
public Iterable<JvmFeature> findAllFeatures(final XImportDeclaration it) { Iterable<JvmFeature> _xblockexpression = null; { final JvmDeclaredType importedType = it.getImportedType(); if (((!it.isStatic()) || (importedType == null))) { return CollectionLiterals.<JvmFeature>emptyList(); } final IVisibilityHelper visibilityHelper = this.getVisibilityHelper(it.eResource()); final IResolvedFeatures resolvedFeatures = this._provider.getResolvedFeatures(importedType); final Function1<JvmFeature, Boolean> _function = (JvmFeature feature) -> { return Boolean.valueOf(((feature.isStatic() && visibilityHelper.isVisible(feature)) && ((it.getMemberName() == null) || feature.getSimpleName().startsWith(it.getMemberName())))); }; _xblockexpression = IterableExtensions.<JvmFeature>filter(resolvedFeatures.getAllFeatures(), _function); } return _xblockexpression; }