Search in sources :

Example 1 with BuildOrderInfo

use of org.eclipse.n4js.xtext.workspace.BuildOrderInfo in project n4js by eclipse.

the class MockWorkspaceSupplier method createWorkspaceConfig.

/**
 * Creates the configuration of the mocked test workspace.
 * <p>
 * The returned workspace configuration is expected to contain at least one project with at least one source folder
 * that isn't a {@link N4JSSourceFolderSnapshotForPackageJson}. The corresponding folders and files are not expected
 * to exist on disk.
 * <p>
 * Only invoked on demand and never more than once.
 */
protected N4JSWorkspaceConfigSnapshot createWorkspaceConfig() {
    N4JSProjectConfigSnapshot projectConfig = createProjectConfig();
    URI workspacePath = URIUtils.trimTrailingPathSeparator(projectConfig.getPath()).trimSegments(1);
    ProjectSet projects = new ProjectSet(Collections.singleton(projectConfig));
    BuildOrderInfo buildOrderInfo = new BuildOrderInfo(Collections.emptyList(), Collections.emptySet());
    return new N4JSWorkspaceConfigSnapshot(workspacePath, projects, buildOrderInfo);
}
Also used : BuildOrderInfo(org.eclipse.n4js.xtext.workspace.BuildOrderInfo) N4JSWorkspaceConfigSnapshot(org.eclipse.n4js.workspace.N4JSWorkspaceConfigSnapshot) N4JSProjectConfigSnapshot(org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot) URI(org.eclipse.emf.common.util.URI) FileURI(org.eclipse.n4js.workspace.locations.FileURI) ProjectSet(org.eclipse.n4js.xtext.workspace.ProjectSet)

Example 2 with BuildOrderInfo

use of org.eclipse.n4js.xtext.workspace.BuildOrderInfo in project n4js by eclipse.

the class AbstractBuildOrderTest method assertBuildOrder.

final void assertBuildOrder(String buildOrder, Collection<Collection<String>> cycles) {
    WorkspaceConfigSnapshot workspaceConfig = concurrentIndex.getWorkspaceConfigSnapshot();
    BuildOrderInfo projectBuildOrderInfo = projectBuildOrderFactory.createBuildOrderInfo(workspaceConfig);
    BuildOrderIterator boIterator = projectBuildOrderFactory.createBuildOrderIterator(workspaceConfig).visitAll();
    try {
        String names = IteratorExtensions.join(boIterator, ", ", it -> it.getName());
        assertEquals(buildOrder, names);
    } catch (Exception exc) {
        throw new RuntimeException("Never happens since toString never throws an exception. Bogus xtext warning", exc);
    }
    assertEquals(cycles.size(), projectBuildOrderInfo.getProjectCycles().size());
    Set<String> expectedCycles = cycles.stream().map(it -> Strings.join(", ", it)).collect(Collectors.toSet());
    for (List<String> cycle : projectBuildOrderInfo.getProjectCycles()) {
        String detectedCycle = Strings.join(", ", cycle);
        assertTrue("Cycle " + detectedCycle + " not found in " + expectedCycles, expectedCycles.contains(detectedCycle));
    }
}
Also used : BuildOrderInfo(org.eclipse.n4js.xtext.workspace.BuildOrderInfo) Collection(java.util.Collection) BuildOrderIterator(org.eclipse.n4js.xtext.workspace.BuildOrderIterator) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) AbstractIdeTest(org.eclipse.n4js.ide.tests.helper.server.AbstractIdeTest) Collectors(java.util.stream.Collectors) WorkspaceConfigSnapshot(org.eclipse.n4js.xtext.workspace.WorkspaceConfigSnapshot) IteratorExtensions(org.eclipse.xtext.xbase.lib.IteratorExtensions) Strings(org.eclipse.n4js.utils.Strings) List(java.util.List) BuildOrderInfo(org.eclipse.n4js.xtext.workspace.BuildOrderInfo) Pair(org.eclipse.xtext.xbase.lib.Pair) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) WorkspaceConfigSnapshot(org.eclipse.n4js.xtext.workspace.WorkspaceConfigSnapshot) BuildOrderIterator(org.eclipse.n4js.xtext.workspace.BuildOrderIterator)

Aggregations

BuildOrderInfo (org.eclipse.n4js.xtext.workspace.BuildOrderInfo)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 URI (org.eclipse.emf.common.util.URI)1 AbstractIdeTest (org.eclipse.n4js.ide.tests.helper.server.AbstractIdeTest)1 Strings (org.eclipse.n4js.utils.Strings)1 N4JSProjectConfigSnapshot (org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot)1 N4JSWorkspaceConfigSnapshot (org.eclipse.n4js.workspace.N4JSWorkspaceConfigSnapshot)1 FileURI (org.eclipse.n4js.workspace.locations.FileURI)1 BuildOrderIterator (org.eclipse.n4js.xtext.workspace.BuildOrderIterator)1 ProjectSet (org.eclipse.n4js.xtext.workspace.ProjectSet)1 WorkspaceConfigSnapshot (org.eclipse.n4js.xtext.workspace.WorkspaceConfigSnapshot)1 IteratorExtensions (org.eclipse.xtext.xbase.lib.IteratorExtensions)1 Pair (org.eclipse.xtext.xbase.lib.Pair)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1