use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_00_b.
@Test
public void testImplicitFirstArgument_00_b() throws Exception {
XtendClass clazz = clazz("class MyXtendClass {\n" + " def prependHello(String myString) {\n" + " }\n" + " def testExtensionMethods(String it) {\n" + " prependHello\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(1);
XFeatureCall first = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation firstFeature = (JvmOperation) first.getFeature();
assertEquals("prependHello", firstFeature.getSimpleName());
assertNull(first.getInvalidFeatureIssueCode(), first.getInvalidFeatureIssueCode());
assertNotNull(first.getImplicitFirstArgument());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_10.
@Test
public void testExtensionMethodCall_10() throws Exception {
XtendClass clazz = clazz("" + "class C {" + " def m() {\n" + " ''.m('', '', '')\n" + " ''.m\n" + " this.m('')\n" + " }\n" + " def void m(String s, String... s2) {" + " }" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression block = (XBlockExpression) func.getExpression();
for (XExpression element : block.getExpressions()) {
XMemberFeatureCall call = (XMemberFeatureCall) element;
assertFalse(call.getFeature().eIsProxy());
assertEquals("C.m(java.lang.String,java.lang.String[])", call.getFeature().getIdentifier());
}
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_06.
@Test
public void testImplicitFirstArgument_06() throws Exception {
XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + " def testExtensionMethods(CharSequence it) {\n" + " contains\n" + " }\n" + " extension String" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XFeatureCall sixth = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation sixthFeature = (JvmOperation) sixth.getFeature();
assertEquals("java.lang.String.contains(java.lang.CharSequence)", sixthFeature.getIdentifier());
assertEquals("java.lang.String", sixthFeature.getDeclaringType().getQualifiedName());
assertNotNull(sixth.getImplicitFirstArgument());
assertEquals("it", ((XAbstractFeatureCall) sixth.getImplicitFirstArgument()).getFeature().getSimpleName());
XMemberFeatureCall sixthReceiver = (XMemberFeatureCall) sixth.getImplicitReceiver();
assertTrue(sixthReceiver.getFeature() instanceof JvmField);
assertNull(sixth.getInvalidFeatureIssueCode(), sixth.getInvalidFeatureIssueCode());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testBug403580_05.
@Test
public void testBug403580_05() throws Exception {
XtendFile file = file("abstract class C {\n" + " def void m() {\n" + " overloaded [ String s | s ]\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(org.eclipse.xtext.xbase.lib.Functions$Function1)", method.getIdentifier());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class LinkingTest method testBug405144_01.
@Test
public void testBug405144_01() throws Exception {
XtendFile file = file("import com.google.inject.Injector\n" + "class C {\n" + " def m(Injector i, Class<? extends CharSequence> c) {\n" + " i.getInstance(c)\n" + " }\n" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement method = featureCall.getFeature();
assertEquals("com.google.inject.Injector.getInstance(java.lang.Class)", method.getIdentifier());
}
Aggregations