Search in sources :

Example 16 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class N4JSModel method getN4JSSourceContainers.

public ImmutableList<? extends IN4JSSourceContainer> getN4JSSourceContainers(N4JSProject project) {
    ImmutableList.Builder<IN4JSSourceContainer> result = ImmutableList.builder();
    URI location = project.getLocation();
    ProjectDescription description = getProjectDescription(location);
    if (description != null) {
        List<SourceFragment> sourceFragments = newArrayList(from(description.getSourceFragment()));
        sourceFragments.sort((f1, fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) -> f1.compareByFragmentType(fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT));
        for (SourceFragment sourceFragment : sourceFragments) {
            List<String> paths = sourceFragment.getPaths();
            for (String path : paths) {
                // XXX poor man's canonical path conversion. Consider headless compiler with npm projects.
                final String relativeLocation = ".".equals(path) ? "" : path;
                IN4JSSourceContainer sourceContainer = this.createProjectN4JSSourceContainer(project, sourceFragment.getSourceFragmentType(), relativeLocation);
                result.add(sourceContainer);
            }
        }
    }
    return result.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) URI(org.eclipse.emf.common.util.URI) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) SimpleProjectDescription(org.eclipse.n4js.n4mf.SimpleProjectDescription) IN4JSSourceContainer(org.eclipse.n4js.projectModel.IN4JSSourceContainer) SourceFragment(org.eclipse.n4js.n4mf.SourceFragment)

Example 17 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class N4JSModel method getAllProvidedRuntimeLibraries.

private EList<ProvidedRuntimeLibraryDependency> getAllProvidedRuntimeLibraries(N4JSProject project) {
    URI projectLocation = project.getLocation();
    if (projectLocation == null)
        return ECollections.emptyEList();
    ProjectDescription description = getProjectDescription(projectLocation);
    if (description == null)
        return ECollections.emptyEList();
    EList<ProvidedRuntimeLibraryDependency> runtimeLibraries = description.getAllProvidedRuntimeLibraries();
    if (runtimeLibraries == null)
        return ECollections.emptyEList();
    return runtimeLibraries;
}
Also used : ProvidedRuntimeLibraryDependency(org.eclipse.n4js.n4mf.ProvidedRuntimeLibraryDependency) URI(org.eclipse.emf.common.util.URI) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) SimpleProjectDescription(org.eclipse.n4js.n4mf.SimpleProjectDescription)

Example 18 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class N4JSModel method getSourceContainers.

public ImmutableList<IN4JSSourceContainer> getSourceContainers(N4JSArchive archive) {
    ImmutableList.Builder<IN4JSSourceContainer> result = ImmutableList.builder();
    URI location = archive.getLocation();
    ProjectDescription description = getProjectDescription(location);
    if (description != null) {
        List<SourceFragment> sourceFragments = newArrayList(from(description.getSourceFragment()));
        sourceFragments.sort((f1, fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) -> f1.compareByFragmentType(fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT));
        for (SourceFragment sourceFragment : sourceFragments) {
            List<String> paths = sourceFragment.getPaths();
            for (String path : paths) {
                result.add(createArchiveN4JSSourceContainer(archive, sourceFragment.getSourceFragmentType(), path));
            }
        }
    }
    return result.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) URI(org.eclipse.emf.common.util.URI) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) SimpleProjectDescription(org.eclipse.n4js.n4mf.SimpleProjectDescription) IN4JSSourceContainer(org.eclipse.n4js.projectModel.IN4JSSourceContainer) SourceFragment(org.eclipse.n4js.n4mf.SourceFragment)

Example 19 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class N4JSModel method getImplementedProjects.

public ImmutableList<? extends IN4JSProject> getImplementedProjects(N4JSProject project) {
    ImmutableList.Builder<IN4JSProject> result = ImmutableList.builder();
    URI location = project.getLocation();
    ProjectDescription description = getProjectDescription(location);
    if (description != null) {
        result.addAll(resolveProjectReferences(project, description.getAllImplementedProjects()));
    }
    return result.build();
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) ImmutableList(com.google.common.collect.ImmutableList) URI(org.eclipse.emf.common.util.URI) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) SimpleProjectDescription(org.eclipse.n4js.n4mf.SimpleProjectDescription)

Example 20 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class N4JSModel method doGetLibraries.

protected ImmutableList<? extends IN4JSArchive> doGetLibraries(N4JSProject project, URI location) {
    ImmutableList.Builder<IN4JSArchive> result = ImmutableList.builder();
    ProjectDescription description = getProjectDescription(location);
    if (description != null) {
        description.getAllRequiredRuntimeLibraries().forEach(lib -> addArchiveFromDependency(project, location, lib, result));
        description.getAllProjectDependencies().forEach(lib -> addArchiveFromDependency(project, location, lib, result));
    }
    return result.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) IN4JSArchive(org.eclipse.n4js.projectModel.IN4JSArchive) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) SimpleProjectDescription(org.eclipse.n4js.n4mf.SimpleProjectDescription)

Aggregations

ProjectDescription (org.eclipse.n4js.n4mf.ProjectDescription)37 URI (org.eclipse.emf.common.util.URI)19 SimpleProjectDescription (org.eclipse.n4js.n4mf.SimpleProjectDescription)11 Test (org.junit.Test)9 ImmutableList (com.google.common.collect.ImmutableList)7 File (java.io.File)6 EObject (org.eclipse.emf.ecore.EObject)6 ProjectDependency (org.eclipse.n4js.n4mf.ProjectDependency)6 Resource (org.eclipse.emf.ecore.resource.Resource)5 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)5 SourceFragment (org.eclipse.n4js.n4mf.SourceFragment)5 N4JSExternalProject (org.eclipse.n4js.external.N4JSExternalProject)4 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)4 IOException (java.io.IOException)3 IFile (org.eclipse.core.resources.IFile)3 ExtendedRuntimeEnvironment (org.eclipse.n4js.n4mf.ExtendedRuntimeEnvironment)3 ProjectReference (org.eclipse.n4js.n4mf.ProjectReference)3 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)3 Optional (com.google.common.base.Optional)2 IResource (org.eclipse.core.resources.IResource)2