Search in sources :

Example 1 with N4JSExternalProject

use of org.eclipse.n4js.external.N4JSExternalProject in project n4js by eclipse.

the class ExternalProjectProvider method getProjectsDescriptions.

Collection<ProjectDescription> getProjectsDescriptions(java.net.URI rootLocation) {
    ensureInitialized();
    File rootFolder = new File(rootLocation);
    Set<ProjectDescription> projectsMapping = newHashSet();
    URI rootUri = URI.createFileURI(rootFolder.getAbsolutePath());
    for (Entry<URI, Optional<Pair<N4JSExternalProject, ProjectDescription>>> entry : projectCache.asMap().entrySet()) {
        URI projectLocation = entry.getKey();
        if (rootUri.equals(projectLocation.trimSegments(1))) {
            Pair<N4JSExternalProject, ProjectDescription> pair = entry.getValue().orNull();
            if (null != pair && null != pair.getFirst()) {
                ProjectDescription description = pair.getSecond();
                if (description != null) {
                    projectsMapping.add(description);
                }
            }
        }
    }
    return unmodifiableCollection(projectsMapping);
}
Also used : N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) Optional(com.google.common.base.Optional) File(java.io.File) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) URI(org.eclipse.emf.common.util.URI)

Example 2 with N4JSExternalProject

use of org.eclipse.n4js.external.N4JSExternalProject in project n4js by eclipse.

the class ExternalProjectProvider method getProjectsIn.

Collection<N4JSExternalProject> getProjectsIn(java.net.URI rootLocation) {
    ensureInitialized();
    File rootFolder = new File(rootLocation);
    Map<String, N4JSExternalProject> projectsMapping = newTreeMap();
    URI rootUri = URI.createFileURI(rootFolder.getAbsolutePath());
    for (Entry<URI, Optional<Pair<N4JSExternalProject, ProjectDescription>>> entry : projectCache.asMap().entrySet()) {
        URI projectLocation = entry.getKey();
        if (rootUri.equals(projectLocation.trimSegments(1))) {
            Pair<N4JSExternalProject, ProjectDescription> pair = entry.getValue().orNull();
            if (null != pair && null != pair.getFirst()) {
                N4JSExternalProject project = pair.getFirst();
                projectsMapping.put(project.getName(), project);
            }
        }
    }
    return unmodifiableCollection(projectsMapping.values());
}
Also used : N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) Optional(com.google.common.base.Optional) File(java.io.File) URI(org.eclipse.emf.common.util.URI) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription)

Example 3 with N4JSExternalProject

use of org.eclipse.n4js.external.N4JSExternalProject in project n4js by eclipse.

the class ExternalIndexUpdater method cleanRemovedLocations.

/**
 * Removes projects from Index that were in a removed location
 */
private void cleanRemovedLocations(Set<URI> removedLocations, IProgressMonitor monitor) {
    Collection<N4JSExternalProject> removedProjects = externalWorkspace.getProjectsIn(removedLocations);
    SubMonitor subMonitor = convert(monitor, 3);
    // Clean removed projects from Index
    builder.clean(removedProjects, subMonitor.newChild(1));
    subMonitor.worked(1);
    // Remember affected workspace and external projects
    extProjectsDependingOnRemovedProjects = collector.getExtProjectsDependendingOn(removedProjects);
    extProjectsDependingOnRemovedProjects.removeAll(removedProjects);
    subMonitor.worked(1);
    wsProjectsDependingOnRemovedProjects = collector.getWSProjectsDependendingOn(removedProjects);
    wsProjectsDependingOnRemovedProjects.removeAll(removedProjects);
    subMonitor.worked(1);
}
Also used : N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) SubMonitor(org.eclipse.core.runtime.SubMonitor)

Example 4 with N4JSExternalProject

use of org.eclipse.n4js.external.N4JSExternalProject in project n4js by eclipse.

the class ExternalProjectCacheLoader method load.

@Override
public Optional<Pair<N4JSExternalProject, ProjectDescription>> load(final URI rootLocation) throws Exception {
    ProjectDescription projectDescription = packageManager.loadManifestFromProjectRoot(rootLocation);
    if (null != projectDescription) {
        File projectRoot = new File(rootLocation.toFileString());
        ExternalProject p = new ExternalProject(projectRoot, NATURE_ID, BUILDER_ID);
        IN4JSProject pp = new N4JSEclipseProject(p, rootLocation, model);
        N4JSExternalProject ppp = new N4JSExternalProject(projectRoot, pp);
        return Optional.of(Tuples.create(ppp, projectDescription));
    }
    return Optional.absent();
}
Also used : N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) File(java.io.File)

Example 5 with N4JSExternalProject

use of org.eclipse.n4js.external.N4JSExternalProject in project n4js by eclipse.

the class EclipseExternalLibraryWorkspace method getLocation.

@Override
public URI getLocation(URI projectURI, ProjectReference reference, N4JSSourceContainerType expectedN4JSSourceContainerType) {
    if (PROJECT.equals(expectedN4JSSourceContainerType)) {
        String name = reference.getProject().getProjectId();
        ExternalProject project = projectProvider.getProject(name);
        if (null == project) {
            return null;
        }
        File referencedProject = new File(project.getLocationURI());
        URI refLocation = URI.createFileURI(referencedProject.getAbsolutePath());
        Pair<N4JSExternalProject, ProjectDescription> pair = projectProvider.getProjectWithDescription(refLocation);
        if (null != pair) {
            return refLocation;
        }
    }
    return null;
}
Also used : N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URI(org.eclipse.emf.common.util.URI) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription)

Aggregations

N4JSExternalProject (org.eclipse.n4js.external.N4JSExternalProject)10 File (java.io.File)5 URI (org.eclipse.emf.common.util.URI)5 IProject (org.eclipse.core.resources.IProject)4 SubMonitor (org.eclipse.core.runtime.SubMonitor)4 ProjectDescription (org.eclipse.n4js.n4mf.ProjectDescription)4 Optional (com.google.common.base.Optional)2 IFile (org.eclipse.core.resources.IFile)2 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)2 ExternalProject (org.eclipse.n4js.utils.resources.ExternalProject)2 FluentIterable.from (com.google.common.collect.FluentIterable.from)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 Inject (com.google.inject.Inject)1 Singleton (com.google.inject.Singleton)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Logger (org.apache.log4j.Logger)1 IResource (org.eclipse.core.resources.IResource)1