コード例 #1
0
ファイル: PivotUtil.java プロジェクト: matterche/ocl
 public static Map<TemplateParameter, ParameterableElement> getAllTemplateParametersAsBindings(
     EObject eObject) {
   if (eObject instanceof Type) {
     eObject = getUnspecializedTemplateableElement((Type) eObject);
   }
   Map<TemplateParameter, ParameterableElement> result = null;
   EObject eContainer = eObject.eContainer();
   if (eContainer != null) {
     result = getAllTemplateParametersAsBindings(eContainer);
   }
   if (eObject instanceof TemplateableElement) {
     //			TemplateableElement unspecializedTemplateableElement =
     // getUnspecializedTemplateableElement((TemplateableElement)eObject);
     TemplateSignature templateSignature =
         ((TemplateableElement) eObject).getOwnedTemplateSignature();
     if (templateSignature != null) {
       List<TemplateParameter> templateParameters = templateSignature.getParameter();
       if (templateParameters.size() > 0) {
         if (result == null) {
           result = new HashMap<TemplateParameter, ParameterableElement>();
         }
         for (TemplateParameter templateParameter : templateSignature.getParameter()) {
           result.put(templateParameter, null);
         }
       }
     }
   }
   return result;
 }
コード例 #2
0
ファイル: PivotUtil.java プロジェクト: matterche/ocl
 public static List<TemplateParameter> getAllTemplateParameters(EObject eObject) {
   List<TemplateParameter> result = null;
   EObject eContainer = eObject.eContainer();
   if (eContainer != null) {
     result = getAllTemplateParameters(eContainer);
   }
   if (eObject instanceof TemplateableElement) {
     TemplateableElement unspecializedTemplateableElement = (TemplateableElement) eObject;
     if (eObject instanceof Type) {
       eObject = getUnspecializedTemplateableElement((Type) eObject);
     }
     TemplateSignature templateSignature =
         unspecializedTemplateableElement.getOwnedTemplateSignature();
     if (templateSignature != null) {
       List<TemplateParameter> templateParameters = templateSignature.getParameter();
       if (templateParameters.size() > 0) {
         if (result == null) {
           result = new ArrayList<TemplateParameter>();
         }
         result.addAll(templateParameters);
       }
     }
   }
   return result;
 }
コード例 #3
0
ファイル: OperationFilter.java プロジェクト: matterche/ocl
 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;
 }
コード例 #4
0
ファイル: OperationFilter.java プロジェクト: matterche/ocl
 @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;
 }
コード例 #5
0
 @Override
 public ScopeView computeLookup(EnvironmentView environmentView, ScopeView scopeView) {
   TemplateSignature pivot = getPivot();
   if (pivot != null) {
     environmentView.addElements(pivot.getOwnedParameters());
   }
   return scopeView.getOuterScope();
 }
コード例 #6
0
ファイル: PivotUtil.java プロジェクト: matterche/ocl
 public static List<TemplateParameter> getTemplateParameters(
     TemplateableElement templateableElement) {
   if (templateableElement != null) {
     TemplateSignature ownedTemplateSignature = templateableElement.getOwnedTemplateSignature();
     if (ownedTemplateSignature != null) {
       return ownedTemplateSignature.getParameter();
     }
   }
   return Collections.emptyList();
 }
コード例 #7
0
ファイル: PivotUtil.java プロジェクト: matterche/ocl
 public static List<TemplateParameter> getAllTemplateParameters(
     Collection<TemplateBinding> templateBindings) {
   List<TemplateParameter> list = null;
   for (TemplateBinding templateBinding : templateBindings) { // FIXME Establish ordering
     TemplateSignature templateSignature = templateBinding.getSignature();
     if (templateSignature != null) {
       List<TemplateParameter> templateParameters = templateSignature.getParameter();
       if (templateParameters.size() > 0) {
         if (list == null) {
           list = new ArrayList<TemplateParameter>();
         }
         list.addAll(templateParameters);
       }
     }
   }
   return list != null ? list : Collections.<TemplateParameter>emptyList();
 }
コード例 #8
0
ファイル: PivotUtil.java プロジェクト: matterche/ocl
 public static List<Type> getTypeTemplateParameterables(TemplateableElement templateableElement) {
   if (templateableElement == null) {
     return Collections.emptyList();
   }
   TemplateSignature ownedTemplateSignature = templateableElement.getOwnedTemplateSignature();
   if (ownedTemplateSignature == null) {
     return Collections.emptyList();
   }
   List<TemplateParameter> templateParameters = ownedTemplateSignature.getParameter();
   if (templateParameters.size() == 0) {
     return Collections.emptyList();
   }
   if (templateParameters.size() == 1) {
     return Collections.singletonList((Type) templateParameters.get(0).getParameteredElement());
   }
   List<Type> results = new ArrayList<Type>(templateParameters.size());
   for (TemplateParameter templateParameter : templateParameters) {
     results.add((Type) templateParameter.getParameteredElement());
   }
   return results;
 }