use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testExplicitTypeOverSugar_01.
@Test
public void testExplicitTypeOverSugar_01() throws Exception {
XtendFile file = file("import static extension org.eclipse.emf.ecore.util.EcoreUtil.*\n" + "import org.eclipse.emf.ecore.EObject\n" + "import org.eclipse.emf.common.util.URI\n" + "\n" + "class C {\n" + " def m(EObject it) {\n" + " URI::createURI(\"someString\")\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("org.eclipse.emf.common.util.URI.createURI(java.lang.String)", method.getIdentifier());
assertTrue(featureCall.isStaticWithDeclaringType());
XFeatureCall target = (XFeatureCall) featureCall.getMemberCallTarget();
assertTrue(target.isTypeLiteral());
assertEquals("org.eclipse.emf.common.util.URI", target.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_01.
@Test
public void testImplicitFirstArgument_01() throws Exception {
XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + " def testExtensionMethods(CharSequence it) {\n" + " length\n" + " }\n" + " extension String" + " def length() { null }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XFeatureCall first = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation firstFeature = (JvmOperation) first.getFeature();
assertEquals("java.lang.CharSequence.length()", firstFeature.getIdentifier());
assertEquals("java.lang.CharSequence", firstFeature.getDeclaringType().getQualifiedName());
assertNull(first.getImplicitFirstArgument());
XFeatureCall firstReceiver = (XFeatureCall) first.getImplicitReceiver();
assertTrue(firstReceiver.getFeature() instanceof JvmFormalParameter);
assertNull(first.getInvalidFeatureIssueCode());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_00_a.
@Test
public void testImplicitFirstArgument_00_a() throws Exception {
XtendClass clazz = clazz("class MyXtendClass {\n" + " def prependHello(String myString) {\n" + " 'Hello '+myString\n" + " }\n" + " def testExtensionMethods(String it) {\n" + " it.prependHello\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(1);
XMemberFeatureCall first = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation firstFeature = (JvmOperation) first.getFeature();
assertEquals("prependHello", firstFeature.getSimpleName());
assertNull(first.getInvalidFeatureIssueCode(), first.getInvalidFeatureIssueCode());
XFeatureCall firstReceiver = (XFeatureCall) first.getImplicitReceiver();
assertEquals("MyXtendClass", firstReceiver.getFeature().getSimpleName());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class UnicodeEscapeLinkingTest method testIdentifiersWithUnicode_02.
@Test
public void testIdentifiersWithUnicode_02() throws Exception {
XtendClass clazz = clazz("class A {\n" + " String \\u0061\n" + " def m() {\n" + " a\n" + " }\n" + "}");
XFeatureCall call = (XFeatureCall) ((XBlockExpression) ((XtendFunction) clazz.getMembers().get(1)).getExpression()).getExpressions().get(0);
JvmIdentifiableElement feature = call.getFeature();
assertFalse(feature.eIsProxy());
assertSame(feature, associator.getJvmField((XtendField) clazz.getMembers().get(0)));
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class ParserTest method testFunction_2.
@Test
public void testFunction_2() throws Exception {
XtendFunction func = function("def foo(String s) {s}");
assertEquals("foo", func.getName());
assertTrue(((XBlockExpression) func.getExpression()).getExpressions().get(0) instanceof XFeatureCall);
assertEquals(1, func.getParameters().size());
assertEquals("s", func.getParameters().get(0).getName());
assertNotNull(func.getParameters().get(0).getParameterType());
assertNull(func.getReturnType());
assertEquals(0, func.getTypeParameters().size());
}
Aggregations