Java Code Examples for org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference

The following examples show how to use org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public String getResolvedErasureSignature() {
	JvmExecutable declaration = getDeclaration();
	List<LightweightTypeReference> parameterTypes = getResolvedParameterTypes();
	StringBuilder result = new StringBuilder(declaration.getSimpleName().length() + 2 + 20 * parameterTypes.size());
	result.append(declaration.getSimpleName());
	result.append('(');
	for(int i = 0; i < parameterTypes.size(); i++) {
		if (i != 0) {
			result.append(',');
		}
		result.append(parameterTypes.get(i).getRawTypeReference().getJavaIdentifier());
	}
	result.append(')');
	return result.toString();
}
 
Example 2
/**
 * Returns the unresolved string representation of the given type parameter. The simple names of
 * the type bounds are used. The string representation includes the bounds, except for
 * the upper bound {@link Object}. 
 */
protected String getTypeParameterAsString(JvmTypeParameter typeParameter) {
	StringBuilder b = new StringBuilder();
	b.append(typeParameter.getName());
	ITypeReferenceOwner referenceOwner = getState().getReferenceOwner();
	if(!typeParameter.getConstraints().isEmpty()) {
		boolean firstUpperBound = true;
		for(int j=0; j<typeParameter.getConstraints().size(); ++j) {
			JvmTypeConstraint constraint = typeParameter.getConstraints().get(j);
			LightweightTypeReference typeRef = referenceOwner.toLightweightTypeReference(constraint.getTypeReference());
			if(constraint instanceof JvmUpperBound) {
				if(typeRef.isType(Object.class))
					continue;
				if (firstUpperBound) {
					b.append(" extends ");
					firstUpperBound = false;
				} else {
					b.append(" & ");
				}
			} else 
				b.append(" super ");
			b.append(typeRef.getHumanReadableName());
		}
	}
	return b.toString();
}
 
Example 3
Source Project: xtext-xtend   Source File: ResolvedMethodImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Iterable<? extends ResolvedTypeParameter> getResolvedTypeParameters() {
  ArrayList<ResolvedTypeParameterImpl> _xblockexpression = null;
  {
    final ArrayList<ResolvedTypeParameterImpl> resolvedTypeParameters = CollectionLiterals.<ResolvedTypeParameterImpl>newArrayList();
    for (int i = 0; (i < this.getDelegate().getResolvedTypeParameters().size()); i++) {
      TypeParameterDeclaration _typeParameterDeclaration = this.getCompilationUnit().toTypeParameterDeclaration(this.getDelegate().getResolvedTypeParameters().get(i));
      final Function1<LightweightTypeReference, TypeReference> _function = (LightweightTypeReference it) -> {
        return this.getCompilationUnit().toTypeReference(it);
      };
      List<TypeReference> _list = IterableExtensions.<TypeReference>toList(ListExtensions.<LightweightTypeReference, TypeReference>map(this.getDelegate().getResolvedTypeParameterConstraints(i), _function));
      ResolvedTypeParameterImpl _resolvedTypeParameterImpl = new ResolvedTypeParameterImpl(_typeParameterDeclaration, _list);
      resolvedTypeParameters.add(_resolvedTypeParameterImpl);
    }
    _xblockexpression = resolvedTypeParameters;
  }
  return _xblockexpression;
}
 
Example 4
protected int doIsConformantOuter(LightweightTypeReference left, LightweightTypeReference right, int nestedResult, int flags) {
	if ((nestedResult & SUCCESS) != 0) {
		JvmType leftType = left.getType();
		EObject leftDeclarator = leftType.eContainer();
		if (leftDeclarator instanceof JvmDeclaredType) {
			JvmDeclaredType castedLeftDeclarator = (JvmDeclaredType) leftDeclarator;
			LightweightTypeReference leftOuter = left.getOuter().getSuperType(castedLeftDeclarator);
			if (leftOuter != null) {
				LightweightTypeReference rightOuter = right.getOuter().getSuperType(castedLeftDeclarator);
				if (rightOuter != null) {
					int outerResult = doIsConformant(leftOuter, rightOuter, flags);
					if ((outerResult & SUCCESS) == 0) {
						return outerResult;
					}
				}
			}
		}
	}
	return nestedResult;
}
 
