use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testInjectedExtensionMethodCall.
@Test
public void testInjectedExtensionMethodCall() throws Exception {
XtendClass clazz = clazz("" + "class Foo {" + " @com.google.inject.Inject extension String string" + " def foo() " + " {(1 as int).indexOf()}" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(1);
final XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
assertEquals("java.lang.String.indexOf(int)", call.getFeature().getIdentifier());
assertEquals("Foo.string", ((XMemberFeatureCall) call.getImplicitReceiver()).getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_00.
@Test
public void testImplicitFirstArgument_00() throws Exception {
XtendClass clazz = clazz("class MyXtendClass {\n" + " def prependHello(String myString) {\n" + " 'Hello '+myString\n" + " }\n" + " def testExtensionMethods(String it) {\n" + " it.prependHello\n" + " prependHello\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(1);
XMemberFeatureCall first = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation firstFeature = (JvmOperation) first.getFeature();
assertEquals("prependHello", firstFeature.getSimpleName());
assertNull(first.getInvalidFeatureIssueCode(), first.getInvalidFeatureIssueCode());
XFeatureCall firstReceiver = (XFeatureCall) first.getImplicitReceiver();
assertEquals("MyXtendClass", firstReceiver.getFeature().getSimpleName());
XFeatureCall second = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(1);
JvmOperation secondFeature = (JvmOperation) second.getFeature();
assertEquals("prependHello", secondFeature.getSimpleName());
assertNull(second.getInvalidFeatureIssueCode(), second.getInvalidFeatureIssueCode());
assertFalse(secondFeature.eIsProxy());
XFeatureCall secondReceiver = (XFeatureCall) second.getImplicitReceiver();
assertEquals("MyXtendClass", secondReceiver.getFeature().getSimpleName());
XFeatureCall implicitArgument = (XFeatureCall) second.getImplicitFirstArgument();
assertNotNull(implicitArgument);
assertEquals("it", implicitArgument.getFeature().getSimpleName());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testSuper.
@Test
public void testSuper() throws Exception {
XtendFile file = file("class B<T> { def T m1() {} }\n" + "class C extends B<String> {\n" + " def void m2() { super.m1.subSequence(1,1) }\n" + "}");
XtendClass c = (XtendClass) file.getXtendTypes().get(1);
XtendFunction n = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) n.getExpression();
XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement feature = featureCall.getFeature();
assertEquals("java.lang.String.subSequence(int,int)", feature.getIdentifier());
}
Aggregations