use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testParameterizedExtension_06.
@Test
public void testParameterizedExtension_06() throws Exception {
XtendFile file = file("package testPackage\n" + "import org.eclipse.xtext.testing.util.ParseHelper\n" + "import org.eclipse.xtend.core.xtend.XtendFile\n" + "class C<F extends XtendFile, T extends ParseHelper<F>> {\n" + " extension T\n" + " def m() {" + " parse('').xtendTypes\n" + " }\n" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XAbstractFeatureCall substring = findSingleFeatureCall(c);
assertEquals("org.eclipse.xtend.core.xtend.XtendFile.getXtendTypes()", substring.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testCreateExtension_00.
@Test
public void testCreateExtension_00() throws Exception {
XtendClass clazz = clazz("class Foo { " + " def create list: newArrayList('foo') getListWithFooAnd(String s) {" + " list" + " this.getListWithFooAnd('')" + " }" + "}");
assertEquals(1, clazz.getMembers().size());
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XFeatureCall featureCall = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
Set<EObject> elements = associator.getJvmElements(func);
Iterable<JvmOperation> filter = filter(elements, JvmOperation.class);
JvmOperation initializer = filter(filter, new Predicate<JvmOperation>() {
@Override
public boolean apply(JvmOperation input) {
return input.getSimpleName().startsWith("_init_");
}
}).iterator().next();
assertEquals(initializer.getParameters().get(0), featureCall.getFeature());
XAbstractFeatureCall recursiveFeatureCall = (XAbstractFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(1);
assertEquals("Foo.getListWithFooAnd(java.lang.String)", recursiveFeatureCall.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testOverloadedMethod_01.
@Test
public void testOverloadedMethod_01() throws Exception {
XtendFile file = file("package testPackage\n" + "class C {\n" + " def String m(String s) {\n" + " return null\n" + " }\n" + " def String m() {" + " this.m\n" + " }\n" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XAbstractFeatureCall substring = findSingleFeatureCall(c);
assertEquals("testPackage.C.m()", substring.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_06.
@Test
public void testImplicitFirstArgument_06() throws Exception {
XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + " def testExtensionMethods(CharSequence it) {\n" + " contains\n" + " }\n" + " extension String" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XFeatureCall sixth = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation sixthFeature = (JvmOperation) sixth.getFeature();
assertEquals("java.lang.String.contains(java.lang.CharSequence)", sixthFeature.getIdentifier());
assertEquals("java.lang.String", sixthFeature.getDeclaringType().getQualifiedName());
assertNotNull(sixth.getImplicitFirstArgument());
assertEquals("it", ((XAbstractFeatureCall) sixth.getImplicitFirstArgument()).getFeature().getSimpleName());
XMemberFeatureCall sixthReceiver = (XMemberFeatureCall) sixth.getImplicitReceiver();
assertTrue(sixthReceiver.getFeature() instanceof JvmField);
assertNull(sixth.getInvalidFeatureIssueCode(), sixth.getInvalidFeatureIssueCode());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testTypeOfRichStringWithNoExpectedString_1.
@Test
public void testTypeOfRichStringWithNoExpectedString_1() throws Exception {
XtendFunction function = function("def foo(String x) {" + "println('''someString''')" + "}");
XBlockExpression block = (XBlockExpression) function.getExpression();
XAbstractFeatureCall call = (XAbstractFeatureCall) block.getExpressions().get(0);
XExpression expression = call.getExplicitArguments().get(0);
// TODO propagate the expectation better via unbound type parameters
// could still be a charsequence, here
assertEquals("java.lang.String", getType(expression).getIdentifier());
}
Aggregations