Example 5
@Override
public LightweightTypeReference doVisitParameterizedTypeReference(ParameterizedTypeReference reference) {
	DeclaratorTypeArgumentCollector typeArgumentCollector = new ConstraintAwareTypeArgumentCollector(owner);
	Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> typeParameterMapping = typeArgumentCollector.getTypeParameterMapping(reference);
	TypeParameterSubstitutor<?> substitutor = new UnboundTypeParameterPreservingSubstitutor(typeParameterMapping, owner);
	JvmGenericType iterable = (JvmGenericType) owner.getServices().getTypeReferences().findDeclaredType(Iterable.class, owner.getContextResourceSet());
	if (iterable == null) {
		return owner.newReferenceToObject();
	}
	LightweightTypeReference substituteMe = owner.newParameterizedTypeReference(iterable.getTypeParameters().get(0));
	LightweightTypeReference substitutedArgument = substitutor.substitute(substituteMe).getUpperBoundSubstitute();
	if (substitutedArgument.getType() instanceof JvmTypeParameter && 
			!(owner.getDeclaredTypeParameters().contains(substitutedArgument.getType()))) {
		return substitutedArgument.getRawTypeReference();
	}
	return substitutedArgument;
}
 
Example 6
protected boolean isResolvedTypeParameter(LightweightTypeReference typeReference, JvmTypeParameter typeParameter) {
	List<LightweightTypeReference> typeArguments = typeReference.getTypeArguments();
	for(int i = 0, size = typeArguments.size(); i < size; i++) {
		LightweightTypeReference typeArgument = typeArguments.get(i);
		if (typeParameter.equals(typeArgument.getType()) || isResolvedTypeParameter(typeArgument, typeParameter)) {
			return true;
		}
	}
	LightweightTypeReference outer = typeReference.getOuter();
	if (outer != null) {
		if (isResolvedTypeParameter(outer, typeParameter)) {
			return true;
		}
	}
	return false;
}
 
Example 7
Source Project: xtext-xtend   Source File: Bug409780Test.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testConstraintsInfluenceType() throws Exception {
	XtendFile file = file(
			"class C {\n" + 
			"	def private a(Iterable<CharSequence> it) {\n" + 
			"		map[ b ]\n" + 
			"	}\n" + 
			"	def private <T extends Appendable> T b(CharSequence c) {}\n" + 
			"}"); 
	XtendClass c = (XtendClass) file.getXtendTypes().get(0);
	XtendFunction m = (XtendFunction) c.getMembers().get(0);
	XBlockExpression body = (XBlockExpression) m.getExpression();
	XFeatureCall featureCall = (XFeatureCall) body.getExpressions().get(0);
	JvmIdentifiableElement method = featureCall.getFeature();
	assertEquals("org.eclipse.xtext.xbase.lib.IterableExtensions.map(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", method.getIdentifier());
	assertTrue(featureCall.isStatic());
	assertTrue(featureCall.isExtension());
	assertFalse(featureCall.isTypeLiteral());
	LightweightTypeReference type = getType(featureCall);
	assertEquals("java.lang.Iterable<java.lang.Appendable>", type.getIdentifier());
}
 
