Search in sources :

Example 1 with BuildRequest

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

the class AbstractIncrementalBuilderTest method newBuildRequest.

protected BuildRequest newBuildRequest(final Procedure1<? super BuildRequest> init) {
    BuildRequest _buildRequest = new BuildRequest();
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        final ResourceDescriptionsData newIndex = this.indexState.getResourceDescriptions().copy();
        it.setBaseDir(this.uri(""));
        XtextResourceSet _get = this.resourceSetProvider.get();
        final Procedure1<XtextResourceSet> _function_1 = (XtextResourceSet it_1) -> {
            it_1.getURIConverter().getURIHandlers().clear();
            EList<URIHandler> _uRIHandlers = it_1.getURIConverter().getURIHandlers();
            _uRIHandlers.add(this.inMemoryURIHandler);
            it_1.setClasspathURIContext(AbstractIncrementalBuilderTest.class.getClassLoader());
            ProjectDescription _projectDescription = new ProjectDescription();
            final Procedure1<ProjectDescription> _function_2 = (ProjectDescription it_2) -> {
                it_2.setName("test-project");
            };
            final ProjectDescription projectDescription = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function_2);
            projectDescription.attachToEmfObject(it_1);
            Map<String, ResourceDescriptionsData> _emptyMap = CollectionLiterals.<String, ResourceDescriptionsData>emptyMap();
            final ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(_emptyMap, it_1);
            index.setContainer(projectDescription.getName(), newIndex);
        };
        XtextResourceSet _doubleArrow = ObjectExtensions.<XtextResourceSet>operator_doubleArrow(_get, _function_1);
        it.setResourceSet(_doubleArrow);
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
        it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
        final BuildRequest.IPostValidationCallback _function_2 = (URI uri, Iterable<Issue> issues) -> {
            Iterables.<Issue>addAll(this.issues, issues);
            return IterableExtensions.isEmpty(issues);
        };
        it.setAfterValidate(_function_2);
        final Procedure1<URI> _function_3 = (URI it_1) -> {
            this.deleted.add(it_1);
        };
        it.setAfterDeleteFile(_function_3);
        final Procedure2<URI, URI> _function_4 = (URI source, URI target) -> {
            this.generated.put(source, target);
        };
        it.setAfterGenerateFile(_function_4);
        Source2GeneratedMapping _copy = this.indexState.getFileMappings().copy();
        IndexState _indexState = new IndexState(newIndex, _copy);
        it.setState(_indexState);
    };
    final BuildRequest result = ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function);
    init.apply(result);
    return result;
}
Also used : Issue(org.eclipse.xtext.validation.Issue) Source2GeneratedMapping(org.eclipse.xtext.build.Source2GeneratedMapping) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) IndexState(org.eclipse.xtext.build.IndexState) ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Procedure2(org.eclipse.xtext.xbase.lib.Procedures.Procedure2) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) URIHandler(org.eclipse.emf.ecore.resource.URIHandler) InMemoryURIHandler(org.eclipse.xtext.junit4.util.InMemoryURIHandler) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription)

Example 2 with BuildRequest

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

the class XtendIncrementalBuilderTest method testSimpleMixedBuild04.

@Test
public void testSimpleMixedBuild04() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("import b.B");
        _builder.newLine();
        _builder.append("class A {");
        _builder.newLine();
        _builder.append("   ");
        _builder.append("def foo() {");
        _builder.newLine();
        _builder.append("      ");
        _builder.append("B.foo");
        _builder.newLine();
        _builder.append("   ");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/A.xtend", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package b;");
        _builder_1.newLine();
        _builder_1.append("public class B {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("public static String foo;");
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        URI _minus_1 = this.operator_minus("src/b/B.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 3 with BuildRequest

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

the class XtendIncrementalBuilderTest method testSimpleMixedBuild.

@Test
public void testSimpleMixedBuild() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class A {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public mypack.MyClass someField");
        _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 String 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 4 with BuildRequest

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

the class XtendIncrementalBuilderTest method testInnerClassEnumProblem.

@Test
public void testInnerClassEnumProblem() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypack;");
        _builder.newLine();
        _builder.append("public class EnumTest {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public enum AB {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("A,");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("B");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        URI _minus = this.operator_minus("src/mypack/EnumTest.java", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package mypack");
        _builder_1.newLine();
        _builder_1.append("class Demo {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("def void format() {");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("var EnumTest.AB x = EnumTest.AB.A");
        _builder_1.newLine();
        _builder_1.append("\t\t");
        _builder_1.append("println(x)");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _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 5 with BuildRequest

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

the class ProjectManager method newBuildRequest.

protected BuildRequest newBuildRequest(final List<URI> changedFiles, final List<URI> deletedFiles, final List<IResourceDescription.Delta> externalDeltas, final CancelIndicator cancelIndicator) {
    BuildRequest _buildRequest = new BuildRequest();
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        it.setBaseDir(this.baseDir);
        ResourceDescriptionsData _copy = this.indexState.getResourceDescriptions().copy();
        Source2GeneratedMapping _copy_1 = this.indexState.getFileMappings().copy();
        IndexState _indexState = new IndexState(_copy, _copy_1);
        it.setState(_indexState);
        it.setResourceSet(this.createFreshResourceSet(it.getState().getResourceDescriptions()));
        it.setDirtyFiles(changedFiles);
        it.setDeletedFiles(deletedFiles);
        it.setExternalDeltas(externalDeltas);
        final BuildRequest.IPostValidationCallback _function_1 = (URI uri, Iterable<Issue> issues) -> {
            this.issueAcceptor.apply(uri, issues);
            return true;
        };
        it.setAfterValidate(_function_1);
        it.setCancelIndicator(cancelIndicator);
    };
    return ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function);
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) Source2GeneratedMapping(org.eclipse.xtext.build.Source2GeneratedMapping) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) IndexState(org.eclipse.xtext.build.IndexState)

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