use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_05.
@Test
public void testImplicitFirstArgument_05() throws Exception {
XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + " def testExtensionMethods(CharSequence it) {\n" + " withObject\n" + " }\n" + " extension String" + " def withObject(Object obj) { null }" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XFeatureCall fifth = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation fifthFeature = (JvmOperation) fifth.getFeature();
assertEquals("MyXtendClass.withObject(java.lang.Object)", fifthFeature.getIdentifier());
assertEquals(1, fifthFeature.getParameters().size());
assertNotNull(fifth.getImplicitFirstArgument());
assertEquals("it", ((XAbstractFeatureCall) fifth.getImplicitFirstArgument()).getFeature().getSimpleName());
XFeatureCall fifthReceiver = (XFeatureCall) fifth.getImplicitReceiver();
assertTrue(fifthReceiver.getFeature() instanceof JvmGenericType);
assertNull(fifth.getInvalidFeatureIssueCode(), fifth.getInvalidFeatureIssueCode());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testFeatureScope_3.
@Test
public void testFeatureScope_3() throws Exception {
XtendFile file = file("import java.lang.String class X { def String foo(String foo) {[String foo|foo]}}");
XtendClass xClass = ((XtendClass) file.getXtendTypes().get(0));
XtendFunction func = (XtendFunction) xClass.getMembers().get(0);
XClosure closure = (XClosure) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
XAbstractFeatureCall featureCall1 = (XAbstractFeatureCall) (((XBlockExpression) closure.getExpression()).getExpressions().get(0));
assertEquals(closure.getFormalParameters().get(0), featureCall1.getFeature());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testInstanceOverExtension_04.
@Test
public void testInstanceOverExtension_04() throws Exception {
XtendClass clazz = clazz("" + "class C {" + " def m(java.util.List<String> list) {\n" + " list.get(0)\n" + " }\n" + "}");
XAbstractFeatureCall substring = findSingleFeatureCall(clazz);
assertEquals("java.util.List.get(int)", substring.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingShadowingTest method testField_staticExtension_shadows_sugarOnIt.
@Test
public void testField_staticExtension_shadows_sugarOnIt() throws Exception {
XtendClass clazz = clazz("import static extension testdata.LinkingStaticType.*\n" + "class SomeClass {\n" + " def method(testdata.LinkingType it) {\n" + " fieldOverloadsMethod\n" + " }\n" + "}");
XAbstractFeatureCall featureCall = getFirstFeatureCall(clazz);
assertLinksTo("testdata.LinkingStaticType.fieldOverloadsMethod", featureCall);
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class LinkingShadowingTest method testField_inherited_shadows_staticallyImported.
@Test
public void testField_inherited_shadows_staticallyImported() throws Exception {
XtendClass clazz = clazz("import static testdata.LinkingStaticType.*" + "class SomeClass extends testdata.LinkingType {\n" + " def method() {\n" + " publicField\n" + " }\n" + "}");
XAbstractFeatureCall featureCall = getFirstFeatureCall(clazz);
assertLinksTo("testdata.LinkingType.publicField", featureCall);
}
Aggregations