Package org.eclipse.xtend.lib.macro.declaration

Examples of org.eclipse.xtend.lib.macro.declaration.TypeReference


      return IterableExtensions.exists(_declaredMethods, _function);
    }
   
    public boolean hasSuperEquals(final ClassDeclaration cls) {
      boolean _xifexpression = false;
      TypeReference _newTypeReference = this.context.newTypeReference(cls);
      TypeReference _object = this.context.getObject();
      boolean _equals = _newTypeReference.equals(_object);
      if (_equals) {
        _xifexpression = false;
      } else {
        boolean _xifexpression_1 = false;
        boolean _hasEquals = this.hasEquals(cls);
        if (_hasEquals) {
          _xifexpression_1 = true;
        } else {
          TypeReference _extendedClass = cls.getExtendedClass();
          Type _type = _extendedClass.getType();
          _xifexpression_1 = this.hasSuperEquals(((ClassDeclaration) _type));
        }
        _xifexpression = _xifexpression_1;
      }
      return _xifexpression;
View Full Code Here


    public void addEquals(final MutableClassDeclaration cls, final Iterable<? extends FieldDeclaration> includedFields, final boolean includeSuper) {
      final Procedure1<MutableMethodDeclaration> _function = new Procedure1<MutableMethodDeclaration>() {
        public void apply(final MutableMethodDeclaration it) {
          Element _primarySourceElement = Util.this.context.getPrimarySourceElement(cls);
          Util.this.context.setPrimarySourceElement(it, _primarySourceElement);
          TypeReference _primitiveBoolean = Util.this.context.getPrimitiveBoolean();
          it.setReturnType(_primitiveBoolean);
          AnnotationReference _newAnnotationReference = Util.this.context.newAnnotationReference(Override.class);
          it.addAnnotation(_newAnnotationReference);
          AnnotationReference _newAnnotationReference_1 = Util.this.context.newAnnotationReference(Pure.class);
          it.addAnnotation(_newAnnotationReference_1);
          TypeReference _object = Util.this.context.getObject();
          it.addParameter("obj", _object);
          StringConcatenationClient _client = new StringConcatenationClient() {
            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
              _builder.append("if (this == obj)");
              _builder.newLine();
              _builder.append("  ");
              _builder.append("return true;");
              _builder.newLine();
              _builder.append("if (obj == null)");
              _builder.newLine();
              _builder.append("  ");
              _builder.append("return false;");
              _builder.newLine();
              _builder.append("if (getClass() != obj.getClass())");
              _builder.newLine();
              _builder.append("  ");
              _builder.append("return false;");
              _builder.newLine();
              {
                if (includeSuper) {
                  _builder.append("if (!super.equals(obj))");
                  _builder.newLine();
                  _builder.append("  ");
                  _builder.append("return false;");
                  _builder.newLine();
                }
              }
              TypeReference _newWildCardSelfTypeReference = Util.this.newWildCardSelfTypeReference(cls);
              _builder.append(_newWildCardSelfTypeReference, "");
              _builder.append(" other = (");
              TypeReference _newWildCardSelfTypeReference_1 = Util.this.newWildCardSelfTypeReference(cls);
              _builder.append(_newWildCardSelfTypeReference_1, "");
              _builder.append(") obj;");
              _builder.newLineIfNotEmpty();
              {
                for(final FieldDeclaration field : includedFields) {
View Full Code Here

   
    private TypeReference newWildCardSelfTypeReference(final ClassDeclaration cls) {
      Iterable<? extends TypeParameterDeclaration> _typeParameters = cls.getTypeParameters();
      final Function1<TypeParameterDeclaration, TypeReference> _function = new Function1<TypeParameterDeclaration, TypeReference>() {
        public TypeReference apply(final TypeParameterDeclaration it) {
          TypeReference _object = Util.this.context.getObject();
          return Util.this.context.newWildcardTypeReference(_object);
        }
      };
      Iterable<TypeReference> _map = IterableExtensions.map(_typeParameters, _function);
      return this.context.newTypeReference(cls, ((TypeReference[])Conversions.unwrapArray(_map, TypeReference.class)));
View Full Code Here

      return this.context.newTypeReference(cls, ((TypeReference[])Conversions.unwrapArray(_map, TypeReference.class)));
    }
   
    public String contributeToEquals(final FieldDeclaration it) {
      String _switchResult = null;
      TypeReference _type = it.getType();
      TypeReference _orObject = this.orObject(_type);
      String _name = _orObject.getName();
      boolean _matched = false;
      if (!_matched) {
        String _name_1 = Double.TYPE.getName();
        if (Objects.equal(_name, _name_1)) {
          _matched=true;
View Full Code Here

    public void addHashCode(final MutableClassDeclaration cls, final Iterable<? extends FieldDeclaration> includedFields, final boolean includeSuper) {
      final Procedure1<MutableMethodDeclaration> _function = new Procedure1<MutableMethodDeclaration>() {
        public void apply(final MutableMethodDeclaration it) {
          Element _primarySourceElement = Util.this.context.getPrimarySourceElement(cls);
          Util.this.context.setPrimarySourceElement(it, _primarySourceElement);
          TypeReference _primitiveInt = Util.this.context.getPrimitiveInt();
          it.setReturnType(_primitiveInt);
          AnnotationReference _newAnnotationReference = Util.this.context.newAnnotationReference(Override.class);
          it.addAnnotation(_newAnnotationReference);
          AnnotationReference _newAnnotationReference_1 = Util.this.context.newAnnotationReference(Pure.class);
          it.addAnnotation(_newAnnotationReference_1);
View Full Code Here

      cls.addMethod("hashCode", _function);
    }
   
    public String contributeToHashCode(final FieldDeclaration it) {
      String _switchResult = null;
      TypeReference _type = it.getType();
      TypeReference _orObject = this.orObject(_type);
      String _name = _orObject.getName();
      boolean _matched = false;
      if (!_matched) {
        String _name_1 = Double.TYPE.getName();
        if (Objects.equal(_name, _name_1)) {
          _matched=true;
View Full Code Here

      }
      return _switchResult;
    }
   
    private TypeReference orObject(final TypeReference ref) {
      TypeReference _xifexpression = null;
      boolean _tripleEquals = (ref == null);
      if (_tripleEquals) {
        _xifexpression = this.context.getObject();
      } else {
        _xifexpression = ref;
View Full Code Here

import org.eclipse.xtext.xbase.lib.StringExtensions;

@SuppressWarnings("all")
public class ListenerProcessor extends AbstractFieldProcessor {
  public void doTransform(final MutableFieldDeclaration field, @Extension final TransformationContext context) {
    TypeReference _type = field.getType();
    boolean _isPrimitive = _type.isPrimitive();
    if (_isPrimitive) {
      context.addError(field, "Primitives can\'t be used as event.");
    }
    Expression _initializer = field.getInitializer();
    boolean _tripleNotEquals = (_initializer != null);
    if (_tripleNotEquals) {
      context.addError(field, "Listener event dont\'t need an initializer");
    }
    final TypeReference eventType = field.getType();
    TypeReference _newTypeReference = context.newTypeReference(Procedure1.class, eventType);
    final TypeReference eventListType = context.getList(_newTypeReference);
    field.setType(eventListType);
    String _simpleName = field.getSimpleName();
    String _plus = (_simpleName + "Listener");
    field.setSimpleName(_plus);
    final TypeReference lamdaType = context.newTypeReference(Procedure1.class, eventType);
    TypeReference _list = context.getList(lamdaType);
    final TypeReference initFieldType = context.newTypeReference(Function0.class, _list);
    final TypeReference initListType = context.newTypeReference(ArrayList.class, lamdaType);
    final CompilationStrategy _function = new CompilationStrategy() {
      public CharSequence compile(final CompilationStrategy.CompilationContext it) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("new ");
        String _javaCode = it.toJavaCode(initFieldType);
View Full Code Here

          final Procedure1<MutableMethodDeclaration> _function = new Procedure1<MutableMethodDeclaration>() {
            public void apply(final MutableMethodDeclaration init) {
              boolean _isStatic = MethodMemoizer.this.method.isStatic();
              init.setStatic(_isStatic);
              init.setVisibility(Visibility.PRIVATE);
              TypeReference _wrappedReturnType = MethodMemoizer.this.wrappedReturnType();
              init.setReturnType(_wrappedReturnType);
              Iterable<? extends MutableParameterDeclaration> _parameters = MethodMemoizer.this.method.getParameters();
              final Procedure1<MutableParameterDeclaration> _function = new Procedure1<MutableParameterDeclaration>() {
                public void apply(final MutableParameterDeclaration it) {
                  String _simpleName = it.getSimpleName();
                  TypeReference _type = it.getType();
                  init.addParameter(_simpleName, _type);
                }
              };
              IterableExtensions.forEach(_parameters, _function);
              Iterable<? extends TypeReference> _exceptions = MethodMemoizer.this.method.getExceptions();
              init.setExceptions(((TypeReference[])Conversions.unwrapArray(_exceptions, TypeReference.class)));
              Expression _body = MethodMemoizer.this.method.getBody();
              init.setBody(_body);
            }
          };
          it.addMethod(_initMethodName, _function);
          String _cacheFieldName = MethodMemoizer.this.cacheFieldName();
          final Procedure1<MutableFieldDeclaration> _function_1 = new Procedure1<MutableFieldDeclaration>() {
            public void apply(final MutableFieldDeclaration it) {
              boolean _isStatic = MethodMemoizer.this.method.isStatic();
              it.setStatic(_isStatic);
              TypeReference _cacheFieldType = MethodMemoizer.this.cacheFieldType();
              it.setType(_cacheFieldType);
              final CompilationStrategy _function = new CompilationStrategy() {
                public CharSequence compile(final CompilationStrategy.CompilationContext it) {
                  return MethodMemoizer.this.cacheFieldInit(it);
                }
              };
              it.setInitializer(_function);
            }
          };
          it.addField(_cacheFieldName, _function_1);
        }
      };
      ObjectExtensions.<MutableTypeDeclaration>operator_doubleArrow(_declaringType, _function);
      final Procedure1<MutableMethodDeclaration> _function_1 = new Procedure1<MutableMethodDeclaration>() {
        public void apply(final MutableMethodDeclaration it) {
          final CompilationStrategy _function = new CompilationStrategy() {
            public CharSequence compile(final CompilationStrategy.CompilationContext it) {
              return MethodMemoizer.this.cacheCall(it);
            }
          };
          it.setBody(_function);
          TypeReference _wrappedReturnType = MethodMemoizer.this.wrappedReturnType();
          it.setReturnType(_wrappedReturnType);
        }
      };
      _xblockexpression = ObjectExtensions.<MutableMethodDeclaration>operator_doubleArrow(
        this.method, _function_1);
View Full Code Here

    }
    return _xblockexpression;
  }
 
  protected final TypeReference wrappedReturnType() {
    TypeReference _returnType = this.method.getReturnType();
    return _returnType.getWrapperIfPrimitive();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.xtend.lib.macro.declaration.TypeReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.