コード例 #1
0
ファイル: TypeReferences.java プロジェクト: ramons03/xtext
 public JvmParameterizedTypeReference createTypeRef(JvmType type, JvmTypeReference... typeArgs) {
   List<JvmTypeReference> typeReferences = Collections.emptyList();
   if (typeArgs != null && typeArgs.length > 0) {
     typeReferences = newArrayListWithCapacity(typeArgs.length);
     for (int i = 0; i < typeArgs.length; i++) {
       JvmTypeReference jvmTypeReference = typeArgs[i];
       typeReferences.add(EcoreUtil2.clone(jvmTypeReference));
     }
   }
   if (type instanceof JvmGenericType) {
     List<JvmTypeParameter> list = ((JvmGenericType) type).getTypeParameters();
     if (!typeReferences.isEmpty() && list.size() != typeReferences.size()) {
       throw new IllegalArgumentException(
           "The type "
               + type.getIdentifier()
               + " expects "
               + list.size()
               + " type arguments, but was "
               + typeReferences.size()
               + ". Either pass zero arguments (raw type) or the correct number.");
     }
     // Raw type -> create type references to type param
     if (typeReferences.isEmpty() && !list.isEmpty()) {
       typeReferences = newArrayListWithCapacity(list.size());
       for (JvmTypeParameter typeParameter : list) {
         typeReferences.add(createTypeRef(typeParameter));
       }
     }
   }
   JvmParameterizedTypeReference reference = factory.createJvmParameterizedTypeReference();
   reference.setType(type);
   if (!typeReferences.isEmpty()) reference.getArguments().addAll(typeReferences);
   return reference;
 }
コード例 #2
0
  public List<Class> getCopyOfAddedClasses(DeltaModule delta) {

    List<Class> addedClasses = DeltaJUtils.getAddedClasses(delta);
    List<Class> copy = new LinkedList<Class>();
    for (Class class1 : addedClasses) {
      copy.add(EcoreUtil2.clone(class1));
    }
    return copy;
  }
コード例 #3
0
  protected void addClonedMethod(Class classToModify, Method method) {

    classToModify.getMethods().add(EcoreUtil2.clone(method));
  }
コード例 #4
0
  protected void addClonedField(Class classToModify, Field field) {

    classToModify.getFields().add(EcoreUtil2.clone(field));
  }