Search in sources :

Example 41 with JvmMember

use of org.eclipse.xtext.common.types.JvmMember in project xtext-xtend by eclipse.

the class InferredJvmModelTest method testInferredFunction_01.

@Test
public void testInferredFunction_01() throws Exception {
    XtendFile xtendFile = file("class Foo { def bar() { true } }");
    JvmGenericType inferredType = getInferredType(xtendFile);
    XtendClass xtendClass = (XtendClass) xtendFile.getXtendTypes().get(0);
    EList<JvmMember> jvmMembers = inferredType.getMembers();
    assertEquals(2, jvmMembers.size());
    JvmMember jvmMember = jvmMembers.get(1);
    assertTrue(jvmMember instanceof JvmOperation);
    XtendFunction xtendFunction = (XtendFunction) xtendClass.getMembers().get(0);
    assertEquals(xtendFunction.getName(), jvmMember.getSimpleName());
    assertEquals(jvmMember, associations.getDirectlyInferredOperation(xtendFunction));
    assertEquals(xtendFunction, associations.getXtendFunction((JvmOperation) inferredType.getMembers().get(1)));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmMember(org.eclipse.xtext.common.types.JvmMember) Test(org.junit.Test)

Aggregations

JvmMember (org.eclipse.xtext.common.types.JvmMember)41 Test (org.junit.Test)22 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)21 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)15 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)15 EObject (org.eclipse.emf.ecore.EObject)14 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)12 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)12 JvmField (org.eclipse.xtext.common.types.JvmField)12 JvmConstructor (org.eclipse.xtext.common.types.JvmConstructor)8 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)7 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)6 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)6 MemberDeclaration (org.eclipse.xtend.lib.macro.declaration.MemberDeclaration)4 JvmAnnotationType (org.eclipse.xtext.common.types.JvmAnnotationType)4 JvmEnumerationLiteral (org.eclipse.xtext.common.types.JvmEnumerationLiteral)4 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)4 Resource (org.eclipse.emf.ecore.resource.Resource)3 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)3 JvmEnumerationType (org.eclipse.xtext.common.types.JvmEnumerationType)3