Exemple #1
0
 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;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 public static List<TemplateParameter> getTemplateParameters(
     TemplateableElement templateableElement) {
   if (templateableElement != null) {
     TemplateSignature ownedTemplateSignature = templateableElement.getOwnedTemplateSignature();
     if (ownedTemplateSignature != null) {
       return ownedTemplateSignature.getParameter();
     }
   }
   return Collections.emptyList();
 }
Exemple #4
0
 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();
 }
Exemple #5
0
 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;
 }