Exemple #1
0
 protected Map<TemplateParameter, ParameterableElement> getIterationBindings(
     Iteration candidateIteration) {
   Type sourceType = this.sourceType;
   if (!(sourceType instanceof CollectionType)
       && (candidateIteration.getOwningType() instanceof CollectionType)) {
     sourceType = metaModelManager.getCollectionType("Set", sourceType); // Implicit oclAsSet()
   }
   if (!(sourceType instanceof CollectionType)) { // May be InvalidType
     return null;
   }
   HashMap<TemplateParameter, ParameterableElement> bindings =
       new HashMap<TemplateParameter, ParameterableElement>();
   bindings.put(
       candidateIteration.getOwningType().getOwnedTemplateSignature().getOwnedParameter().get(0),
       ((CollectionType) sourceType).getElementType());
   PivotUtil.getAllTemplateParameterSubstitutions(bindings, sourceType);
   TemplateSignature templateSignature = candidateIteration.getOwnedTemplateSignature();
   if (templateSignature != null) {
     List<TemplateParameter> templateParameters = templateSignature.getOwnedParameter();
     int accIndex = 0;
     for (NavigatingArgCS csArgument : csArguments) {
       if (csArgument.getRole() == NavigationRole.ACCUMULATOR) {
         if (accIndex < templateParameters.size()) {
           Variable argument = PivotUtil.getPivot(Variable.class, csArgument);
           Type argumentType = argument.getType();
           TemplateParameter accParameter = templateParameters.get(accIndex);
           bindings.put(accParameter, argumentType);
         }
         accIndex++;
       }
     }
   }
   return bindings;
 }
Exemple #2
0
 @Override
 protected Map<TemplateParameter, ParameterableElement> getOperationBindings(
     Operation candidateOperation) {
   Type sourceType = this.sourceType;
   Map<TemplateParameter, ParameterableElement> bindings = null;
   Type containingType = candidateOperation.getOwningType();
   if (containingType instanceof CollectionType) {
     if (!(sourceType instanceof CollectionType)) {
       sourceType = metaModelManager.getCollectionType("Set", sourceType); // Implicit oclAsSet()
     }
     Type elementType;
     if (sourceType instanceof CollectionType) {
       elementType = ((CollectionType) sourceType).getElementType();
     } else {
       elementType = metaModelManager.getOclInvalidType();
     }
     bindings = new HashMap<TemplateParameter, ParameterableElement>();
     bindings.put(
         containingType.getOwnedTemplateSignature().getOwnedParameter().get(0), elementType);
   }
   bindings = PivotUtil.getAllTemplateParameterSubstitutions(bindings, sourceType);
   TemplateSignature templateSignature = candidateOperation.getOwnedTemplateSignature();
   if (templateSignature != null) {
     for (TemplateParameter templateParameter : templateSignature.getOwnedParameter()) {
       if (bindings == null) {
         bindings = new HashMap<TemplateParameter, ParameterableElement>();
       }
       bindings.put(templateParameter, null);
     }
   }
   return bindings;
 }