use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug345827_02.
@Test
public void testBug345827_02() throws Exception {
XtendFunction function = function("def String name() {\n" + " var name = ''\n" + " name()" + "}");
XBlockExpression block = (XBlockExpression) function.getExpression();
XFeatureCall featureCall = (XFeatureCall) block.getExpressions().get(1);
assertSame(associator.getDirectlyInferredOperation(function), featureCall.getFeature());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_07.
@Test
public void testImplicitFirstArgument_07() throws Exception {
XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + " def testExtensionMethods(CharSequence it) {\n" + " withCharSequence\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XFeatureCall seventh = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation seventhFeature = (JvmOperation) seventh.getFeature();
assertEquals("test.ImplicitFirstArgumentStatics.withCharSequence(java.lang.CharSequence)", seventhFeature.getIdentifier());
// static methods don't have receiver but an implicit argument
assertNotNull(seventh.getImplicitFirstArgument());
assertNull(seventh.getImplicitReceiver());
assertNull(seventh.getInvalidFeatureIssueCode(), seventh.getInvalidFeatureIssueCode());
assertEquals("it", ((XAbstractFeatureCall) seventh.getImplicitFirstArgument()).getFeature().getSimpleName());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testSugarOverTypeLiteral_01.
@Test
public void testSugarOverTypeLiteral_01() throws Exception {
XtendFile file = file("import org.eclipse.emf.ecore.resource.Resource\n" + "import org.eclipse.emf.common.util.URI\n" + "class C {\n" + " def m(Resource it, URI unused) {\n" + " URI" + " }\n" + "}\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("org.eclipse.emf.ecore.resource.Resource.getURI()", method.getIdentifier());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug403580_04.
@Test
public void testBug403580_04() 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 <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.Comparable)", method.getIdentifier());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testSugarOverTypeLiteral_03.
@Test
public void testSugarOverTypeLiteral_03() throws Exception {
XtendFile file = file("import org.eclipse.emf.ecore.EPackage\n" + "class C {\n" + " def m(Object it) {\n" + " EPackage" + " }" + " def void getEPackage(Object o) {}\n" + "}\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.getEPackage(java.lang.Object)", method.getIdentifier());
}
Aggregations