Example 8
protected void initializeExecutableBuilder(final AbstractExecutableBuilder builder, final JvmDeclaredType overrider, final IResolvedExecutable overridden) {
  final JvmExecutable executable = overridden.getDeclaration();
  builder.setContext(overrider);
  builder.setVisibility(overridden.getDeclaration().getVisibility());
  final Procedure2<LightweightTypeReference, Integer> _function = (LightweightTypeReference it, Integer index) -> {
    final JvmFormalParameter declaredParameter = executable.getParameters().get((index).intValue());
    final AbstractParameterBuilder parameterBuilder = builder.newParameterBuilder();
    parameterBuilder.setName(declaredParameter.getSimpleName());
    parameterBuilder.setType(it);
    JvmAnnotationReference _findAnnotation = this.annotationLookup.findAnnotation(declaredParameter, Extension.class);
    boolean _tripleNotEquals = (_findAnnotation != null);
    parameterBuilder.setExtensionFlag(_tripleNotEquals);
  };
  IterableExtensions.<LightweightTypeReference>forEach(overridden.getResolvedParameterTypes(), _function);
  builder.setVarArgsFlag(executable.isVarArgs());
  builder.setExceptions(overridden.getResolvedExceptions());
}
 
Example 9
Source Project: xtext-extras   Source File: XbaseCompiler.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Append the type parameters of the given operation.
 *
 * @param appendable the receiver of the Java code.
 * @param operation the source operation.
 * @param instantiatedType the type of the operation container.
 */
protected void appendTypeParameters(ITreeAppendable appendable, JvmOperation operation, LightweightTypeReference instantiatedType) {
	Preconditions.checkArgument(!operation.getTypeParameters().isEmpty(), "the operation is not generic");
	BottomResolvedOperation resolvedOperation = new BottomResolvedOperation(operation, instantiatedType, overrideTester);
	List<JvmTypeParameter> typeParameters = resolvedOperation.getResolvedTypeParameters();
	appendable.append("<");
	for(int i = 0; i < typeParameters.size(); i++) {
		if (i != 0) {
			appendable.append(", ");
		}
		JvmTypeParameter typeParameter = typeParameters.get(i);
		appendable.append(typeParameter.getName());
		List<LightweightTypeReference> constraints = resolvedOperation.getResolvedTypeParameterConstraints(i);
		if (!constraints.isEmpty()) {
			appendable.append(" extends ");
			for(int j = 0; j < constraints.size(); j++) {
				if (j != 0) {
					appendable.append(" & ");
				}
				appendable.append(constraints.get(j));
			}
		}
	}
	appendable.append("> ");
}
 
Example 10
protected LightweightTypeReference wrapInCompoundTypeIfNecessary(
		List<LightweightTypeReference> referencesWithSameDistance) {
	if (referencesWithSameDistance.size() == 1) {
		return referencesWithSameDistance.get(0);
	} else if (referencesWithSameDistance.size() > 1) {
		CompoundTypeReference result = owner.newCompoundTypeReference(false);
		for(LightweightTypeReference reference: referencesWithSameDistance) {
			result.addComponent(reference);
		}
		return result;
	}
	return null;
}
 
Example 11
Source Project: xtext-extras   Source File: ArrayTypesTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testTryConvertToArray_10() throws Exception {
	LightweightTypeReference typeReference = toTypeReference(
			"org.eclipse.xtext.xbase.tests.typesystem.ClosureTypeComputerUnitTest.StrangeStringIterable<Integer>");
	ArrayTypeReference arrayType = typeReference.tryConvertToArray();
	assertEquals("String[]", arrayType.getSimpleName());
}
 
Example 12
@Override
protected LightweightTypeReference internalGetParameterTypeForLambda(int idx) {
	if (idx >= arguments.size()) {
		throw new IndexOutOfBoundsException("Cannot read type for argument that is not present.");
	} else if (idx >= parameters.size()) {
		idx = parameters.size() - 1;
	}
	LightweightTypeReference result = super.internalGetParameterTypeForLambda(idx);
	return getComponentTypeIfLast(result, parameters, idx);
}
 
