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;
}
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);
}
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;
}
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;
}
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);
}
Aggregations