Search in sources :

Example 1 with ProjectDescription

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

the class BuildManager method internalBuild.

protected List<IResourceDescription.Delta> internalBuild(final CancelIndicator cancelIndicator) {
    final ArrayList<URI> allDirty = new ArrayList<URI>(this.dirtyFiles);
    final HashMultimap<ProjectDescription, URI> project2dirty = HashMultimap.<ProjectDescription, URI>create();
    for (final URI dirty : allDirty) {
        {
            final ProjectDescription projectManager = this.workspaceManager.getProjectManager(dirty).getProjectDescription();
            project2dirty.put(projectManager, dirty);
        }
    }
    final HashMultimap<ProjectDescription, URI> project2deleted = HashMultimap.<ProjectDescription, URI>create();
    for (final URI deleted : this.deletedFiles) {
        {
            final ProjectDescription projectManager = this.workspaceManager.getProjectManager(deleted).getProjectDescription();
            project2deleted.put(projectManager, deleted);
        }
    }
    Set<ProjectDescription> _keySet = project2dirty.keySet();
    Set<ProjectDescription> _keySet_1 = project2deleted.keySet();
    Iterable<ProjectDescription> _plus = Iterables.<ProjectDescription>concat(_keySet, _keySet_1);
    final List<ProjectDescription> sortedDescriptions = this.sortByDependencies(_plus);
    final ArrayList<IResourceDescription.Delta> result = CollectionLiterals.<IResourceDescription.Delta>newArrayList();
    for (final ProjectDescription it : sortedDescriptions) {
        {
            final ProjectManager projectManager = this.workspaceManager.getProjectManager(it.getName());
            final List<URI> projectDirty = IterableExtensions.<URI>toList(project2dirty.get(it));
            final List<URI> projectDeleted = IterableExtensions.<URI>toList(project2deleted.get(it));
            final IncrementalBuilder.Result partialResult = projectManager.doBuild(projectDirty, projectDeleted, result, cancelIndicator);
            final Function1<IResourceDescription.Delta, URI> _function = (IResourceDescription.Delta it_1) -> {
                return it_1.getUri();
            };
            allDirty.addAll(ListExtensions.<IResourceDescription.Delta, URI>map(partialResult.getAffectedResources(), _function));
            Iterables.removeAll(this.dirtyFiles, projectDirty);
            Iterables.removeAll(this.deletedFiles, projectDeleted);
            result.addAll(partialResult.getAffectedResources());
        }
    }
    return result;
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) ArrayList(java.util.ArrayList) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) URI(org.eclipse.emf.common.util.URI) ProjectManager(org.eclipse.xtext.ide.server.ProjectManager) ArrayList(java.util.ArrayList) List(java.util.List) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription)

Example 2 with ProjectDescription

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

the class BuildManager method doInitialBuild.

public List<IResourceDescription.Delta> doInitialBuild(final List<ProjectDescription> projects, final CancelIndicator indicator) {
    final List<ProjectDescription> sortedDescriptions = this.sortByDependencies(projects);
    final ArrayList<IResourceDescription.Delta> result = CollectionLiterals.<IResourceDescription.Delta>newArrayList();
    for (final ProjectDescription description : sortedDescriptions) {
        {
            final IncrementalBuilder.Result partialresult = this.workspaceManager.getProjectManager(description.getName()).doInitialBuild(indicator);
            result.addAll(partialresult.getAffectedResources());
        }
    }
    return result;
}
Also used : ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription)

Example 3 with ProjectDescription

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

the class BuildOrderTest method testCycle1.

@Test
public void testCycle1() {
    ProjectDescription _projectDescription = new ProjectDescription();
    final Procedure1<ProjectDescription> _function = (ProjectDescription it) -> {
        it.setName("a");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("a")));
    };
    final ProjectDescription a = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function);
    final ArrayList<ProjectDescription> cyclic = CollectionLiterals.<ProjectDescription>newArrayList();
    final Procedure1<ProjectDescription> _function_1 = (ProjectDescription it) -> {
        cyclic.add(it);
    };
    this.assertEquals(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList()), new TopologicalSorter().sortByDependencies(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(a)), _function_1));
    this.assertEquals(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(a)), cyclic);
}
Also used : TopologicalSorter(org.eclipse.xtext.ide.server.TopologicalSorter) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription) Test(org.junit.Test)

Example 4 with ProjectDescription

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

the class BuildOrderTest method testJustOne.

@Test
public void testJustOne() {
    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");
    };
    final ProjectDescription b = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription_1, _function_1);
    final Procedure1<ProjectDescription> _function_2 = (ProjectDescription it) -> {
        Assert.fail();
    };
    this.assertEquals(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(a)), new TopologicalSorter().sortByDependencies(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(a)), _function_2));
    final Procedure1<ProjectDescription> _function_3 = (ProjectDescription it) -> {
        Assert.fail();
    };
    this.assertEquals(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(b)), new TopologicalSorter().sortByDependencies(Collections.<ProjectDescription>unmodifiableList(CollectionLiterals.<ProjectDescription>newArrayList(b)), _function_3));
}
Also used : TopologicalSorter(org.eclipse.xtext.ide.server.TopologicalSorter) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription) Test(org.junit.Test)

Example 5 with ProjectDescription

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

the class BuildOrderTest method testDiamond_1.

@Test
public void testDiamond_1() {
    ProjectDescription _projectDescription = new ProjectDescription();
    final Procedure1<ProjectDescription> _function = (ProjectDescription it) -> {
        it.setName("a");
        it.setDependencies(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("b", "c", "d")));
    };
    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