Example 13
public Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> in(final String typeParameters, final String expectedType, final String actualType) {
  final JvmOperation operation = this.operation(typeParameters, expectedType, actualType);
  ITypeReferenceOwner _owner = this.getOwner();
  final DeferredTypeParameterHintCollector collector = new DeferredTypeParameterHintCollector(_owner);
  final DefaultReentrantTypeResolver resolver = this.resolverProvider.get();
  resolver.initializeFrom(EcoreUtil.getRootContainer(operation));
  ITypeReferenceOwner _owner_1 = this.getOwner();
  PublicResolvedTypes _publicResolvedTypes = new PublicResolvedTypes(resolver);
  final MockTypeParameterSubstitutor substitutor = new MockTypeParameterSubstitutor(_owner_1, _publicResolvedTypes);
  final LightweightTypeReference hasUnbounds = substitutor.substitute(this.toLightweightTypeReference(IterableExtensions.<JvmFormalParameter>head(operation.getParameters()).getParameterType()));
  final LightweightTypeReference isActual = this.toLightweightTypeReference(IterableExtensions.<JvmFormalParameter>last(operation.getParameters()).getParameterType());
  collector.processPairedReferences(hasUnbounds, isActual);
  return substitutor.getTypeParameterMapping();
}
 
Example 14
Source Project: xtext-extras   Source File: ResolvedFeature.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Map<JvmTypeParameter, LightweightMergedBoundTypeArgument> getDeclaratorParameterMapping() {
	final Wrapper<Map<JvmTypeParameter, LightweightMergedBoundTypeArgument>> receiverTypeParameterMapping = Wrapper.wrap(Collections.<JvmTypeParameter, LightweightMergedBoundTypeArgument>emptyMap());
	XExpression receiver = getReceiver();
	if (receiver != null) {
		LightweightTypeReference receiverType = getReceiverType();
		if (receiverType == null) {
			throw new IllegalStateException("Cannot determine type of receiver "+ getReceiver());
		}
		JvmIdentifiableElement feature = getFeature();
		if (feature instanceof JvmFeature) {
			JvmDeclaredType declaringType = ((JvmFeature) feature).getDeclaringType();
			final LightweightTypeReference declaringTypeReference = receiverType.getOwner().newParameterizedTypeReference(declaringType);
			final TypeConformanceComputationArgument rawConformanceCheck = new TypeConformanceComputationArgument(true, false, false, false, false, false);
			if (declaringTypeReference.isAssignableFrom(receiverType, rawConformanceCheck)) {
				receiverTypeParameterMapping.set(new DeclaratorTypeArgumentCollector().getTypeParameterMapping(receiverType));
			} else {
				CommonTypeComputationServices services = receiverType.getOwner().getServices();
				SynonymTypesProvider synonymProvider = services.getSynonymTypesProvider();
				synonymProvider.collectSynonymTypes(receiverType, new SynonymTypesProvider.Acceptor() {
					
					@Override
					protected boolean accept(LightweightTypeReference synonym, int hints) {
						if (declaringTypeReference.isAssignableFrom(synonym, rawConformanceCheck)) {
							receiverTypeParameterMapping.set(new DeclaratorTypeArgumentCollector().getTypeParameterMapping(synonym));
							return false;
						}
						return true;
					}
				});
			}
			
		} else {
			receiverTypeParameterMapping.set(new DeclaratorTypeArgumentCollector().getTypeParameterMapping(receiverType));
		}
	}
	return receiverTypeParameterMapping.get();
}
 
Example 15
Source Project: xtext-extras   Source File: XbaseValidator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected String getNameOfTypes(LightweightTypeReference expectedType) {
	final StringBuilder result = new StringBuilder(canonicalName(expectedType));
	getServices().getSynonymTypesProvider().collectSynonymTypes(expectedType, new SynonymTypesProvider.Acceptor() {
		@Override
		protected boolean accept(LightweightTypeReference synonym, int flags) {
			result.append(" or ").append(canonicalName(synonym));
			return true;
		}
	});
	return result.toString();
}
 
