public String signature(JvmExecutable executable) { StringBuilder b = new StringBuilder(executable.getSimpleName()); b.append(parameters(executable)); if (executable instanceof JvmOperation) b.append(" : ").append(((JvmOperation) executable).getReturnType().getSimpleName()); return b.toString(); }
protected void resolveDispatchCaseTypes(JvmOperation dispatcher, List<JvmOperation> dispatchCases, LightweightTypeReference type, IFeatureScopeSession featureScopeSession) { if (InferredTypeIndicator.isInferred(dispatcher.getReturnType())) { InferredTypeIndicator.resolveTo(dispatcher.getReturnType(), toJavaCompliantTypeReference(type, featureScopeSession)); } for (JvmOperation dispatchCase : dispatchCases) { if (InferredTypeIndicator.isInferred(dispatchCase.getReturnType())) { InferredTypeIndicator.resolveTo(dispatchCase.getReturnType(), toJavaCompliantTypeReference(type, featureScopeSession)); } } }
private JvmType getTypeForAnnotationValue(JvmOperation value) { JvmType expectedType = value.getReturnType().getType(); if (expectedType instanceof JvmArrayType) { expectedType = ((JvmArrayType) expectedType).getComponentType(); } return expectedType; }
@Override public Boolean apply(final JvmOperation it) { return Boolean.valueOf((it.getSimpleName().startsWith("bind") && (IterableExtensions.<JvmTypeReference>head(((JvmParameterizedTypeReference) it.getReturnType()).getArguments()) != null))); } };
@Override public LightweightTypeReference getResolvedReturnType() { if (returnType != null) return returnType; return returnType = getResolvedReference(getDeclaration().getReturnType()); }
protected LightweightTypeReference _internalFindReferencedInvalidType(final JvmOperation operation) { final LightweightTypeReference unknownType = this.findUnknownType(operation.getReturnType()); if ((unknownType != null)) { return unknownType; } return this._internalFindReferencedInvalidType(((JvmExecutable) operation)); }
/** * @return the type returned by the fixture of the given interaction (may be null) */ public JvmTypeReference getReturnType(final InteractionType interaction) { MethodReference _defaultMethod = interaction.getDefaultMethod(); JvmOperation _operation = null; if (_defaultMethod!=null) { _operation=_defaultMethod.getOperation(); } JvmTypeReference _returnType = null; if (_operation!=null) { _returnType=_operation.getReturnType(); } return _returnType; }
@Override public TypeReference getReturnType() { return this.getCompilationUnit().toTypeReference(this.getDelegate().getReturnType()); } }
protected boolean isArrayOfAnnotations(final JvmAnnotationValue annotationValue) { final JvmTypeReference returnType = annotationValue.getOperation().getReturnType(); if ((returnType instanceof JvmGenericArrayTypeReference)) { JvmType _type = ((JvmGenericArrayTypeReference)returnType).getComponentType().getType(); return (_type instanceof JvmAnnotationType); } return false; }
protected void throwNotApplicable(final JvmAnnotationValue it, final String valueType) { JvmTypeReference _returnType = it.getOperation().getReturnType(); JvmType _type = null; if (_returnType!=null) { _type=_returnType.getType(); } String _isNotApplicableMessage = ConditionUtils.isNotApplicableMessage(valueType, this.getAnnotationValueTypeName(_type)); throw new IllegalArgumentException(_isNotApplicableMessage); }
@Override public TypeReference getType() { return this.getCompilationUnit().toTypeReference(this.getDelegate().getReturnType()); }
@Override public LightweightTypeReference enhance(ParameterizedTypeReference ref) { ref.addTypeArgument(owner.newReferenceTo(ArrayList.class, new TypeReferenceInitializer<ParameterizedTypeReference>(){ @Override public LightweightTypeReference enhance(ParameterizedTypeReference keyType) { keyType.addTypeArgument(owner.newWildcardExtendsObject()); return keyType; } })); ref.addTypeArgument(owner.toLightweightTypeReference(createOperation.getReturnType())); return ref; } });
protected Object translateAnnotationValue(final XExpression value, final String property) { final JvmType annotationType = this.getDelegate().getAnnotationType(); if ((annotationType instanceof JvmAnnotationType)) { final Function1<JvmOperation, Boolean> _function = (JvmOperation it) -> { String _simpleName = it.getSimpleName(); return Boolean.valueOf(Objects.equal(_simpleName, property)); }; final JvmOperation operation = IterableExtensions.<JvmOperation>findFirst(Iterables.<JvmOperation>filter(((JvmAnnotationType)annotationType).getMembers(), JvmOperation.class), _function); if ((operation != null)) { final boolean array = this.getCompilationUnit().getTypeReferences().isArray(operation.getReturnType()); return this.getCompilationUnit().translateAnnotationValue(value, operation.getReturnType(), array); } } return this.getCompilationUnit().translateAnnotationValue(value, null, false); }
@Check public void checkNonRawTypeInferred(XtendFunction function) { if (function.getReturnType() == null) { JvmOperation operation = associations.getDirectlyInferredOperation(function); // operation could have been removed by AA, thus the resource is possibly null if (operation != null && operation.eResource() != null) { JvmTypeReference returnType = operation.getReturnType(); validateInferredType(returnType, function, "The inferred return type ", XTEND_FUNCTION__NAME); } } }
protected LightweightTypeReference getClosureOperationReturnType(LightweightTypeReference closureType, JvmOperation operation) { ITypeReferenceOwner owner = newTypeReferenceOwner(operation); Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> mapping = new DeclaratorTypeArgumentCollector().getTypeParameterMapping(closureType); LightweightTypeReference parameterType = owner.toLightweightTypeReference(operation.getReturnType()); return new StandardTypeParameterSubstitutor(mapping, owner).substitute(parameterType); }
@Override public Object getDefaultValue() { return this.getCompilationUnit().translateAnnotationValue(this.getDelegate().getDefaultValue(), this.getCompilationUnit().getTypeReferences().isArray(this.getDelegate().getReturnType())); }
@Override protected ITypeComputationResult createNoTypeResult() { JvmOperation operation = (JvmOperation) getMember(); LightweightTypeReference expectedType = ((LogicalContainerAwareReentrantTypeResolver)getResolver()).getReturnTypeOfOverriddenOperation(operation, resolvedTypes, getFeatureScopeSession()); if (expectedType != null) { InferredTypeIndicator.resolveTo(operation.getReturnType(), expectedType.toJavaCompliantTypeReference()); } return new NoTypeResult(getMember(), resolvedTypes.getReferenceOwner()); } }
@Override /* @Nullable */ protected LightweightTypeReference getExpectedType() { JvmOperation operation = (JvmOperation) getMember(); LightweightTypeReference expectedType = ((LogicalContainerAwareReentrantTypeResolver)getResolver()).getReturnTypeOfOverriddenOperation(operation, resolvedTypes, getFeatureScopeSession()); if (expectedType != null) { InferredTypeIndicator.resolveTo(operation.getReturnType(), expectedType.toJavaCompliantTypeReference()); return expectedType; } return getResolvedTypes().getExpectedTypeForAssociatedExpression(getMember(), getNonNullRootExpression()); }
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); } }
public void generateAnnotationMethod(final JvmOperation it, final ITreeAppendable appendable, final GeneratorConfig config) { appendable.increaseIndentation().newLine(); appendable.openScope(); this.generateJavaDoc(it, appendable, config); final ITreeAppendable tracedAppendable = appendable.trace(it); this.generateAnnotations(it.getAnnotations(), tracedAppendable, true, config); this.generateModifier(it, tracedAppendable, config); this._errorSafeExtensions.serializeSafely(it.getReturnType(), "Object", tracedAppendable); tracedAppendable.append(" "); this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(this.makeJavaIdentifier(it.getSimpleName())); tracedAppendable.append("()"); this.generateDefaultExpression(it, tracedAppendable, config); tracedAppendable.append(";"); appendable.decreaseIndentation(); appendable.closeScope(); }