use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class UTF8ParserErrorTest method testInvalidReference_02.
@Test
public void testInvalidReference_02() throws Exception {
XtendFunction func = function("def m() { invalid\\u0020Part }");
XBlockExpression block = (XBlockExpression) func.getExpression();
XFeatureCall featureCall = (XFeatureCall) block.getExpressions().get(0);
String featureName = featureCall.getConcreteSyntaxFeatureName();
assertEquals("invalid\\u0020Part", featureName);
assertTrue(featureCall.getFeature().eIsProxy());
List<Diagnostic> errorList = func.eResource().getErrors();
assertEquals(2, errorList.size());
XtextLinkingDiagnostic diagnostic = (XtextLinkingDiagnostic) errorList.get(1);
assertTrue(diagnostic.getMessage().contains("invalidPart"));
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class Bug409780Test method testConstraintsInfluenceType.
@Test
public void testConstraintsInfluenceType() throws Exception {
XtendFile file = file("class C {\n" + " def private a(Iterable<CharSequence> it) {\n" + " map[ b ]\n" + " }\n" + " def private <T extends Appendable> T b(CharSequence 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("org.eclipse.xtext.xbase.lib.IterableExtensions.map(java.lang.Iterable,org.eclipse.xtext.xbase.lib.Functions$Function1)", method.getIdentifier());
assertTrue(featureCall.isStatic());
assertTrue(featureCall.isExtension());
assertFalse(featureCall.isTypeLiteral());
LightweightTypeReference type = getType(featureCall);
assertEquals("java.lang.Iterable<java.lang.Appendable>", type.getIdentifier());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testTypeOfSuperInConstructor.
@Test
public void testTypeOfSuperInConstructor() throws Exception {
XtendConstructor constructor = constructor("new() {\n" + " super()\n" + "}\n");
XBlockExpression body = (XBlockExpression) constructor.getExpression();
XFeatureCall superCall = (XFeatureCall) body.getExpressions().get(0);
assertEquals("void", getType(superCall).getIdentifier());
assertNull(getExpectedType(superCall));
assertNull(getExpectedReturnType(superCall));
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testExpectationRelevantExpressionType_05.
@Test
public void testExpectationRelevantExpressionType_05() throws Exception {
String clazzString = "class C<T> {\n" + " def String m(String s, Class<? super T>[] types) {\n" + " this.m('', newArrayList)\n" + " }\n" + "}";
XtendClass clazz = (XtendClass) file(clazzString, false).getXtendTypes().get(0);
XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) function.getExpression();
XMemberFeatureCall invocation = (XMemberFeatureCall) body.getExpressions().get(0);
XFeatureCall newArrayList = (XFeatureCall) invocation.getActualArguments().get(1);
assertEquals("newArrayList", newArrayList.getFeature().getSimpleName());
assertEquals("Class<? super T>[]", getExpectedType(newArrayList).getSimpleName());
assertEquals("ArrayList<Class<? super T>>", getType(newArrayList).getSimpleName());
}
use of org.eclipse.xtext.xbase.XFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testExpectationRelevantExpressionType_03.
@Test
public void testExpectationRelevantExpressionType_03() throws Exception {
String clazzString = "class C {\n" + " def m() {\n" + " typeof(C).getMethod('', newArrayList)\n" + " }\n" + "}";
XtendClass clazz = (XtendClass) file(clazzString, false).getXtendTypes().get(0);
XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) function.getExpression();
XMemberFeatureCall invocation = (XMemberFeatureCall) body.getExpressions().get(0);
XFeatureCall newArrayList = (XFeatureCall) invocation.getActualArguments().get(1);
assertEquals("newArrayList", newArrayList.getFeature().getSimpleName());
assertEquals("Class<?>[]", getExpectedType(newArrayList).getSimpleName());
assertEquals("ArrayList<Class<?>>", getType(newArrayList).getSimpleName());
}
Aggregations