Exemplo n.º 1
0
 private void copyFields(
     final EObject objectWithReference,
     final Iterable<XtendMember> members,
     final Set<String> fieldNames) {
   boolean _not = (!(objectWithReference instanceof XtendClass));
   if (_not) {
     return;
   }
   final XtendClass type = ((XtendClass) objectWithReference);
   final ArrayList<XtendField> newFields = CollectionLiterals.<XtendField>newArrayList();
   Iterable<XtendField> _filter = Iterables.<XtendField>filter(members, XtendField.class);
   for (final XtendField field : _filter) {
     String _name = field.getName();
     boolean _contains = fieldNames.contains(_name);
     boolean _not_1 = (!_contains);
     if (_not_1) {
       final XtendField copiedMember = this._expressionCopier.<XtendField>cloneWithProxies(field);
       SourceAdapter.adapt(copiedMember, field);
       newFields.add(((XtendField) copiedMember));
       String _name_1 = field.getName();
       fieldNames.add(_name_1);
     }
   }
   EList<XtendMember> _members = type.getMembers();
   _members.addAll(newFields);
 }
Exemplo n.º 2
0
 protected void addSuperClass(final XtendClass xtendClass) {
   EObject xtendType = xtendClass;
   while (((!Objects.equal(xtendType, null)) && (xtendType instanceof XtendClass))) {
     {
       final XtendClass current = ((XtendClass) xtendType);
       EList<XAnnotation> _annotations = current.getAnnotations();
       final Function1<XAnnotation, Boolean> _function =
           new Function1<XAnnotation, Boolean>() {
             public Boolean apply(final XAnnotation it) {
               return Boolean.valueOf(JnarioJvmModelInferrer.this.hasExtendsAnnotation(it));
             }
           };
       Iterable<XAnnotation> _filter =
           IterableExtensions.<XAnnotation>filter(_annotations, _function);
       final Function1<XAnnotation, XTypeLiteral> _function_1 =
           new Function1<XAnnotation, XTypeLiteral>() {
             public XTypeLiteral apply(final XAnnotation it) {
               XExpression _value = it.getValue();
               return ((XTypeLiteral) _value);
             }
           };
       Iterable<XTypeLiteral> _map =
           IterableExtensions.<XAnnotation, XTypeLiteral>map(_filter, _function_1);
       for (final XTypeLiteral extendedType : _map) {
         boolean _and = false;
         EList<JvmTypeReference> _implements = current.getImplements();
         boolean _isEmpty = _implements.isEmpty();
         if (!_isEmpty) {
           _and = false;
         } else {
           JvmType _type = extendedType.getType();
           boolean _notEquals = (!Objects.equal(_type, null));
           _and = _notEquals;
         }
         if (_and) {
           JvmType _type_1 = extendedType.getType();
           JvmParameterizedTypeReference _createTypeRef =
               this._typeReferences.createTypeRef(_type_1);
           xtendClass.setExtends(_createTypeRef);
           return;
         }
       }
       EObject _eContainer = xtendType.eContainer();
       xtendType = _eContainer;
     }
   }
 }
Exemplo n.º 3
0
 protected RichString richString(String string) throws Exception {
   XtendClass clazz = clazz("class Foo { def foo() " + string + "}");
   XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
   return (RichString) function.getExpression();
 }