/** * Creates and returns a constructor with the given simple name associated to the given source element. By default * the constructor will have an empty body and no arguments, hence the Java default constructor. * * @param sourceElement * the sourceElement the constructor should be associated with. * @param initializer * the initializer to apply on the created constructor. If <code>null</code>, the method won't be initialized. * * @return a result representing a Java constructor with the given name, <code>null</code> if sourceElement is <code>null</code>. */ /* @Nullable */ public JvmConstructor toConstructor(/* @Nullable */ EObject sourceElement, /* @Nullable */ Procedure1<? super JvmConstructor> initializer) { if(sourceElement == null) return null; JvmConstructor constructor = typesFactory.createJvmConstructor(); constructor.setVisibility(JvmVisibility.PUBLIC); associate(sourceElement, constructor); return initializeSafely(constructor, initializer); }
protected JvmConstructor inferAnonymousClassConstructor(AnonymousClass anonymousClass, JvmGenericType inferredLocalClass) { XConstructorCall constructorCall = anonymousClass.getConstructorCall(); JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor(); inferredLocalClass.getMembers().add(constructor); associator.associatePrimary(constructorCall, constructor); constructor.setVisibility(JvmVisibility.DEFAULT); constructor.setSimpleName(inferredLocalClass.getSimpleName()); return constructor; }
protected void addDefaultConstructor(XtendClass source, JvmGenericType target) { for (XtendMember member : source.getMembers()) { if (member instanceof XtendConstructor) return; } JvmConstructor constructor = typesFactory.createJvmConstructor(); target.getMembers().add(constructor); associator.associate(source, constructor); constructor.setSimpleName(source.getName()); constructor.setVisibility(JvmVisibility.PUBLIC); typeExtensions.setSynthetic(constructor, true); }
protected JvmConstructor createConstructor(Constructor<?> constructor) { JvmConstructor result = TypesFactory.eINSTANCE.createJvmConstructor(); Class<?> declaringClass = constructor.getDeclaringClass(); int offset = 0;
protected JvmConstructor createConstructor(Constructor<?> constructor) { JvmConstructor result = TypesFactory.eINSTANCE.createJvmConstructor(); Class<?> declaringClass = constructor.getDeclaringClass(); int offset = 0;
protected void completeJvmGenericType(JvmGenericType element) { // if no super type add Object ensureSuperTypeObject(element); addAnnotations(element); if (!element.isInterface()) { // if no constructors have been added, add a default constructor if (isEmpty(element.getDeclaredConstructors())) { JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor(); constructor.setSimpleName(element.getSimpleName()); constructor.setVisibility(JvmVisibility.PUBLIC); typeExtensions.setSynthetic(constructor, true); EObject primarySourceElement = associations.getPrimarySourceElement(element); if (primarySourceElement != null) { associator.associate(primarySourceElement, constructor); } element.getMembers().add(constructor); } } }
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; }
final StringBuilder fqName; if (isConstructor(name)) { result = TypesFactory.eINSTANCE.createJvmConstructor(); String declaratorIdentifier = declarator.getIdentifier(); String simpleName = declarator.getSimpleName();
protected JvmConstructor inferAnonymousClassConstructor(AnonymousClass anonymousClass, JvmGenericType inferredLocalClass, JvmConstructor superConstructor, boolean visible) { JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor(); inferredLocalClass.getMembers().add(constructor); associator.associatePrimary(anonymousClass.getConstructorCall(), constructor);
protected void transform(XtendConstructor source, JvmGenericType container) { JvmConstructor constructor = typesFactory.createJvmConstructor(); container.getMembers().add(constructor); associator.associatePrimary(source, constructor); JvmVisibility visibility = source.getVisibility(); constructor.setSimpleName(container.getSimpleName()); constructor.setVisibility(visibility); for (XtendParameter parameter : source.getParameters()) { translateParameter(constructor, parameter); } copyAndFixTypeParameters(source.getTypeParameters(), constructor); for (JvmTypeReference exception : source.getExceptions()) { constructor.getExceptions().add(jvmTypesBuilder.cloneWithProxies(exception)); } translateAnnotationsTo(source.getAnnotations(), constructor); setBody(constructor, source.getExpression()); jvmTypesBuilder.copyDocumentationTo(source, constructor); }
final JvmConstructor constructor = this.typesFactory.createJvmConstructor(); constructor.setVisibility(JvmVisibility.PUBLIC); innerType.getMembers().add(constructor);
final JvmConstructor constructor = this.typesFactory.createJvmConstructor(); container.getMembers().add(constructor); this.associator.associatePrimary(source, constructor); final List<InferredStandardParameter> otherSignature = entry.getValue(); final JvmConstructor constructor2 = SARLJvmModelInferrer.this.typesFactory.createJvmConstructor(); container.getMembers().add(constructor2); copyAndCleanDocumentationTo(source, constructor2);
if (createdConstructors.add(pair.getValue())) { final JvmConstructor constructor = pair.getKey(); final JvmConstructor newCons = this.typesFactory.createJvmConstructor(); newCons.setDeprecated(constructor.isDeprecated()); newCons.setSimpleName(target.getSimpleName());