Search in sources :

Example 11 with BuildRequest

use of org.eclipse.xtext.build.BuildRequest in project xtext-xtend by eclipse.

the class XtendIncrementalBuilderTest method testIssue52.

/**
 * tests https://github.com/eclipse/xtext-core/issues/52
 */
@Test
public void testIssue52() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package a");
        _builder.newLine();
        _builder.newLine();
        _builder.append("import b.B");
        _builder.newLine();
        _builder.append("import org.eclipse.xtend.lib.annotations.Accessors");
        _builder.newLine();
        _builder.newLine();
        _builder.append("class A {");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("@Accessors String version");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new (String x, B b) {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("@Accessors");
        _builder.newLine();
        _builder.append("class A1 {");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("var String a");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/a/A.xtend", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package b");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("import a.A");
        _builder_1.newLine();
        _builder_1.append("import org.eclipse.xtend.lib.annotations.Accessors");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("class B {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("@Accessors String version");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("def doSth() {");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("val a = new A");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("a.toString");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("def doSomethingElse(String a) {");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("a.length + 1");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        URI _minus_1 = this.operator_minus("src/b/B.xtend", _builder_1.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1)));
    };
    this.build(this.newBuildRequest(_function));
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    final Procedure1<BuildRequest> _function_1 = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package a");
        _builder.newLine();
        _builder.newLine();
        _builder.append("import b.B");
        _builder.newLine();
        _builder.append("import org.eclipse.xtend.lib.annotations.Accessors");
        _builder.newLine();
        _builder.newLine();
        _builder.append("class A {");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("@Accessors String version");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new (String x, B b) {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("@Accessors");
        _builder.newLine();
        _builder.append("class A1 {");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("var String a");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/a/A.xtend", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package b");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("import a.A");
        _builder_1.newLine();
        _builder_1.append("import org.eclipse.xtend.lib.annotations.Accessors");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("class B {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("@Accessors String version");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("def doSth() {");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("val a = new A");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("a.toString");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("def doSomethingElse(String a) {");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("a.length + 1");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        URI _minus_1 = this.operator_minus("src/b/B.xtend", _builder_1.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1)));
    };
    this.build(this.newBuildRequest(_function_1));
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) AbstractIncrementalBuilderTest(org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest) Test(org.junit.Test)

Example 12 with BuildRequest

use of org.eclipse.xtext.build.BuildRequest in project xtext-xtend by eclipse.

the class XtendIncrementalBuilderTest method testPackageInfo.

@Test
public void testPackageInfo() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package foo;");
        _builder.newLine();
        URI _minus = this.operator_minus("src/foo/package-info.java", _builder.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
    };
    final BuildRequest buildRequest = this.newBuildRequest(_function);
    this.build(buildRequest);
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) AbstractIncrementalBuilderTest(org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest) Test(org.junit.Test)

Example 13 with BuildRequest

use of org.eclipse.xtext.build.BuildRequest in project xtext-xtend by eclipse.

the class XtendIncrementalBuilderTest method testSimpleMixedBuild_02.

@Test
public void testSimpleMixedBuild_02() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class A {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def void doStuff(mypack.MyClass obj) {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("val A x = obj.a");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("println(\"Juhu \"+x)");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/MyFile.xtend", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package mypack;");
        _builder_1.newLine();
        _builder_1.append("class MyClass {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("public A a;");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        URI _minus_1 = this.operator_minus("src/mypack/MyClass.java", _builder_1.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1)));
    };
    final BuildRequest buildRequest = this.newBuildRequest(_function);
    this.build(buildRequest);
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    Assert.assertEquals(2, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/A.java"));
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) AbstractIncrementalBuilderTest(org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest) Test(org.junit.Test)

Example 14 with BuildRequest

use of org.eclipse.xtext.build.BuildRequest in project xtext-xtend by eclipse.

the class XtendIncrementalBuilderTest method testGrammarAccessproblem.

@Test
public void testGrammarAccessproblem() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypack;");
        _builder.newLine();
        _builder.append("public class FakeIssue60GrammarAccess {");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("private final GreetingElements pGreeting;");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public FakeIssue60GrammarAccess() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("this.pGreeting = new GreetingElements();");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public class GreetingElements {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("public String getHelloKeyword_0() { return null; }");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public GreetingElements getGreetingAccess() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("return pGreeting;");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/mypack/FakeIssue60GrammarAccess.java", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package mypack");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("import mypack.FakeIssue60GrammarAccess$GreetingElements");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("class Demo {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("extension mypack.FakeIssue60GrammarAccess");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("GreetingElements elements");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("def void format() {");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("greetingAccess.helloKeyword_0");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("println(elements)");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        URI _minus_1 = this.operator_minus("src/mypack/Demo.xtend", _builder_1.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1)));
    };
    final BuildRequest buildRequest = this.newBuildRequest(_function);
    this.build(buildRequest);
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    Assert.assertEquals(2, this.generated.size());
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) AbstractIncrementalBuilderTest(org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest) Test(org.junit.Test)

Example 15 with BuildRequest

use of org.eclipse.xtext.build.BuildRequest in project xtext-xtend by eclipse.

the class XtendIncrementalBuilderTest method testSimpleMixedBuild_03.

@Test
public void testSimpleMixedBuild_03() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class A extends mypack.MyClass {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def void doStuff(A obj) {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("val A x = obj.a");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("val mypack.MyClass x2 = obj.myClass");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("println(\"Juhu \"+x+\' - \'+x2.a)");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/MyFile.xtend", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package mypack;");
        _builder_1.newLine();
        _builder_1.append("public class MyClass extends Third {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("public A a;");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        URI _minus_1 = this.operator_minus("src/mypack/MyClass.java", _builder_1.toString());
        StringConcatenation _builder_2 = new StringConcatenation();
        _builder_2.append("package mypack");
        _builder_2.newLine();
        _builder_2.append("class Third {");
        _builder_2.newLine();
        _builder_2.append("\t");
        _builder_2.append("public MyClass myClass");
        _builder_2.newLine();
        _builder_2.append("}");
        _builder_2.newLine();
        URI _minus_2 = this.operator_minus("src/mypack/Third.xtend", _builder_2.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus, _minus_1, _minus_2)));
    };
    final BuildRequest buildRequest = this.newBuildRequest(_function);
    this.build(buildRequest);
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    Assert.assertEquals(4, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/A.java"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/.A.java._trace"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/mypack/Third.java"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "xtend-gen/mypack/.Third.java._trace"));
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) AbstractIncrementalBuilderTest(org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest) Test(org.junit.Test)

Aggregations

URI (org.eclipse.emf.common.util.URI)24 BuildRequest (org.eclipse.xtext.build.BuildRequest)24 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)20 AbstractIncrementalBuilderTest (org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest)20 Test (org.junit.Test)20 IndexState (org.eclipse.xtext.build.IndexState)4 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)4 Procedure2 (org.eclipse.xtext.xbase.lib.Procedures.Procedure2)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Source2GeneratedMapping (org.eclipse.xtext.build.Source2GeneratedMapping)3 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)3 ChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions)3 ResourceDescriptionsData (org.eclipse.xtext.resource.impl.ResourceDescriptionsData)3 Issue (org.eclipse.xtext.validation.Issue)3 URIHandler (org.eclipse.emf.ecore.resource.URIHandler)2 OutputConfiguration (org.eclipse.xtext.generator.OutputConfiguration)2 ProjectDescription (org.eclipse.xtext.resource.impl.ProjectDescription)2 IncrementalBuilder (org.eclipse.xtext.build.IncrementalBuilder)1 InMemoryURIHandler (org.eclipse.xtext.junit4.util.InMemoryURIHandler)1 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)1