Search in sources :

Example 1 with N4JSProject

use of org.eclipse.n4js.internal.N4JSProject in project n4js by eclipse.

the class N4JSRuntimeCoreWithMockProject method createMockProject.

private IN4JSProject createMockProject(MockN4JSModel model) {
    N4JSProject project = new MockProject(MockProject.MOCK_URI, model);
    model.setMockProject(project);
    return project;
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) N4JSProject(org.eclipse.n4js.internal.N4JSProject)

Example 2 with N4JSProject

use of org.eclipse.n4js.internal.N4JSProject in project n4js by eclipse.

the class BuildOrderComputer method getBuildOrder.

/**
 * Convenience method for {@link #getBuildOrder(N4JSProject[])}
 */
public VertexOrder<IN4JSProject> getBuildOrder(N4JSExternalProject[] projects) {
    N4JSProject[] n4jsPrjs = new N4JSProject[projects.length];
    for (int i = 0; i < projects.length; i++) {
        N4JSExternalProject project = projects[i];
        URI locationURI = URIUtils.convert(project);
        N4JSProject prjDependency = (N4JSProject) core.findProject(locationURI).orNull();
        n4jsPrjs[i] = prjDependency;
    }
    return getBuildOrder(n4jsPrjs);
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) N4JSProject(org.eclipse.n4js.internal.N4JSProject) N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) URI(org.eclipse.emf.common.util.URI)

Example 3 with N4JSProject

use of org.eclipse.n4js.internal.N4JSProject in project n4js by eclipse.

the class BuildOrderComputer method getDependencies.

private Set<N4JSProject> getDependencies(IN4JSProject project) {
    Set<N4JSProject> prjDependencies = new HashSet<>();
    ImmutableList<? extends IN4JSSourceContainerAware> deps = project.getAllDirectDependencies();
    for (IN4JSSourceContainerAware dep : deps) {
        IN4JSProject pDep = core.findProject(dep.getLocation()).orNull();
        boolean isValidDep = true;
        isValidDep &= pDep != null && pDep.exists();
        isValidDep &= !(pDep instanceof N4JSEclipseProject) || ((N4JSEclipseProject) pDep).getProject().isOpen();
        if (isValidDep) {
            prjDependencies.add((N4JSProject) pDep);
        }
    }
    return prjDependencies;
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) N4JSProject(org.eclipse.n4js.internal.N4JSProject) N4JSEclipseProject(org.eclipse.n4js.ui.internal.N4JSEclipseProject) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) IN4JSSourceContainerAware(org.eclipse.n4js.projectModel.IN4JSSourceContainerAware) HashSet(java.util.HashSet)

Example 4 with N4JSProject

use of org.eclipse.n4js.internal.N4JSProject in project n4js by eclipse.

the class BuildOrderComputer method computeVertexOrder.

private VertexOrder<String> computeVertexOrder(String[] requestedProjectURIs) {
    // init worklist with existing projects
    TreeSet<String> worklist = new TreeSet<>();
    for (String projectURI : requestedProjectURIs) {
        IN4JSProject project = uri2PrjMapper.get(projectURI);
        if (project != null && project.exists()) {
            worklist.add(projectURI);
        }
    }
    // find dependency edges and project closure
    Multimap<String, String> edges = HashMultimap.create();
    TreeSet<String> projectsClosure = new TreeSet<>();
    while (!worklist.isEmpty()) {
        String projectURI = worklist.pollFirst();
        projectsClosure.add(projectURI);
        IN4JSProject project = uri2PrjMapper.get(projectURI);
        Set<N4JSProject> prjDependencies = getDependencies(project);
        Set<String> prjDependencyURIs = new HashSet<>();
        // add edges
        for (N4JSProject prjDependency : prjDependencies) {
            String depURI = prjDependency.getLocation().toString();
            edges.put(projectURI, depURI);
            prjDependencyURIs.add(depURI);
        }
        // add only new dependencies to the worklist
        prjDependencyURIs.removeAll(projectsClosure);
        worklist.addAll(prjDependencyURIs);
    }
    // transform dependency edges
    List<String[]> edges2 = new ArrayList<>();
    for (Map.Entry<String, String> dependency : edges.entries()) {
        String prj = dependency.getKey();
        String depOn = dependency.getValue();
        edges2.add(new String[] { prj, depOn });
    }
    VertexOrder<Object> orderedObjects = ComputeProjectOrder.computeVertexOrder(projectsClosure, edges2);
    VertexOrder<String> orderedURIs = ComputeProjectOrder.castVertexOrder(orderedObjects, String.class);
    return orderedURIs;
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) N4JSProject(org.eclipse.n4js.internal.N4JSProject) ArrayList(java.util.ArrayList) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) TreeSet(java.util.TreeSet) Map(java.util.Map) HashSet(java.util.HashSet)

Example 5 with N4JSProject

use of org.eclipse.n4js.internal.N4JSProject in project n4js by eclipse.

the class N4HeadlessCompiler method configureResourceSetContainerState.

private void configureResourceSetContainerState(final List<N4JSProject> allProjects) {
    // a container is a project.
    List<String> containers = new LinkedList<>();
    BiMap<String, N4JSProject> container2project = HashBiMap.create();
    // the URIs of all resources directly contained in a project/container.
    Multimap<String, URI> container2Uris = HashMultimap.create();
    for (N4JSProject project : allProjects) {
        String container = FileBasedWorkspace.N4FBPRJ + project.getLocation();
        container2project.put(container, project);
        containers.add(container);
        for (IN4JSSourceContainer sourceContainer : project.getSourceContainers()) {
            Iterables.addAll(container2Uris.get(container), sourceContainer);
        }
    }
    // Define the Mapping of Resources (URIs to Container === Projects),
    rsbAcs.configure(containers, container2Uris);
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) N4JSProject(org.eclipse.n4js.internal.N4JSProject) URI(org.eclipse.emf.common.util.URI) LinkedList(java.util.LinkedList) IN4JSSourceContainer(org.eclipse.n4js.projectModel.IN4JSSourceContainer)

Aggregations

N4JSProject (org.eclipse.n4js.internal.N4JSProject)5 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)5 HashSet (java.util.HashSet)2 URI (org.eclipse.emf.common.util.URI)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 N4JSExternalProject (org.eclipse.n4js.external.N4JSExternalProject)1 IN4JSSourceContainer (org.eclipse.n4js.projectModel.IN4JSSourceContainer)1 IN4JSSourceContainerAware (org.eclipse.n4js.projectModel.IN4JSSourceContainerAware)1 N4JSEclipseProject (org.eclipse.n4js.ui.internal.N4JSEclipseProject)1