Java源码示例:org.eclipse.xtend.lib.macro.declaration.MutableConstructorDeclaration

示例1
public void addFinalFieldsConstructor(final MutableClassDeclaration it) {
  boolean _isEmpty = this.getFinalFieldsConstructorArgumentTypes(it).isEmpty();
  if (_isEmpty) {
    final AnnotationReference anno = it.findAnnotation(this.context.findTypeGlobally(FinalFieldsConstructor.class));
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("There are no final fields, this annotation has no effect");
    this.context.addWarning(anno, _builder.toString());
    return;
  }
  boolean _hasFinalFieldsConstructor = this.hasFinalFieldsConstructor(it);
  if (_hasFinalFieldsConstructor) {
    this.context.addError(it, this.getConstructorAlreadyExistsMessage(it));
    return;
  }
  final Procedure1<MutableConstructorDeclaration> _function = (MutableConstructorDeclaration it_1) -> {
    this.context.setPrimarySourceElement(it_1, this.context.getPrimarySourceElement(it_1.getDeclaringType()));
    this.makeFinalFieldsConstructor(it_1);
  };
  it.addConstructor(_function);
}
 
示例2
public MutableConstructorDeclaration addConstructor(final Procedure1<MutableConstructorDeclaration> initializer) {
  this.checkMutable();
  Preconditions.checkArgument((initializer != null), "initializer cannot be null");
  final Function1<JvmConstructor, Boolean> _function = (JvmConstructor it) -> {
    return Boolean.valueOf(this.getCompilationUnit().getTypeExtensions().isSingleSyntheticDefaultConstructor(it));
  };
  final JvmConstructor constructor = IterableExtensions.<JvmConstructor>findFirst(Iterables.<JvmConstructor>filter(this.getDelegate().getMembers(), JvmConstructor.class), _function);
  if ((constructor != null)) {
    EcoreUtil.remove(constructor);
  }
  final JvmConstructor newConstructor = TypesFactory.eINSTANCE.createJvmConstructor();
  newConstructor.setVisibility(JvmVisibility.PUBLIC);
  newConstructor.setSimpleName(this.getSimpleName());
  this.getDelegate().getMembers().add(newConstructor);
  MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(newConstructor);
  final MutableConstructorDeclaration mutableConstructorDeclaration = ((MutableConstructorDeclaration) _memberDeclaration);
  initializer.apply(mutableConstructorDeclaration);
  return mutableConstructorDeclaration;
}
 
示例3
public boolean hasFinalFieldsConstructor(final MutableTypeDeclaration cls) {
  boolean _xblockexpression = false;
  {
    final ArrayList<TypeReference> expectedTypes = this.getFinalFieldsConstructorArgumentTypes(cls);
    final Function1<MutableConstructorDeclaration, Boolean> _function = (MutableConstructorDeclaration it) -> {
      final Function1<MutableParameterDeclaration, TypeReference> _function_1 = (MutableParameterDeclaration it_1) -> {
        return it_1.getType();
      };
      List<TypeReference> _list = IterableExtensions.<TypeReference>toList(IterableExtensions.map(it.getParameters(), _function_1));
      return Boolean.valueOf(Objects.equal(_list, expectedTypes));
    };
    _xblockexpression = IterableExtensions.exists(cls.getDeclaredConstructors(), _function);
  }
  return _xblockexpression;
}
 
示例4
public void transform(final MutableTypeParameterDeclarator it, final TransformationContext context) {
  if (it instanceof MutableConstructorDeclaration) {
    _transform((MutableConstructorDeclaration)it, context);
    return;
  } else if (it instanceof MutableClassDeclaration) {
    _transform((MutableClassDeclaration)it, context);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, context).toString());
  }
}
 
示例5
@Override
public MutableConstructorDeclaration addConstructor(final Procedure1<MutableConstructorDeclaration> initializer) {
  String _simpleName = this.getSimpleName();
  String _plus = ("The annotation \'" + _simpleName);
  String _plus_1 = (_plus + "\' cannot declare any constructors.");
  throw new UnsupportedOperationException(_plus_1);
}
 
