Search in sources :

Example 21 with BuildRequest

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

the class IncrementalBuilderTest method testIndexOnly.

@Test
public void testIndexOnly() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        it.setIndexOnly(true);
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A {}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/MyFile.indextestlanguage", _builder.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
        final BuildRequest.IPostValidationCallback _function_1 = (URI $0, Iterable<Issue> $1) -> {
            throw new IllegalStateException();
        };
        it.setAfterValidate(_function_1);
        final Procedure2<URI, URI> _function_2 = (URI $0, URI $1) -> {
            throw new IllegalStateException();
        };
        it.setAfterGenerateFile(_function_2);
    };
    final BuildRequest buildRequest = this.newBuildRequest(_function);
    final IndexState result = this.build(buildRequest);
    Assert.assertEquals(1, IterableExtensions.size(result.getResourceDescriptions().getAllResourceDescriptions()));
}
Also used : Procedure2(org.eclipse.xtext.xbase.lib.Procedures.Procedure2) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) IndexState(org.eclipse.xtext.build.IndexState) AbstractIncrementalBuilderTest(org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest) Test(org.junit.Test)

Example 22 with BuildRequest

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

the class IncrementalBuilderTest method testNoCleanupBuild.

@Test
public void testNoCleanupBuild() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        final Procedure1<OutputConfiguration> _function_1 = (OutputConfiguration it_1) -> {
            it_1.setCleanUpDerivedResources(false);
        };
        this.withOutputConfig(it, _function_1);
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity B {}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A { foo.B myReference }");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/MyFile.indextestlanguage", _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());
    Assert.assertEquals(2, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
    final Procedure1<BuildRequest> _function_1 = (BuildRequest it) -> {
        final Procedure1<OutputConfiguration> _function_2 = (OutputConfiguration it_1) -> {
            it_1.setCleanUpDerivedResources(false);
        };
        this.withOutputConfig(it, _function_2);
        URI _delete = this.delete(this.uri("src/A.indextestlanguage"));
        it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_delete)));
    };
    this.newBuildRequest(_function_1);
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    Assert.assertEquals(2, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
}
Also used : OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) 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 23 with BuildRequest

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

the class IncrementalBuilderTest method testGeneratedOnceBuild.

@Test
public void testGeneratedOnceBuild() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        final Procedure1<OutputConfiguration> _function_1 = (OutputConfiguration it_1) -> {
            it_1.setOverrideExistingResources(false);
        };
        this.withOutputConfig(it, _function_1);
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity B {}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A { foo.B myReference }");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/MyFile.indextestlanguage", _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());
    Assert.assertEquals(2, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
    final Procedure1<BuildRequest> _function_1 = (BuildRequest it) -> {
        final Procedure1<OutputConfiguration> _function_2 = (OutputConfiguration it_1) -> {
            it_1.setOverrideExistingResources(false);
        };
        this.withOutputConfig(it, _function_2);
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity B {}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A { foo.B someReference }");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/MyFile.indextestlanguage", _builder.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
        final Procedure2<URI, URI> _function_3 = (URI $0, URI $1) -> {
            Assert.fail();
        };
        it.setAfterGenerateFile(_function_3);
    };
    this.newBuildRequest(_function_1);
}
Also used : OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) Procedure2(org.eclipse.xtext.xbase.lib.Procedures.Procedure2) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) 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 24 with BuildRequest

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

the class IncrementalBuilderTest method testIncrementalBuild.

@Test
public void testIncrementalBuild() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A {foo.B reference}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/A.indextestlanguage", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("foo {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("entity B {foo.A reference}");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        URI _minus_1 = this.operator_minus("src/B.indextestlanguage", _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());
    Assert.assertEquals(2, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
    final Procedure1<BuildRequest> _function_1 = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A {foo.B reference}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/A.indextestlanguage", _builder.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
    };
    this.build(this.newBuildRequest(_function_1));
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    Assert.assertEquals(1, this.generated.size());
    Assert.assertFalse(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
    final Procedure1<BuildRequest> _function_2 = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity X { foo.B reference }");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/A.indextestlanguage", _builder.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
    };
    this.build(this.newBuildRequest(_function_2));
    Assert.assertEquals(this.issues.toString(), 1, this.issues.size());
    Assert.assertEquals(1, this.generated.size());
    Assert.assertFalse(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/X.txt"));
    Assert.assertEquals(1, this.indexState.getFileMappings().getGenerated(this.uri("src/A.indextestlanguage")).size());
    Assert.assertEquals(1, this.deleted.size());
    Assert.assertTrue(this.containsSuffix(this.deleted, "src-gen/A.txt"));
    final Procedure1<BuildRequest> _function_3 = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A { foo.B reference }");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/A.indextestlanguage", _builder.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
    };
    this.build(this.newBuildRequest(_function_3));
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    Assert.assertEquals(2, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
    Assert.assertTrue(this.containsSuffix(this.deleted, "src-gen/X.txt"));
    final Procedure1<BuildRequest> _function_4 = (BuildRequest it) -> {
        URI _delete = this.delete(this.uri("src/A.indextestlanguage"));
        it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_delete)));
    };
    this.build(this.newBuildRequest(_function_4));
    Assert.assertEquals(this.issues.toString(), 1, this.issues.size());
    Assert.assertEquals(0, this.generated.size());
    Assert.assertEquals(1, this.deleted.size());
    Assert.assertTrue(this.containsSuffix(this.deleted, "src-gen/A.txt"));
}
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