use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testLocalVarExtensionMethodCall.
@Test
public void testLocalVarExtensionMethodCall() throws Exception {
XtendClass clazz = clazz("" + "class Foo {" + " def foo() " + " { extension var local = '' (1 as int).indexOf() }" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
final XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(1);
assertEquals("java.lang.String.indexOf(int)", call.getFeature().getIdentifier());
assertEquals("local", ((XFeatureCall) call.getImplicitReceiver()).getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug403580_01.
@Test
public void testBug403580_01() throws Exception {
XtendFile file = file("abstract class C {\n" + " def void m() {\n" + " overloaded [ String s | s ]\n" + " }\n" + " def void overloaded(Object o)" + " def <T> void overloaded(Comparable<T> c)" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XFeatureCall featureCall = (XFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement method = featureCall.getFeature();
assertEquals("C.overloaded(java.lang.Object)", method.getIdentifier());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug403580_06.
@Test
public void testBug403580_06() throws Exception {
XtendFile file = file("abstract class C {\n" + " def void m() {\n" + " overloaded [ String s | s.length ]\n" + " }\n" + " def void overloaded((String)=>String s)" + " def void overloaded(Object o)" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XFeatureCall featureCall = (XFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement method = featureCall.getFeature();
assertEquals("C.overloaded(java.lang.Object)", method.getIdentifier());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug345827_06.
@Test
public void testBug345827_06() throws Exception {
XtendFunction function = function("def String name(String param) {\n" + " name('param')" + "}");
XBlockExpression block = (XBlockExpression) function.getExpression();
XFeatureCall featureCall = (XFeatureCall) block.getExpressions().get(0);
assertSame(associator.getDirectlyInferredOperation(function), featureCall.getFeature());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_03.
@Test
public void testImplicitFirstArgument_03() throws Exception {
XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + " def testExtensionMethods(CharSequence it) {\n" + " toLowerCase\n" + " }\n" + " extension String" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XFeatureCall third = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation thirdFeature = (JvmOperation) third.getFeature();
assertEquals("java.lang.String.toLowerCase()", thirdFeature.getIdentifier());
assertNull(third.getImplicitFirstArgument());
XMemberFeatureCall thirdReceiver = (XMemberFeatureCall) third.getImplicitReceiver();
assertTrue(thirdReceiver.getFeature() instanceof JvmField);
assertNull(third.getInvalidFeatureIssueCode(), third.getInvalidFeatureIssueCode());
}
Aggregations