Example 16
Source Project: xtext-extras   Source File: OverrideTester.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected void addReturnTypeDetails(AbstractResolvedOperation overriding, AbstractResolvedOperation overridden,
		EnumSet<OverrideCheckDetails> result) {
	LightweightTypeReference overridingReturnType = overriding.getResolvedReturnType();
	LightweightTypeReference overriddenReturnType = overridden.getResolvedReturnType();
	TypeConformanceComputationArgument conformanceArgument = new TypeConformanceComputationArgument(false, false, false, false, false, false);
	if (!overriddenReturnType.isAssignableFrom(overridingReturnType, conformanceArgument)) {
		if (overriding.getTypeParameters().isEmpty() && !overridden.getTypeParameters().isEmpty()) {
			TypeConformanceComputationArgument rawConformanceArgument = new TypeConformanceComputationArgument(true, false, false, false, false, false);
			if (!overriddenReturnType.isAssignableFrom(overridingReturnType, rawConformanceArgument)) {
				result.add(OverrideCheckDetails.RETURN_MISMATCH);		
			} else {
				result.add(OverrideCheckDetails.UNCHECKED_CONVERSION_REQUIRED);
				if (overridingReturnType.getRawTypeReference().getType() != overriddenReturnType.getRawTypeReference().getType()) {
					result.add(OverrideCheckDetails.COVARIANT_RETURN);
				}
			}
		} else {
			result.add(OverrideCheckDetails.RETURN_MISMATCH);
		}
	} else if (!overriddenReturnType.getJavaIdentifier().equals(overridingReturnType.getJavaIdentifier())) {
		if (!overridden.isRawTypeInheritance() && overriding.getTypeParameters().isEmpty() && !overridden.getTypeParameters().isEmpty()) {
			if (overridden.getTypeParameters().contains(overridden.getDeclaration().getReturnType().getType())) {
				result.add(OverrideCheckDetails.UNCHECKED_CONVERSION_REQUIRED);
			}
		}
		result.add(OverrideCheckDetails.COVARIANT_RETURN);
	}
}
 
Example 17
protected LightweightTypeReference toTypeReference(CharSequence reference) {
	try {
		String expression = "null as " + reference;
		XCastedExpression castExpression = (XCastedExpression) expression(expression);
		IResolvedTypes resolvedTypes = typeResolver.resolveTypes(castExpression);
		return resolvedTypes.getActualType(castExpression);
	} catch (Exception e) {
		throw Exceptions.sneakyThrow(e);
	}
}
 
Example 18
Source Project: xtext-extras   Source File: ResolvedFeature.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected boolean isRawTypeContext() {
	LightweightTypeReference receiverType = getReceiverType();
	if(receiverType != null && receiverType.isRawType()) {
		return true;
	}
	return false;
}
 
Example 19
Source Project: xtext-extras   Source File: ResolvedTypes.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected LightweightTypeReference doGetExpectedType(XExpression expression, boolean returnType) {
	TypeData typeData = getTypeData(expression, returnType, !returnType);
	if (typeData != null) {
		return typeData.getExpectation().getExpectedType();
	}
	return null;
}
 
Example 20
@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());
}
 
Example 21
Source Project: xtext-extras   Source File: ResolvedTypes.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected int getConformanceFlags(TypeData typeData, boolean recompute) {
	int flags = typeData.getConformanceFlags();
	if (recompute) {
		if ((flags & ConformanceFlags.SEALED) != 0) {
			ConformanceFlags.sanityCheck(flags);
			return flags;
		}
		flags &= ~(ConformanceFlags.INCOMPATIBLE | ConformanceFlags.SUCCESS);
		flags |= ConformanceFlags.UNCHECKED;
	}
	if ((flags & ConformanceFlags.UNCHECKED) != 0) {
		LightweightTypeReference actualType = typeData.getActualType();
		ITypeExpectation expectation = typeData.getExpectation();
		LightweightTypeReference expectedType = expectation.getExpectedType();
		if (expectedType != null) {
			int conformanceResult = expectedType.getUpperBoundSubstitute().internalIsAssignableFrom(
					actualType, TypeConformanceComputationArgument.DEFAULT);
			flags |= conformanceResult | ConformanceFlags.CHECKED;
			flags &= ~ConformanceFlags.UNCHECKED;
		} else {
			flags &= ~ConformanceFlags.UNCHECKED;
			flags |= ConformanceFlags.CHECKED_SUCCESS; 
		}
	}
	ConformanceFlags.sanityCheck(flags);
	typeData.setConformanceFlags(flags);
	return flags;
}
 