示例6
@Override
public MutableConstructorDeclaration addConstructor(final Procedure1<MutableConstructorDeclaration> initializer) {
  String _simpleName = this.getSimpleName();
  String _plus = ("The interface \'" + _simpleName);
  String _plus_1 = (_plus + "\' cannot declare any constructors.");
  throw new UnsupportedOperationException(_plus_1);
}
 
示例7
public void doTransform(List<? extends MutableConstructorDeclaration> annotatedConstructors, @Extension TransformationContext context) {
	for (MutableConstructorDeclaration annotatedConstructor : annotatedConstructors) {
		doTransform(annotatedConstructor, context);
	}
}
 
示例8
protected void _transform(final MutableConstructorDeclaration it, @Extension final TransformationContext context) {
  @Extension
  final FinalFieldsConstructorProcessor.Util util = new FinalFieldsConstructorProcessor.Util(context);
  util.makeFinalFieldsConstructor(it);
}
 
示例9
@Override
public MutableConstructorDeclaration findDeclaredConstructor(final TypeReference... parameterTypes) {
  ConstructorDeclaration _findDeclaredConstructor = super.findDeclaredConstructor(parameterTypes);
  return ((MutableConstructorDeclaration) _findDeclaredConstructor);
}
 
示例10
@Override
public Iterable<? extends MutableConstructorDeclaration> getDeclaredConstructors() {
  Iterable<? extends ConstructorDeclaration> _declaredConstructors = super.getDeclaredConstructors();
  return ((Iterable<? extends MutableConstructorDeclaration>) _declaredConstructors);
}
 
示例11
@Override
public MutableConstructorDeclaration findDeclaredConstructor(final TypeReference... parameterTypes) {
  ConstructorDeclaration _findDeclaredConstructor = super.findDeclaredConstructor(parameterTypes);
  return ((MutableConstructorDeclaration) _findDeclaredConstructor);
}
 
示例12
@Override
public Iterable<? extends MutableConstructorDeclaration> getDeclaredConstructors() {
  Iterable<? extends ConstructorDeclaration> _declaredConstructors = super.getDeclaredConstructors();
  return ((Iterable<? extends MutableConstructorDeclaration>) _declaredConstructors);
}
 
示例13
@Override
public MutableConstructorDeclaration findDeclaredConstructor(final TypeReference... parameterTypes) {
  ConstructorDeclaration _findDeclaredConstructor = super.findDeclaredConstructor(parameterTypes);
  return ((MutableConstructorDeclaration) _findDeclaredConstructor);
}
 
示例14
@Override
public Iterable<? extends MutableConstructorDeclaration> getDeclaredConstructors() {
  Iterable<? extends ConstructorDeclaration> _declaredConstructors = super.getDeclaredConstructors();
  return ((Iterable<? extends MutableConstructorDeclaration>) _declaredConstructors);
}
 
示例15
@Override
public MutableConstructorDeclaration findDeclaredConstructor(final TypeReference... parameterTypes) {
  ConstructorDeclaration _findDeclaredConstructor = super.findDeclaredConstructor(parameterTypes);
  return ((MutableConstructorDeclaration) _findDeclaredConstructor);
}
 
示例16
@Override
public Iterable<? extends MutableConstructorDeclaration> getDeclaredConstructors() {
  Iterable<? extends ConstructorDeclaration> _declaredConstructors = super.getDeclaredConstructors();
  return ((Iterable<? extends MutableConstructorDeclaration>) _declaredConstructors);
}
 
示例17
/**
 * @param annotatedConstructor a mutable method representation annotated with the annotation this processor is responsible for.
 * @param context
 */
public void doTransform(MutableConstructorDeclaration annotatedConstructor, @Extension TransformationContext context) {}