use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class UnicodeEscapeLinkingTest method testIdentifiersWithUnicode_01.
@Test
public void testIdentifiersWithUnicode_01() throws Exception {
XtendClass clazz = clazz("class A {\n" + " String a\n" + " def m() {\n" + " \\u0061\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.XBlockExpression in project xtext-xtend by eclipse.
the class ParserTest method testExtensionOnForLoopParam_01.
@Test
public void testExtensionOnForLoopParam_01() throws Exception {
XtendClass clazz = clazz("class Foo { def void m() { for(extension i: 1..2) {} } }");
assertEquals(1, clazz.getMembers().size());
XtendFunction m = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
assertEquals(1, body.getExpressions().size());
XForLoopExpression forLoop = (XForLoopExpression) body.getExpressions().get(0);
XtendFormalParameter parameter = (XtendFormalParameter) forLoop.getDeclaredParam();
assertTrue(parameter.isExtension());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class ParserTest method testExtensionOnLocalVar_01.
@Test
public void testExtensionOnLocalVar_01() throws Exception {
XtendClass clazz = clazz("class Foo { def m() { extension var s = '' } }");
assertEquals(1, clazz.getMembers().size());
XtendFunction m = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
assertEquals(1, body.getExpressions().size());
XtendVariableDeclaration variableDeclaration = (XtendVariableDeclaration) body.getExpressions().get(0);
assertTrue(variableDeclaration.isWriteable());
assertTrue(variableDeclaration.isExtension());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class ParserTest method testExtensionOnCatchClause_01.
@Test
public void testExtensionOnCatchClause_01() throws Exception {
XtendClass clazz = clazz("class Foo { def void m() { try {} catch(extension NullPointerException e) {} } }");
assertEquals(1, clazz.getMembers().size());
XtendFunction m = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
assertEquals(1, body.getExpressions().size());
XTryCatchFinallyExpression tryCatch = (XTryCatchFinallyExpression) body.getExpressions().get(0);
XCatchClause singleCatchClause = tryCatch.getCatchClauses().get(0);
XtendFormalParameter parameter = (XtendFormalParameter) singleCatchClause.getDeclaredParam();
assertTrue(parameter.isExtension());
}
use of org.eclipse.xtext.xbase.XBlockExpression in project xtext-xtend by eclipse.
the class ParserTest method testMultiCatch_02.
@Test
public void testMultiCatch_02() throws Exception {
XtendClass clazz = clazz("class Foo { def void m() { try {} catch(extension NullPointerException | IllegalArgumentException | IllegalStateException e) {} } }");
assertEquals(1, clazz.getMembers().size());
XtendFunction m = (XtendFunction) clazz.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
assertEquals(1, body.getExpressions().size());
XTryCatchFinallyExpression tryCatch = (XTryCatchFinallyExpression) body.getExpressions().get(0);
XCatchClause singleCatchClause = tryCatch.getCatchClauses().get(0);
XtendFormalParameter parameter = (XtendFormalParameter) singleCatchClause.getDeclaredParam();
assertTrue(parameter.isExtension());
JvmSynonymTypeReference parameterType = (JvmSynonymTypeReference) parameter.getParameterType();
assertEquals(3, parameterType.getReferences().size());
}
Aggregations