Example 22
protected AbstractTypeExpectation createTypeExpectation(/* @Nullable */ LightweightTypeReference expectedType, AbstractTypeComputationState actualState, boolean returnType) {
	AbstractTypeExpectation result = null;
	if (expectedType != null) {
		LightweightTypeReference copied = expectedType.copyInto(actualState.getReferenceOwner());
		result = new TypeExpectation(copied, actualState, returnType);
	} else {
		result = new NoExpectation(actualState, returnType);
	}
	return result;
}
 
Example 23
Source Project: xtext-xtend   Source File: LinkingTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testTypeParameterReference_12() throws Exception {
	XtendFunction func = (XtendFunction) ((XtendClass)file("class X<Z> implements Iterable<Z> { def Iterable<String> foo() { val result = new X return result }}")
			.getXtendTypes().get(0)).getMembers().get(0);
	JvmOperation operation = associator.getDirectlyInferredOperation(func);
	JvmTypeReference returnType = operation.getReturnType();
	assertEquals("java.lang.Iterable<java.lang.String>", returnType.getIdentifier());
	LightweightTypeReference bodyType = getType(func.getExpression());
	assertEquals("void", bodyType.getIdentifier());
	LightweightTypeReference bodyReturnType = getReturnType(func.getExpression());
	assertEquals("X<java.lang.String>", bodyReturnType.getIdentifier());
}
 
Example 24
Source Project: xtext-xtend   Source File: CommonSuperTypeTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private boolean isPrimitiveOrVoid(final LightweightTypeReference computedSuperType) {
  boolean _xblockexpression = false;
  {
    if ((computedSuperType == null)) {
      return false;
    }
    _xblockexpression = (computedSuperType.isPrimitiveVoid() || computedSuperType.isPrimitive());
  }
  return _xblockexpression;
}
 
Example 25
protected void newFieldQuickfix(String name, XAbstractFeatureCall call, 
		final Issue issue, final IssueResolutionAcceptor issueResolutionAcceptor) {
	JvmDeclaredType callersType = getCallersType(call);
	LightweightTypeReference receiverType = getReceiverType(call);
	LightweightTypeReference fieldType = getNewMemberType(call);
	if(callersType != null && receiverType != null && callersType == receiverType.getType()) 
		newFieldQuickfix(callersType, name, fieldType, isStaticAccess(call), call, issue, issueResolutionAcceptor);
}
 
Example 26
Source Project: xtext-xtend   Source File: XtendValidator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected void createExceptionMismatchError(IResolvedOperation operation, EObject sourceElement,
		List<IResolvedOperation> exceptionMismatch) {
	List<LightweightTypeReference> exceptions = operation.getIllegallyDeclaredExceptions();
	StringBuilder message = new StringBuilder(100);
	message.append("The declared exception");
	if (exceptions.size() > 1) {
		message.append('s');
	}
	message.append(' ');
	for(int i = 0; i < exceptions.size(); i++) {
		if (i != 0) {
			if (i != exceptions.size() - 1)
				message.append(", ");
			else
				message.append(" and ");
		}
		message.append(exceptions.get(i).getHumanReadableName());
	}
	if (exceptions.size() > 1) {
		message.append(" are");
	} else {
		message.append(" is");
	}
	message.append(" not compatible with throws clause in ");
	for(int i = 0; i < exceptionMismatch.size(); i++) {
		if (i != 0) {
			if (i != exceptionMismatch.size() - 1)
				message.append(", ");
			else
				message.append(" and ");
		}
		IResolvedOperation resolvedOperation = exceptionMismatch.get(i);
		message.append(getDeclaratorName(resolvedOperation));
		message.append('.');
		message.append(exceptionMismatch.get(i).getSimpleSignature());
	}
	error(message.toString(), sourceElement, exceptionsFeature(sourceElement), INCOMPATIBLE_THROWS_CLAUSE);
}
 
