Search in sources :

Example 6 with ProjectDescription

use of org.eclipse.xtext.resource.impl.ProjectDescription in project xtext-core by eclipse.

the class DefaultProjectDescriptionFactory method getProjectDescription.

@Override
public ProjectDescription getProjectDescription(final IProjectConfig config) {
    ProjectDescription _projectDescription = new ProjectDescription();
    final Procedure1<ProjectDescription> _function = (ProjectDescription it) -> {
        it.setName(config.getName());
    };
    return ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function);
}
Also used : ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription)

Example 7 with ProjectDescription

use of org.eclipse.xtext.resource.impl.ProjectDescription in project xtext-core 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.testing.util.InMemoryURIHandler) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription)

Example 8 with ProjectDescription

use of org.eclipse.xtext.resource.impl.ProjectDescription in project xtext-core by eclipse.

the class BuildOrderTest method testCycle.

@Test
public void testCycle() {
    ProjectDescription _projectDescription = new ProjectDescription();
    final Procedure1<ProjectDescription> _function = (ProjectDescription it) -> {
        it.setName("a");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("b", "c")));
    };
    final ProjectDescription a = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function);
    ProjectDescription _projectDescription_1 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_1 = (ProjectDescription it) -> {
        it.setName("b");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("c", "d")));
    };
    final ProjectDescription b = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_1, _function_1);
    ProjectDescription _projectDescription_2 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_2 = (ProjectDescription it) -> {
        it.setName("c");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("d")));
    };
    final ProjectDescription c = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_2, _function_2);
    ProjectDescription _projectDescription_3 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_3 = (ProjectDescription it) -> {
        it.setName("d");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("b")));
    };
    final ProjectDescription d = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_3, _function_3);
    ProjectDescription _projectDescription_4 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_4 = (ProjectDescription it) -> {
        it.setName("e");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList()));
    };
    final ProjectDescription e = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_4, _function_4);
    final ArrayList<ProjectDescription> cyclic = CollectionLiterals.<ProjectDescription>newArrayList();
    final Procedure1<ProjectDescription> _function_5 = (ProjectDescription it) -> {
        cyclic.add(it);
    };
    this.assertEquals(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(e)), new TopologicalSorter().sortByDependencies(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(a, b, c, d, e)), _function_5));
    this.assertEquals(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(b, d, c, a)), cyclic);
}
Also used : TopologicalSorter(org.eclipse.xtext.ide.server.TopologicalSorter) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription) Test(org.junit.Test)

Example 9 with ProjectDescription

use of org.eclipse.xtext.resource.impl.ProjectDescription in project xtext-core by eclipse.

the class BuildOrderTest method testDiamond.

@Test
public void testDiamond() {
    ProjectDescription _projectDescription = new ProjectDescription();
    final Procedure1<ProjectDescription> _function = (ProjectDescription it) -> {
        it.setName("a");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("b", "c")));
    };
    final ProjectDescription a = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function);
    ProjectDescription _projectDescription_1 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_1 = (ProjectDescription it) -> {
        it.setName("b");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("c")));
    };
    final ProjectDescription b = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_1, _function_1);
    ProjectDescription _projectDescription_2 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_2 = (ProjectDescription it) -> {
        it.setName("c");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("d")));
    };
    final ProjectDescription c = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_2, _function_2);
    ProjectDescription _projectDescription_3 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_3 = (ProjectDescription it) -> {
        it.setName("d");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList()));
    };
    final ProjectDescription d = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_3, _function_3);
    final Procedure1<ProjectDescription> _function_4 = (ProjectDescription it) -> {
        Assert.fail();
    };
    this.assertEquals(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(d, c, b, a)), new TopologicalSorter().sortByDependencies(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(a, b, c, d)), _function_4));
}
Also used : TopologicalSorter(org.eclipse.xtext.ide.server.TopologicalSorter) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription) Test(org.junit.Test)

Example 10 with ProjectDescription

use of org.eclipse.xtext.resource.impl.ProjectDescription in project xtext-core by eclipse.

the class BuildOrderTest method testChain.

@Test
public void testChain() {
    ProjectDescription _projectDescription = new ProjectDescription();
    final Procedure1<ProjectDescription> _function = (ProjectDescription it) -> {
        it.setName("a");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("b")));
    };
    final ProjectDescription a = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function);
    ProjectDescription _projectDescription_1 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_1 = (ProjectDescription it) -> {
        it.setName("b");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("c")));
    };
    final ProjectDescription b = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_1, _function_1);
    ProjectDescription _projectDescription_2 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_2 = (ProjectDescription it) -> {
        it.setName("c");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("d")));
    };
    final ProjectDescription c = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_2, _function_2);
    ProjectDescription _projectDescription_3 = new ProjectDescription();
    final Procedure1<ProjectDescription> _function_3 = (ProjectDescription it) -> {
        it.setName("d");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList()));
    };
    final ProjectDescription d = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_3, _function_3);
    final Procedure1<ProjectDescription> _function_4 = (ProjectDescription it) -> {
        Assert.fail();
    };
    this.assertEquals(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(d, c, b, a)), new TopologicalSorter().sortByDependencies(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(a, b, c, d)), _function_4));
}
Also used : TopologicalSorter(org.eclipse.xtext.ide.server.TopologicalSorter) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription) Test(org.junit.Test)

Aggregations

ProjectDescription (org.eclipse.xtext.resource.impl.ProjectDescription)12 TopologicalSorter (org.eclipse.xtext.ide.server.TopologicalSorter)6 Test (org.junit.Test)6 ChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions)3 URI (org.eclipse.emf.common.util.URI)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 IContainer (org.eclipse.xtext.resource.IContainer)2 LiveShadowedChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 URIHandler (org.eclipse.emf.ecore.resource.URIHandler)1 BuildRequest (org.eclipse.xtext.build.BuildRequest)1 IndexState (org.eclipse.xtext.build.IndexState)1 Source2GeneratedMapping (org.eclipse.xtext.build.Source2GeneratedMapping)1 ProjectManager (org.eclipse.xtext.ide.server.ProjectManager)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 ResourceDescriptionsData (org.eclipse.xtext.resource.impl.ResourceDescriptionsData)1 InMemoryURIHandler (org.eclipse.xtext.testing.util.InMemoryURIHandler)1 Issue (org.eclipse.xtext.validation.Issue)1