Search in sources :

Example 1 with IN4JSSourceContainerAware

use of org.eclipse.n4js.projectModel.IN4JSSourceContainerAware in project n4js by eclipse.

the class RuntimeEnvironmentsHelper method getEnvironemntWithAncestorsRecursive.

private void getEnvironemntWithAncestorsRecursive(IN4JSProject project, Set<IN4JSProject> environemtns) {
    if (!project.getProjectType().equals(ProjectType.RUNTIME_ENVIRONMENT)) {
        return;
    }
    Optional<IN4JSSourceContainerAware> maybePArent = project.getExtendedRuntimeEnvironment();
    if (maybePArent.isPresent()) {
        IN4JSProject parent = (IN4JSProject) maybePArent.get();
        environemtns.add(parent);
        getEnvironemntWithAncestorsRecursive(parent, environemtns);
    }
    return;
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) IN4JSSourceContainerAware(org.eclipse.n4js.projectModel.IN4JSSourceContainerAware)

Example 2 with IN4JSSourceContainerAware

use of org.eclipse.n4js.projectModel.IN4JSSourceContainerAware in project n4js by eclipse.

the class N4JSModel method getProvidedRuntimeLibraries.

public ImmutableList<? extends IN4JSSourceContainerAware> getProvidedRuntimeLibraries(N4JSProject project) {
    ImmutableList.Builder<IN4JSSourceContainerAware> providedRuntimes = ImmutableList.builder();
    EList<ProvidedRuntimeLibraryDependency> runtimeLibraries = getAllProvidedRuntimeLibraries(project);
    URI projectLocation = project.getLocation();
    // GHOLD-249: If the project n4mf file has parse errors, we need a lot of null checks.
    for (ProvidedRuntimeLibraryDependency runtimeLibrary : runtimeLibraries) {
        if (null != runtimeLibrary.getProject()) {
            URI location = workspace.getLocation(projectLocation, runtimeLibrary, PROJECT);
            if (null == location) {
                location = externalLibraryWorkspace.getLocation(projectLocation, runtimeLibrary, PROJECT);
            }
            if (null != location) {
                providedRuntimes.add(getN4JSProject(location));
            } else {
                // Assuming archive (NFAR)
                location = workspace.getLocation(projectLocation, runtimeLibrary, ARCHIVE);
                if (null != location) {
                    providedRuntimes.add(getN4JSArchive(project, location));
                }
            }
        }
    }
    return providedRuntimes.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) IN4JSSourceContainerAware(org.eclipse.n4js.projectModel.IN4JSSourceContainerAware) ProvidedRuntimeLibraryDependency(org.eclipse.n4js.n4mf.ProvidedRuntimeLibraryDependency) URI(org.eclipse.emf.common.util.URI)

Example 3 with IN4JSSourceContainerAware

use of org.eclipse.n4js.projectModel.IN4JSSourceContainerAware in project n4js by eclipse.

the class N4MFProjectDependencyStrategy method getProjectDependencies.

@Override
public List<IProject> getProjectDependencies(final IProject project) {
    final IN4JSEclipseProject n4Project = core.create(project).orNull();
    if (null != n4Project) {
        // This covers project dependencies, tests (if any), required REs and required RLs and APIs.
        final Collection<? extends IN4JSEclipseProject> dependencies = n4Project.getDependenciesAndImplementedApis();
        // This is for the provided runtime libraries.
        final Collection<IN4JSEclipseProject> providedRuntimeLibs = from(n4Project.getProvidedRuntimeLibraries()).filter(IN4JSEclipseProject.class).toList();
        // This is for the extended RE, if specified.
        final IN4JSSourceContainerAware srcContainerAware = n4Project.getExtendedRuntimeEnvironment().orNull();
        final IN4JSEclipseProject extendedRE = srcContainerAware instanceof IN4JSEclipseProject ? (IN4JSEclipseProject) srcContainerAware : null;
        int projectCount = dependencies.size() + providedRuntimeLibs.size();
        if (null != extendedRE) {
            projectCount++;
        }
        final IProject[] projects = new IProject[projectCount];
        int i = 0;
        for (final IN4JSEclipseProject dependency : dependencies) {
            projects[i++] = dependency.getProject();
        }
        for (final IN4JSEclipseProject providedRuntimeLib : providedRuntimeLibs) {
            projects[i++] = providedRuntimeLib.getProject();
        }
        if (null != extendedRE) {
            projects[i] = extendedRE.getProject();
        }
        return from(asList(projects)).filter(p -> !(p instanceof ExternalProject)).toList();
    } else {
        return emptyList();
    }
}
Also used : List(java.util.List) IProject(org.eclipse.core.resources.IProject) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) FluentIterable.from(com.google.common.collect.FluentIterable.from) Collection(java.util.Collection) Inject(com.google.inject.Inject) IN4JSEclipseCore(org.eclipse.n4js.ui.projectModel.IN4JSEclipseCore) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) IN4JSSourceContainerAware(org.eclipse.n4js.projectModel.IN4JSSourceContainerAware) IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) IN4JSSourceContainerAware(org.eclipse.n4js.projectModel.IN4JSSourceContainerAware) IProject(org.eclipse.core.resources.IProject)

Example 4 with IN4JSSourceContainerAware

use of org.eclipse.n4js.projectModel.IN4JSSourceContainerAware 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)

Aggregations

IN4JSSourceContainerAware (org.eclipse.n4js.projectModel.IN4JSSourceContainerAware)4 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)2 FluentIterable.from (com.google.common.collect.FluentIterable.from)1 ImmutableList (com.google.common.collect.ImmutableList)1 Inject (com.google.inject.Inject)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Collections.emptyList (java.util.Collections.emptyList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 IProject (org.eclipse.core.resources.IProject)1 URI (org.eclipse.emf.common.util.URI)1 N4JSProject (org.eclipse.n4js.internal.N4JSProject)1 ProvidedRuntimeLibraryDependency (org.eclipse.n4js.n4mf.ProvidedRuntimeLibraryDependency)1 N4JSEclipseProject (org.eclipse.n4js.ui.internal.N4JSEclipseProject)1 IN4JSEclipseCore (org.eclipse.n4js.ui.projectModel.IN4JSEclipseCore)1 IN4JSEclipseProject (org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject)1 ExternalProject (org.eclipse.n4js.utils.resources.ExternalProject)1