Example 27
@Override
public void reassignType(JvmIdentifiableElement identifiable, LightweightTypeReference reference) {
	if (reference != null && !reference.isOwnedBy(getReferenceOwner())) {
		throw new IllegalArgumentException("reference is not owned by this resolved types");
	}
	super.reassignType(identifiable, reference);
}
 
Example 28
@Override
public LightweightTypeReference getExpectedType(XExpression expression) {
	LightweightTypeReference result = super.getExpectedType(expression);
	if (!result.isOwnedBy(getReferenceOwner())) {
		throw new IllegalArgumentException("result is not owned by this resolved types");
	}
	return result;
}
 
Example 29
@Override
public LightweightTypeReference getMergedType(List<LightweightTypeReference> types) {
	for (LightweightTypeReference it : types) {
		if (!it.isOwnedBy(it.getOwner())) {
			throw new IllegalArgumentException("result is not owned by this resolved types");
		}
	}
	LightweightTypeReference result = super.getMergedType(types);
	if (!result.isOwnedBy(getReferenceOwner())) {
		throw new IllegalArgumentException("result is not owned by this resolved types");
	}
	return result;
}
 
Example 30
@Override
public void completeXMemberFeatureCall_Feature(EObject model, Assignment assignment, ContentAssistContext context,
		ICompletionProposalAcceptor acceptor) {
	if (model instanceof XMemberFeatureCall) {
		XExpression memberCallTarget = ((XMemberFeatureCall) model).getMemberCallTarget();
		IResolvedTypes resolvedTypes = typeResolver.resolveTypes(memberCallTarget);
		LightweightTypeReference memberCallTargetType = resolvedTypes.getActualType(memberCallTarget);
		Iterable<JvmFeature> featuresToImport = getFavoriteStaticFeatures(model, input -> {
			if(input instanceof JvmOperation && input.isStatic()) {
				List<JvmFormalParameter> parameters = ((JvmOperation) input).getParameters();
				if(parameters.size() > 0) {
					JvmFormalParameter firstParam = parameters.get(0);
					JvmTypeReference parameterType = firstParam.getParameterType();
					if(parameterType != null) {
						LightweightTypeReference lightweightTypeReference = memberCallTargetType.getOwner().toLightweightTypeReference(parameterType);
						if(lightweightTypeReference != null) {
							return memberCallTargetType.isAssignableFrom(lightweightTypeReference);
						}
					}
				}
			}
			return false;
		});
		// Create StaticExtensionFeatureDescriptionWithImplicitFirstArgument instead of SimpleIdentifiableElementDescription since we want the Proposal to show parameters
		Iterable<IEObjectDescription> scopedFeatures = Iterables.transform(featuresToImport, feature -> {
			QualifiedName qualifiedName = QualifiedName.create(feature.getSimpleName());
			return new StaticExtensionFeatureDescriptionWithImplicitFirstArgument(qualifiedName, feature, memberCallTarget, memberCallTargetType, 0, true);
		});
		// Scope for all static features
		IScope staticMemberScope = new SimpleScope(IScope.NULLSCOPE, scopedFeatures);
		proposeFavoriteStaticFeatures(model, context, acceptor, staticMemberScope);
		// Regular proposals
		createReceiverProposals(((XMemberFeatureCall) model).getMemberCallTarget(), (CrossReference) assignment.getTerminal(),
				context, acceptor);
	} else if (model instanceof XAssignment) {
		createReceiverProposals(((XAssignment) model).getAssignable(), (CrossReference) assignment.getTerminal(),
				context, acceptor);
	}
}