Пример #1
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;
 }
Пример #2
0
 public static boolean isLibraryType(Type type) {
   if (type instanceof LambdaType) {
     return false;
   } else if (type instanceof TupleType) {
     return false;
   } else {
     return type.getTemplateBinding().isEmpty();
   }
 }
Пример #3
0
 public static Map<TemplateParameter, ParameterableElement> getAllTemplateParameterSubstitutions(
     Map<TemplateParameter, ParameterableElement> bindings,
     Type argumentType,
     LambdaType lambdaType) {
   Type resultType = lambdaType.getResultType();
   if (resultType != null) {
     TemplateParameter resultTemplateParameter = resultType.getOwningTemplateParameter();
     if (resultTemplateParameter != null) {
       if (bindings == null) {
         bindings = new HashMap<TemplateParameter, ParameterableElement>();
       }
       bindings.put(resultTemplateParameter, argumentType);
     }
   }
   // FIXME There is much more to do
   // FIXME Conflict checking
   return bindings;
 }
Пример #4
0
 public static boolean debugWellContainedness(Type type) {
   if (type.eResource() == null) {
     PivotUtil.debugObjectUsage("Badly contained ", type);
     return false;
   }
   if (type instanceof CollectionType) {
     if (!debugWellContainedness(((CollectionType) type).getElementType())) {
       PivotUtil.debugObjectUsage("Badly contained ", type);
       return false;
     }
   }
   return true;
 }