protected void appendSyntheticDispatchMethods(XtendTypeDeclaration source, final JvmGenericType target) { ListMultimap<DispatchHelper.DispatchSignature, JvmOperation> methods = dispatchHelper.getDeclaredOrEnhancedDispatchMethods(target); for (DispatchHelper.DispatchSignature signature : methods.keySet()) { List<JvmOperation> operations = methods.get(signature); Iterable<JvmOperation> localOperations = Iterables.filter(operations, new Predicate<JvmOperation>() { @Override public boolean apply(JvmOperation input) { return target == input.eContainer(); } }); JvmOperation operation = deriveGenericDispatchOperationSignature(localOperations, target); if (operation != null) { dispatchHelper.markAsDispatcherFunction(operation); operation.setSimpleName(signature.getSimpleName()); operation.setReturnType(jvmTypesBuilder.inferredType()); } } }
@Override public MutableAnnotationTypeElementDeclaration addAnnotationTypeElement(final String name, final Procedure1<MutableAnnotationTypeElementDeclaration> initializer) { this.checkMutable(); ConditionUtils.checkJavaIdentifier(name, "name"); Preconditions.checkArgument((initializer != null), "initializer cannot be null"); final JvmOperation newAnnotationElement = TypesFactory.eINSTANCE.createJvmOperation(); newAnnotationElement.setSimpleName(name); newAnnotationElement.setVisibility(JvmVisibility.PUBLIC); this.getDelegate().getMembers().add(newAnnotationElement); MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(newAnnotationElement); final MutableAnnotationTypeElementDeclaration mutableAnnotationTypeElementDeclaration = ((MutableAnnotationTypeElementDeclaration) _memberDeclaration); initializer.apply(mutableAnnotationTypeElementDeclaration); return mutableAnnotationTypeElementDeclaration; }
/** * Creates a public method with the given name and the given return type and associates it with the given * sourceElement. * * @param sourceElement * the sourceElement the method should be associated with. * @param name * the simple name of the method to be created. * @param returnType * the return type of the created method. * @param initializer * the initializer to apply on the created method. If <code>null</code>, the method won't be initialized. * * @return a result representing a Java method with the given name, <code>null</code> if sourceElement or name are <code>null</code>. */ /* @Nullable */ public JvmOperation toMethod(/* @Nullable */ EObject sourceElement, /* @Nullable */ String name, /* @Nullable */ JvmTypeReference returnType, /* @Nullable */ Procedure1<? super JvmOperation> initializer) { if(sourceElement == null || name == null) return null; JvmOperation result = typesFactory.createJvmOperation(); result.setSimpleName(name); result.setVisibility(JvmVisibility.PUBLIC); result.setReturnType(cloneWithProxies(returnType)); associate(sourceElement, result); return initializeSafely(result, initializer); }
public MutableMethodDeclaration addMethod(final String name, final Procedure1<MutableMethodDeclaration> initializer) { this.checkMutable(); ConditionUtils.checkJavaIdentifier(name, "name"); Preconditions.checkArgument((initializer != null), "initializer cannot be null"); final JvmOperation newMethod = TypesFactory.eINSTANCE.createJvmOperation(); newMethod.setVisibility(JvmVisibility.PUBLIC); newMethod.setSimpleName(name); newMethod.setReturnType(this.getCompilationUnit().toJvmTypeReference(this.getCompilationUnit().getTypeReferenceProvider().getPrimitiveVoid())); this.getDelegate().getMembers().add(newMethod); MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(newMethod); final MutableMethodDeclaration mutableMethodDeclaration = ((MutableMethodDeclaration) _memberDeclaration); initializer.apply(mutableMethodDeclaration); return mutableMethodDeclaration; }
values.setVisibility(JvmVisibility.PUBLIC); values.setStatic(true); values.setSimpleName("values"); values.setReturnType(references.createArrayType(references.createTypeRef(element))); typeExtensions.setSynthetic(values, true); valueOf.setVisibility(JvmVisibility.PUBLIC); valueOf.setStatic(true); valueOf.setSimpleName("valueOf"); valueOf.setReturnType(references.createTypeRef(element)); JvmFormalParameter param = typesFactory.createJvmFormalParameter();
@Override public MutableMethodDeclaration addMethod(final String name, final Procedure1<MutableMethodDeclaration> initializer) { this.checkMutable(); ConditionUtils.checkJavaIdentifier(name, "name"); Preconditions.checkArgument((initializer != null), "initializer cannot be null"); final JvmOperation newMethod = TypesFactory.eINSTANCE.createJvmOperation(); newMethod.setVisibility(JvmVisibility.PUBLIC); newMethod.setSimpleName(name); newMethod.setReturnType(this.getCompilationUnit().toJvmTypeReference(this.getCompilationUnit().getTypeReferenceProvider().getPrimitiveVoid())); newMethod.setAbstract(true); this.getDelegate().getMembers().add(newMethod); MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(newMethod); final MutableMethodDeclaration mutableMethodDeclaration = ((MutableMethodDeclaration) _memberDeclaration); initializer.apply(mutableMethodDeclaration); return mutableMethodDeclaration; }
result.setVisibility(JvmVisibility.PUBLIC); result.setReturnType(references.getTypeForName(Void.TYPE,sourceElement)); result.setSimpleName("set" + Strings.toFirstUpper(propertyName)); result.getParameters().add(toParameter(sourceElement, propertyName, typeRef)); setBody(result, new Procedures.Procedure1<ITreeAppendable>() {
result.setVisibility(JvmVisibility.PUBLIC); String prefix = (isPrimitiveBoolean(typeRef) ? "is" : "get"); result.setSimpleName(prefix + Strings.toFirstUpper(propertyName)); result.setReturnType(cloneWithProxies(typeRef)); setBody(result, new Procedures.Procedure1<ITreeAppendable>() {
initializer.setSimpleName(CREATE_INITIALIZER_PREFIX + source.getName()); initializer.setVisibility(JvmVisibility.PRIVATE); initializer.setReturnType(typeReferences.getTypeForName(Void.TYPE, source));
newOp.setSimpleName(operation.getSimpleName()); newOp.setStrictFloatingPoint(operation.isStrictFloatingPoint());
operation.setSimpleName(sourceName); setVisibility(operation, source); operation.setStrictFloatingPoint(source.isStrictFloatingPoint()); operation2.setSimpleName(operation.getSimpleName()); operation2.setVisibility(operation.getVisibility()); operation2.setVarArgs(operation.isVarArgs());
container.getMembers().add(staticConstructor); this.associator.associatePrimary(source, staticConstructor); staticConstructor.setSimpleName(Utils.STATIC_CONSTRUCTOR_NAME); staticConstructor.setVisibility(JvmVisibility.PRIVATE); staticConstructor.setStatic(true);
operation.setVisibility(JvmVisibility.PRIVATE); operation.setStatic(false); operation.setSimpleName(behName); operation.setReturnType(this.typeBuilder.cloneWithProxies(voidType)); container.getMembers().add(operation);
operation.setVisibility(JvmVisibility.PRIVATE); operation.setReturnType(cloneWithTypeParametersAndProxies(capacityType, operation)); operation.setSimpleName(methodName);
JvmOperation operation = typesFactory.createJvmOperation(); associator.associatePrimary(member, operation); operation.setSimpleName(field.getName()); JvmTypeReference returnType = null; XExpression initialValue = field.getInitialValue();
sourceName = "_" + sourceName; operation.setSimpleName(sourceName); operation.setVisibility(visibility); operation.setStatic(source.isStatic());
bodyOperation.setVisibility(JvmVisibility.PRIVATE); bodyOperation.setStatic(false); bodyOperation.setSimpleName(bodyMethodName); bodyOperation.setReturnType(voidType); guardOperation.setVisibility(JvmVisibility.PRIVATE); guardOperation.setStatic(false); guardOperation.setSimpleName(guardMethodName); guardOperation.setReturnType(this._typeReferenceBuilder.typeRef(Boolean.TYPE));