Search in sources :

Example 6 with XIfExpression

use of org.eclipse.xtext.xbase.XIfExpression in project xtext-xtend by eclipse.

the class ErrorTest method testErrorModel_076.

@Test
public void testErrorModel_076() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def String m(boolean b) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("switch \'a\' {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("case \'b\': \'a\'");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("case \'c\': {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("if ");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("return \'b\'");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("else");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("return \'c\'");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this.processWithoutException(_builder);
    final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(file);
    final XIfExpression ifExpression = IteratorExtensions.<XIfExpression>head(Iterators.<XIfExpression>filter(file.eAllContents(), XIfExpression.class));
    Assert.assertNull(ifExpression.getThen());
    Assert.assertNull(ifExpression.getElse());
    Assert.assertNotNull(resolvedTypes.getActualType(ifExpression));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XIfExpression(org.eclipse.xtext.xbase.XIfExpression) IResolvedTypes(org.eclipse.xtext.xbase.typesystem.IResolvedTypes) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Aggregations

XIfExpression (org.eclipse.xtext.xbase.XIfExpression)6 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)5 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)4 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)4 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4 XExpression (org.eclipse.xtext.xbase.XExpression)4 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)4 XSwitchExpression (org.eclipse.xtext.xbase.XSwitchExpression)4 Test (org.junit.Test)4 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)3 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)3 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)2 EObject (org.eclipse.emf.ecore.EObject)1 EPackage (org.eclipse.emf.ecore.EPackage)1 RichString (org.eclipse.xtend.core.xtend.RichString)1 RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)1 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)1 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)1 XtendEnum (org.eclipse.xtend.core.xtend.XtendEnum)1 XtendField (org.eclipse.xtend.core.xtend.XtendField)1