use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testStaticNestedClass_01.
@Test
public void testStaticNestedClass_01() throws Exception {
XtendFile file = file("class C {\n" + " static class D {\n" + " def static void m(CharSequence c) { m('') }\n" + " }\n" + " def void m(String s) {}\n" + "}");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendClass d = (XtendClass) c.getMembers().get(0);
XtendFunction m = (XtendFunction) d.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XFeatureCall featureCall = (XFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement feature = featureCall.getFeature();
assertEquals("C$D.m(java.lang.CharSequence)", feature.getIdentifier());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug345827_01.
@Test
public void testBug345827_01() 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);
// TODO actually we should prefer the function in case 'explicitOperationCall' is true
// for a featureCall
assertSame(block.getExpressions().get(0), featureCall.getFeature());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testTypeOfSuper.
@Test
public void testTypeOfSuper() throws Exception {
String classAsString = "class Foo extends java.util.ArrayList<String> {" + " def m() {\n" + " super.add(null)\n" + " }\n" + "}";
XtendClass clazz = clazz(classAsString);
XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
XExpression body = function.getExpression();
XBlockExpression block = (XBlockExpression) body;
XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(0);
XFeatureCall superCall = (XFeatureCall) featureCall.getMemberCallTarget();
LightweightTypeReference type = getType(superCall);
assertEquals("java.util.ArrayList<java.lang.String>", type.getIdentifier());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug345827_04.
@Test
public void testBug345827_04() throws Exception {
XtendFunction function = function("def String name(String param) {\n" + " var name = ''\n" + " name('param')" + "}");
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 testDeclaredConstructor_01.
@Test
public void testDeclaredConstructor_01() throws Exception {
XtendClass clazz = clazz("class Foo { " + " int i" + " new(int i) { this.i = i }" + "}");
assertEquals(2, clazz.getMembers().size());
XtendConstructor constructor = (XtendConstructor) clazz.getMembers().get(1);
XAssignment assignment = (XAssignment) ((XBlockExpression) constructor.getExpression()).getExpressions().get(0);
JvmField field = (JvmField) assignment.getFeature();
assertEquals("i", field.getSimpleName());
XFeatureCall target = (XFeatureCall) assignment.getAssignable();
JvmDeclaredType identifiableElement = (JvmDeclaredType) target.getFeature();
assertEquals("Foo", identifiableElement.getSimpleName());
XFeatureCall value = (XFeatureCall) assignment.getValue();
JvmFormalParameter parameter = (JvmFormalParameter) value.getFeature();
assertEquals("i", parameter.getSimpleName());
}
Aggregations