Search in sources :

Example 51 with XtendFile

use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.

the class ValidationBug409602Test method test_06.

@Test
public void test_06() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def m() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("val ()=>void res = [|");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("if (\"\" == null) {");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("return");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("1");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("]");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("return res");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this.parser.parse(_builder);
        this.helper.assertError(file, XbasePackage.Literals.XNUMBER_LITERAL, IssueCodes.INVALID_INNER_EXPRESSION);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 52 with XtendFile

use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.

the class ValidationBug409602Test method test_18.

@Test
public void test_18() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def m() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("val ()=>void res = [|");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("if (\"\" == null) {");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("return 1");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("} else {");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("return");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("]");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("res");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this.parser.parse(_builder);
        this.helper.assertError(file, XbasePackage.Literals.XRETURN_EXPRESSION, IssueCodes.INVALID_RETURN, "Void functions cannot return a value.");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 53 with XtendFile

use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.

the class ValidationBug409602Test method test_20.

@Test
public void test_20() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def m() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("while(true)");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("return \'\'");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this.parser.parse(_builder);
        this.helper.assertNoErrors(file);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 54 with XtendFile

use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.

the class ValidationBug409602Test method test_21.

@Test
public void test_21() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def m(boolean b) {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("while(b)");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("return \'\'");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("return \'\'");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this.parser.parse(_builder);
        this.helper.assertNoErrors(file);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 55 with XtendFile

use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.

the class ValidationBug409602Test method test_14.

@Test
public void test_14() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def m() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("[|");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("if (\"\" == null) {");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("return");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("} else {");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("return 1");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("]");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this.parser.parse(_builder);
        this.helper.assertError(file, XbasePackage.Literals.XRETURN_EXPRESSION, IssueCodes.INVALID_RETURN, "Void functions cannot return a value.");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Aggregations

XtendFile (org.eclipse.xtend.core.xtend.XtendFile)855 Test (org.junit.Test)782 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)372 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)229 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)182 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)126 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)119 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)98 XExpression (org.eclipse.xtext.xbase.XExpression)82 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)64 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)62 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)62 EObject (org.eclipse.emf.ecore.EObject)50 Resource (org.eclipse.emf.ecore.resource.Resource)47 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)46 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)42 XtextResource (org.eclipse.xtext.resource.XtextResource)34 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)29 XtendField (org.eclipse.xtend.core.xtend.XtendField)23 IResolvedTypes (org.eclipse.xtext.xbase.typesystem.IResolvedTypes)21