Search in sources :

Example 6 with IN4JSArchive

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

Example 7 with IN4JSArchive

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

the class N4JSProjectsStateHelper method initVisibleHandles.

public List<String> initVisibleHandles(String handle) {
    if (handle.startsWith(PROJECT_CONTAINER_PREFIX)) {
        // similar to source-container-prefix but we are only interested in the project/archive and
        // don't have an actual file of the source-locations.
        URI uri = URI.createURI(handle.substring(PROJECT_CONTAINER_PREFIX.length()));
        List<String> result = Lists.newArrayList();
        // Project.
        Optional<? extends IN4JSEclipseProject> containerProjectOpt = core.findProject(uri);
        if (containerProjectOpt.isPresent()) {
            fullCollectLocationHandles(result, containerProjectOpt.get());
        } else {
            // archive
            Optional<? extends IN4JSArchive> containerArchiveOpt = core.findArchive(uri);
            if (containerArchiveOpt.isPresent()) {
                // out of archive
                IN4JSArchive archive = containerArchiveOpt.get();
                fullCollectLocationHandles(result, archive);
            } else {
                // Nothing found.
                return Collections.emptyList();
            }
        }
        return result;
    }
    URI uri = URI.createURI(handle.substring(SOURCE_CONTAINER_PREFIX.length()));
    Optional<? extends IN4JSSourceContainer> containerOpt = core.findN4JSSourceContainer(uri);
    List<String> result = Lists.newArrayList();
    if (containerOpt.isPresent()) {
        IN4JSSourceContainer container = containerOpt.get();
        if (container.isLibrary()) {
            IN4JSArchive archive = container.getLibrary();
            fullCollectLocationHandles(result, archive);
        } else {
            IN4JSProject project = container.getProject();
            fullCollectLocationHandles(result, project);
        }
        return result;
    }
    return Collections.emptyList();
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) IN4JSArchive(org.eclipse.n4js.projectModel.IN4JSArchive) URI(org.eclipse.emf.common.util.URI) IN4JSSourceContainer(org.eclipse.n4js.projectModel.IN4JSSourceContainer)

Example 8 with IN4JSArchive

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

the class AbstractN4JSArchiveTest method testGetArchiveName.

@SuppressWarnings("javadoc")
@Test
public void testGetArchiveName() {
    IN4JSArchive archive = getArchive();
    assertEquals(archiveProjectId + ".nfar", archive.getFileName());
}
Also used : IN4JSArchive(org.eclipse.n4js.projectModel.IN4JSArchive) Test(org.junit.Test)

Example 9 with IN4JSArchive

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

the class AbstractN4JSArchiveTest method testGetLibraries.

@SuppressWarnings("javadoc")
@Test
public void testGetLibraries() {
    IN4JSArchive archive = getArchive();
    archive.getReferencedLibraries();
    ImmutableList<? extends IN4JSArchive> dependencies = archive.getReferencedLibraries();
    assertEquals(0, dependencies.size());
}
Also used : IN4JSArchive(org.eclipse.n4js.projectModel.IN4JSArchive) Test(org.junit.Test)

Example 10 with IN4JSArchive

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

the class AbstractN4JSArchiveTest method testGetSourceContainers_01.

@SuppressWarnings("javadoc")
@Test
public void testGetSourceContainers_01() {
    IN4JSArchive archive = getArchive();
    ImmutableList<? extends IN4JSSourceContainer> sourceContainers = archive.getSourceContainers();
    assertEquals(1, sourceContainers.size());
    assertTrue(sourceContainers.get(0).isSource());
    assertEquals("src", sourceContainers.get(0).getRelativeLocation());
}
Also used : IN4JSArchive(org.eclipse.n4js.projectModel.IN4JSArchive) Test(org.junit.Test)

Aggregations

IN4JSArchive (org.eclipse.n4js.projectModel.IN4JSArchive)10 Test (org.junit.Test)7 URI (org.eclipse.emf.common.util.URI)2 ImmutableList (com.google.common.collect.ImmutableList)1 Set (java.util.Set)1 ProjectDescription (org.eclipse.n4js.n4mf.ProjectDescription)1 SimpleProjectDescription (org.eclipse.n4js.n4mf.SimpleProjectDescription)1 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)1 IN4JSSourceContainer (org.eclipse.n4js.projectModel.IN4JSSourceContainer)1