use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testInferredFunctionWithReturnType_01.
@Test
public void testInferredFunctionWithReturnType_01() throws Exception {
XtendFile xtendFile = file("class Foo { def Boolean bar() { true } }");
JvmGenericType inferredType = getInferredType(xtendFile);
assertTrue(inferredType.getMembers().get(0) instanceof JvmConstructor);
JvmOperation jvmOperation = (JvmOperation) inferredType.getMembers().get(1);
XtendFunction xtendFunction = (XtendFunction) ((XtendClass) xtendFile.getXtendTypes().get(0)).getMembers().get(0);
assertFalse(xtendFunction.getReturnType() == jvmOperation.getReturnType());
assertEquals(xtendFunction.getReturnType().getType(), jvmOperation.getReturnType().getType());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class Case_14 method testInference.
@Test
public void testInference() {
final Provider<IJvmModelInferrer> _function = () -> {
final IJvmModelInferrer _function_1 = (EObject obj, IJvmDeclaredTypeAcceptor acceptor, boolean preIndexing) -> {
final JvmGenericType firstType = this._jvmTypesBuilder.toClass(obj, "foo.Bar");
final JvmGenericType secondType = this._jvmTypesBuilder.toClass(obj, "foo.Baz");
Assert.assertNull(secondType.eResource());
final Procedure1<JvmGenericType> _function_2 = (JvmGenericType it) -> {
it.setAbstract(true);
Assert.assertNotNull(firstType.eResource());
Assert.assertNotNull(secondType.eResource());
};
acceptor.<JvmGenericType>accept(firstType, _function_2);
final Procedure1<JvmGenericType> _function_3 = (JvmGenericType it) -> {
it.setAbstract(true);
Assert.assertNotNull(firstType.eResource());
};
acceptor.<JvmGenericType>accept(secondType, _function_3);
};
return _function_1;
};
this.assoc.setInferrerProvider(_function);
this.resource.setDerivedStateComputer(null);
this.resource.setURI(URI.createURI("foo.txt"));
this.resourceSet.setClasspathURIContext(this.getClass());
EList<Resource> _resources = this.resourceSet.getResources();
this._jvmTypesBuilder.<DerivedStateAwareResource>operator_add(_resources, this.resource);
EList<EObject> _contents = this.resource.getContents();
EClass _createEClass = EcoreFactory.eINSTANCE.createEClass();
this._jvmTypesBuilder.<EClass>operator_add(_contents, _createEClass);
this.assoc.installDerivedState(this.resource, true);
EObject _get = this.resource.getContents().get(1);
Assert.assertFalse(((JvmDeclaredType) _get).isAbstract());
this.resource.getContents().clear();
EList<EObject> _contents_1 = this.resource.getContents();
EClass _createEClass_1 = EcoreFactory.eINSTANCE.createEClass();
this._jvmTypesBuilder.<EClass>operator_add(_contents_1, _createEClass_1);
this.assoc.installDerivedState(this.resource, false);
EObject _get_1 = this.resource.getContents().get(1);
final JvmGenericType type = ((JvmGenericType) _get_1);
Assert.assertTrue(type.isAbstract());
Assert.assertEquals(1, IterableExtensions.size(Iterables.<JvmConstructor>filter(type.getMembers(), JvmConstructor.class)));
JvmTypeReference _head = IterableExtensions.<JvmTypeReference>head(type.getSuperTypes());
String _qualifiedName = null;
if (_head != null) {
_qualifiedName = _head.getQualifiedName();
}
Assert.assertEquals("java.lang.Object", _qualifiedName);
}
Aggregations