Search in sources :

Example 91 with XtendFile

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

the class ValidationBug437678Test method test_10.

@Test
public void test_10() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class A {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def methodA(B b) {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        _builder.append("class B {}");
        _builder.newLine();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("static extension A");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def static void m(B it) {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("methodA");
        _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 92 with XtendFile

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

the class ValidationBug437678Test method test_05.

@Test
public void test_05() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class A {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def methodA() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("extension A");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def static void m() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("methodA");
        _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.XFEATURE_CALL, IssueCodes.STATIC_ACCESS_TO_INSTANCE_MEMBER, "Cannot make an implicit static reference to the non-static extension methodA");
    } 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 93 with XtendFile

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

the class ValidationBug447516Test method test_01.

@Test
public void test_01() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("import org.eclipse.xtext.util.concurrent.IReadAccess");
        _builder.newLine();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public val IReadAccess<CharSequence> stateAccess = [ return \"\" ]");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this.parser.parse(_builder);
        this.helper.assertError(file, XbasePackage.Literals.XSTRING_LITERAL, IssueCodes.INCOMPATIBLE_TYPES, "Type mismatch: cannot convert from String to T");
    } 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 94 with XtendFile

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

the class ValidationBug450834Test method test_01.

@Test
public void test_01() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public static val c1 = 5");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile c = this.parser.parse(_builder);
        final ResourceSet resourceSet = c.eResource().getResourceSet();
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("class D {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("public static val d1 = 5");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("def void m() {");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("if (C.c1 == D.d1) {");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        final XtendFile d = this.parser.parse(_builder_1, resourceSet);
        this.helper.assertWarning(d, XbasePackage.Literals.XBINARY_OPERATION, IssueCodes.CONSTANT_BOOLEAN_CONDITION, "Constant condition is always true");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) Test(org.junit.Test)

Example 95 with XtendFile

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

the class ValidationBug464563Test method testJvmConstructor_10.

@Test
public void testJvmConstructor_10() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypackage");
        _builder.newLine();
        _builder.newLine();
        _builder.append("class Foo {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new (Unknown<?> arg0) {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def void bar() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("new Foo(notify)");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this._parseHelper.parse(_builder);
        this._validationTestHelper.assertError(file, XbasePackage.Literals.XCONSTRUCTOR_CALL, IssueCodes.REFER_INVALID_TYPES, "The constructor Foo(Unknown) refers to the missing type Unknown");
    } 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