public void setType(final TypeReference type) { this.checkMutable(); Preconditions.checkArgument((type != null), "returnType cannot be null"); this.getDelegate().setReturnType(this.getCompilationUnit().toJvmTypeReference(type)); } }
@Override public void setReturnType(final TypeReference type) { this.checkMutable(); Preconditions.checkArgument((type != null), "returnType cannot be null"); this.getDelegate().setReturnType(this.getCompilationUnit().toJvmTypeReference(type)); }
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()); } } }
returnType = method.getReturnType(); result.setReturnType(createTypeReference(returnType)); Type[] exceptionTypes; try {
@Override public void apply(final JvmOperation it) { JvmTypeReference _typeRef = PatternMatchProcessorClassInferrer.this.builder.typeRef(Void.TYPE); it.setReturnType(_typeRef); CharSequence _javadocProcessMethod = PatternMatchProcessorClassInferrer.this._javadocInferrer.javadocProcessMethod(pattern); String _string = _javadocProcessMethod.toString(); PatternMatchProcessorClassInferrer.this._eMFJvmTypesBuilder.setDocumentation(it, _string); it.setAbstract(true); EList<Variable> _parameters = pattern.getParameters(); for (final Variable parameter : _parameters) { EList<JvmFormalParameter> _parameters_1 = it.getParameters(); String _parameterName = PatternMatchProcessorClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.parameterName(parameter); JvmTypeReference _calculateType = PatternMatchProcessorClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.calculateType(parameter); JvmFormalParameter _parameter = PatternMatchProcessorClassInferrer.this._eMFJvmTypesBuilder.toParameter(parameter, _parameterName, _calculateType); PatternMatchProcessorClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter); } } };
/** * 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; }
@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; }
values.setStatic(true); values.setSimpleName("values"); values.setReturnType(references.createArrayType(references.createTypeRef(element))); typeExtensions.setSynthetic(values, true); if (primarySourceElement != null) { valueOf.setStatic(true); valueOf.setSimpleName("valueOf"); valueOf.setReturnType(references.createTypeRef(element)); JvmFormalParameter param = typesFactory.createJvmFormalParameter(); param.setName("name");
@Override public void apply(final JvmOperation it) { JvmTypeReference _typeRef = PatternMatchClassInferrer.this.builder.typeRef(Void.TYPE); it.setReturnType(_typeRef); EList<JvmFormalParameter> _parameters = it.getParameters(); String _parameterName = PatternMatchClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.parameterName(variable); JvmTypeReference _calculateType = PatternMatchClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.calculateType(variable); JvmFormalParameter _parameter = PatternMatchClassInferrer.this._eMFJvmTypesBuilder.toParameter(variable, _parameterName, _calculateType); PatternMatchClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("if (!isMutable()) throw new java.lang.UnsupportedOperationException();"); _builder.newLine(); _builder.append("this."); String _fieldName = PatternMatchClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.fieldName(variable); _builder.append(_fieldName, ""); _builder.append(" = "); String _parameterName = PatternMatchClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.parameterName(variable); _builder.append(_parameterName, ""); _builder.append(";"); _builder.newLineIfNotEmpty(); } }; PatternMatchClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
JvmOperation result = typesFactory.createJvmOperation(); result.setVisibility(JvmVisibility.PUBLIC); result.setReturnType(references.getTypeForName(Void.TYPE,sourceElement)); result.setSimpleName("set" + Strings.toFirstUpper(propertyName)); result.getParameters().add(toParameter(sourceElement, propertyName, typeRef));
protected void _doPrepare(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmOperation operation, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) { StackedResolvedTypes childResolvedTypes = declareTypeParameters(resolvedTypes, operation, resolvedTypesByContext); JvmTypeReference knownType = operation.getReturnType(); if (InferredTypeIndicator.isInferred(knownType)) { XComputedTypeReference casted = (XComputedTypeReference) knownType; JvmTypeReference reference = createComputedTypeReference( resolvedTypesByContext, childResolvedTypes, featureScopeSession, operation, (InferredTypeIndicator) casted.getTypeProvider(), true); casted.setEquivalent(reference); } else if (knownType != null) { LightweightTypeReference lightweightReference = childResolvedTypes.getReferenceOwner().toLightweightTypeReference(knownType); childResolvedTypes.setType(operation, lightweightReference); } else { JvmTypeReference reference = createComputedTypeReference(resolvedTypesByContext, childResolvedTypes, featureScopeSession, operation, null, true); operation.setReturnType(reference); } }
String prefix = (isPrimitiveBoolean(typeRef) ? "is" : "get"); result.setSimpleName(prefix + Strings.toFirstUpper(propertyName)); result.setReturnType(cloneWithProxies(typeRef)); setBody(result, new Procedures.Procedure1<ITreeAppendable>() { @Override
@Override public void apply(final JvmOperation it) { JvmTypeReference _typeRef = PatternMatchProcessorClassInferrer.this.builder.typeRef(Void.TYPE); it.setReturnType(_typeRef); EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatchProcessorClassInferrer.this.annBuilder.annotationRef(Override.class);
initializer.setSimpleName(CREATE_INITIALIZER_PREFIX + source.getName()); initializer.setVisibility(JvmVisibility.PRIVATE); initializer.setReturnType(typeReferences.getTypeForName(Void.TYPE, source)); for (JvmTypeReference exception : source.getExceptions()) { initializer.getExceptions().add(jvmTypesBuilder.cloneWithProxies(exception));
@Override public void apply(final JvmOperation it) { JvmTypeReference _typeRef = PatternMatcherClassInferrer.this.builder.typeRef(Void.TYPE); it.setReturnType(_typeRef); CharSequence _javadocForEachMatchMethod = PatternMatcherClassInferrer.this._javadocInferrer.javadocForEachMatchMethod(pattern); String _string = _javadocForEachMatchMethod.toString();
newOp.setReturnType(cloneWithTypeParametersAndProxies(operation.getReturnType(), newOp));
@Override public void apply(final JvmOperation it) { JvmTypeReference _typeRef = PatternMatchClassInferrer.this.builder.typeRef(Boolean.TYPE); it.setReturnType(_typeRef); EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatchClassInferrer.this.annBuilder.annotationRef(Override.class);
returnType = jvmTypesBuilder.inferredType(initialValue); operation.setReturnType(returnType); if (initialValue != null) { JvmAnnotationValue jvmAnnotationValue = jvmTypesBuilder.toJvmAnnotationValue(initialValue);
operation.setReturnType(returnType); copyAndFixTypeParameters(source.getTypeParameters(), operation); for (JvmTypeReference exception : source.getExceptions()) {