protected LightweightTypeReference toLightweightTypeReference(JvmFormalParameter parameter) { JvmTypeReference parameterType = parameter.getParameterType(); if (parameterType == null) { return null; } LightweightTypeReference result = owner.toLightweightTypeReference(parameterType); return result; }
@Override public LightweightTypeReference toLightweightTypeReference(JvmTypeReference reference) { return getReferenceOwner().toLightweightTypeReference(reference); } }
protected ResolvedTypes pushExpectedExceptions(JvmExecutable exceptionDeclarator) { List<JvmTypeReference> executablesExceptions = exceptionDeclarator.getExceptions(); if (executablesExceptions.isEmpty()) return this; List<LightweightTypeReference> exceptions = Lists.newArrayListWithCapacity(executablesExceptions.size()); for(JvmTypeReference exception: executablesExceptions) { exceptions.add(getReferenceOwner().toLightweightTypeReference(exception)); } return pushExpectedExceptions(exceptions); }
protected List<LightweightTypeReference> getSyntacticTypeArguments() { List<LightweightTypeReference> result = Lists.newArrayList(); List<JvmTypeReference> typeArguments = getPlainSyntacticTypeArguments(); ITypeReferenceOwner referenceOwner = getState().getReferenceOwner(); for(int i = 0, size = typeArguments.size(); i < size; i++) { LightweightTypeReference typeArgument = referenceOwner.toLightweightTypeReference(typeArguments.get(i)); result.add(typeArgument); } return result; }
@Override public List<LightweightTypeReference> getTypeArguments() { XAbstractFeatureCall featureCall = getFeatureCall(); List<JvmTypeReference> typeArguments = featureCall.getTypeArguments(); if (typeArguments.isEmpty()) return Collections.emptyList(); List<LightweightTypeReference> result = Lists.newArrayList(); for(JvmTypeReference typeArgument: typeArguments) { result.add(getState().getReferenceOwner().toLightweightTypeReference(typeArgument)); } return result; }
protected LightweightTypeReference getDeclaredParameterType(JvmFormalParameter declaredParam, final ITypeComputationState state) { JvmTypeReference parameterType = declaredParam.getParameterType(); if (parameterType == null) return null; return state.getReferenceOwner().toLightweightTypeReference(parameterType); }
public ITreeAppendable compileAsJavaExpression(XExpression obj, ITreeAppendable parentAppendable, JvmTypeReference expectedType) { LightweightTypeReference converted = null; if (expectedType != null) { converted = newTypeReferenceOwner(obj).toLightweightTypeReference(expectedType); } return compileAsJavaExpression(obj, parentAppendable, converted); }
public ITreeAppendable compile(XExpression obj, ITreeAppendable parentAppendable, /* @Nullable */ JvmTypeReference expectedReturnType, /* @Nullable */ Set<JvmTypeReference> declaredExceptions) { LightweightTypeReference converted = null; if (expectedReturnType != null) { converted = newTypeReferenceOwner(obj).toLightweightTypeReference(expectedReturnType); } return compile(obj, parentAppendable, converted, declaredExceptions); }
@Override public List<LightweightTypeReference> getTypeArguments() { XAbstractFeatureCall featureCall = getFeatureCall(); List<JvmTypeReference> typeArguments = featureCall.getTypeArguments(); if (typeArguments.isEmpty()) return Collections.emptyList(); List<LightweightTypeReference> result = Lists.newArrayList(); for(JvmTypeReference typeArgument: typeArguments) { result.add(getState().getReferenceOwner().toLightweightTypeReference(typeArgument)); } return result; }
/** * @see #findDeclaredType(String, ITypeReferenceOwner) * @since 2.14 */ protected LightweightTypeReference getTypeForName(String clazzName, ITypeComputationState state) { JvmType type = findDeclaredType(clazzName, state); ITypeReferenceOwner owner = state.getReferenceOwner(); if (type == null) { return owner.newUnknownTypeReference(clazzName); } return owner.toLightweightTypeReference(type); }
/** * Returns the resolved features that are defined in the given <code>type</code> and its supertypes. * Considers private methods of super types, too. * @param type the type. Has to be contained in a resource. * @return the resolved features. */ public ResolvedFeatures getResolvedFeatures(JvmDeclaredType type) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type.eResource().getResourceSet()); LightweightTypeReference contextType = owner.toLightweightTypeReference(type); return getResolvedFeatures(contextType); }
/** * Returns the resolved features targeting a specific Java version in order to support new language features. */ public ResolvedFeatures getResolvedFeatures(JvmDeclaredType type, JavaVersion targetVersion) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type.eResource().getResourceSet()); LightweightTypeReference contextType = owner.toLightweightTypeReference(type); return getResolvedFeatures(contextType, targetVersion); }
/** * Returns the resolved features targeting a specific Java version in order to support new language features. */ public ResolvedFeatures getResolvedFeatures(JvmTypeReference contextType, JavaVersion targetVersion) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, contextType.eResource().getResourceSet()); return getResolvedFeatures(owner.toLightweightTypeReference(contextType), targetVersion); }
public JvmTypeReference resolveMultiType(JvmTypeReference reference, EObject context) { ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, context.eResource().getResourceSet()); return owner.toLightweightTypeReference(reference).toJavaCompliantTypeReference(); } }
@SuppressWarnings("unused") protected void _doPrepare(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmConstructor constructor, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) { StackedResolvedTypes childResolvedTypes = declareTypeParameters(resolvedTypes, constructor, resolvedTypesByContext); JvmDeclaredType producedType = constructor.getDeclaringType(); LightweightTypeReference lightweightReference = childResolvedTypes.getReferenceOwner().toLightweightTypeReference(producedType); childResolvedTypes.setType(constructor, lightweightReference); }
protected boolean isMatchesSignature(JvmFormalParameter parameter, JvmFormalParameter candidateParameter, TypeParameterSubstitutor<?> substitutor, ITypeReferenceOwner owner) { JvmTypeReference parameterType = parameter.getParameterType(); if (parameterType == null || parameterType.getType() == null) { return false; } String identifier = parameterType.getIdentifier(); LightweightTypeReference candidateParameterType = substitutor.substitute(owner.toLightweightTypeReference(candidateParameter.getParameterType())); return identifier.equals(candidateParameterType.getJavaIdentifier()); }
protected LightweightTypeReference normalizedMultiType(ITypeReferenceOwner referenceOwner, JvmTypeReference ref) { LightweightTypeReference result = referenceOwner.toLightweightTypeReference(ref); if (result.isSynonym()) { List<LightweightTypeReference> components = result.getMultiTypeComponents(); result = referenceOwner.getServices().getTypeConformanceComputer().getCommonSuperType(components, referenceOwner); } return result; }
protected LightweightTypeReference getClosureOperationParameterType(LightweightTypeReference closureType, JvmOperation operation, int i) { ITypeReferenceOwner owner = newTypeReferenceOwner(operation); Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> mapping = new DeclaratorTypeArgumentCollector().getTypeParameterMapping(closureType); LightweightTypeReference parameterType = owner.toLightweightTypeReference(operation.getParameters().get(i).getParameterType()); return new StandardTypeParameterSubstitutor(mapping, owner).substitute(parameterType); }
protected ITypeComputationState getSwitchExpressionState(XSwitchExpression expr, ITypeComputationState state) { JvmFormalParameter param = expr.getDeclaredParam(); if (param == null) { return state.withNonVoidExpectation(); } JvmTypeReference parameterType = param.getParameterType(); if (parameterType == null) { return state.withNonVoidExpectation(); } LightweightTypeReference expectation = state.getReferenceOwner().toLightweightTypeReference(parameterType); return state.withExpectation(expectation); }
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); }