use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class UIStringsTest method testReferenceToString_4.
@Test
public void testReferenceToString_4() throws Exception {
XtendFile file = file("class Foo { var test }");
assertFalse(validationTestHelper.validate(file).isEmpty());
XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
XtendField field = (XtendField) clazz.getMembers().get(0);
JvmField jvmField = associations.getJvmField(field);
JvmTypeReference reference = jvmField.getType();
assertNotNull(reference);
assertNotNull(reference.getType());
assertFalse(reference.getType().eIsProxy());
assertNotNull(reference.eResource());
assertEquals("Object", this.uiStrings.referenceToString(reference, "the-default-label"));
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class XtendFieldImpl method basicSetType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetType(JvmTypeReference newType, NotificationChain msgs) {
JvmTypeReference oldType = type;
type = newType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XtendPackage.XTEND_FIELD__TYPE, oldType, newType);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testInferredFunctionWithTypeParameter.
@Test
public void testInferredFunctionWithTypeParameter() throws Exception {
XtendFile xtendFile = file("class Foo<S> { def java.util.List<S> foo() {null} }");
JvmGenericType inferredType = getInferredType(xtendFile);
JvmOperation jvmOperation = (JvmOperation) inferredType.getMembers().get(1);
assertEquals("java.util.List<S>", jvmOperation.getReturnType().getIdentifier());
JvmTypeReference argument = ((JvmParameterizedTypeReference) jvmOperation.getReturnType()).getArguments().get(0);
assertSame(inferredType, ((JvmTypeParameter) argument.getType()).getDeclarator());
XtendFunction xtendFunction = (XtendFunction) ((XtendClass) xtendFile.getXtendTypes().get(0)).getMembers().get(0);
assertEquals("java.util.List<S>", xtendFunction.getReturnType().getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterShadowsType_1.
@Test
public void testTypeParameterShadowsType_1() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class A {} class B { def <A> A foo(A x) {x}}").getXtendTypes().get(1)).getMembers().get(0);
JvmTypeReference returnType = func.getReturnType();
JvmTypeParameter typeParamDecl = (JvmTypeParameter) returnType.getType();
assertEquals("A", typeParamDecl.getIdentifier());
JvmTypeParameter param = (JvmTypeParameter) func.getParameters().get(0).getParameterType().getType();
assertSame(typeParamDecl, param);
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class LinkingTest method testTypeParameterReference_2.
@Test
public void testTypeParameterReference_2() throws Exception {
XtendFunction func = (XtendFunction) ((XtendClass) file("class X<Y> { def foo(Y y) { return y }}").getXtendTypes().get(0)).getMembers().get(0);
JvmOperation operation = associator.getDirectlyInferredOperation(func);
JvmTypeReference returnType = operation.getReturnType();
assertEquals("Y", returnType.getIdentifier());
JvmTypeReference paramType = operation.getParameters().get(0).getParameterType();
assertEquals("Y", paramType.getIdentifier());
}
Aggregations