Search in sources :

Example 86 with IN4JSProject

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

the class AbstractN4JSProjectTest method testGetDependencies_01.

@SuppressWarnings("javadoc")
@Test
public void testGetDependencies_01() {
    IN4JSProject project = getN4JSCore().create(myProjectURI);
    ImmutableList<? extends IN4JSProject> dependencies = project.getDependencies();
    assertEquals(1, dependencies.size());
    assertEquals(libProjectURI.lastSegment(), dependencies.get(0).getLocation().lastSegment());
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) Test(org.junit.Test)

Example 87 with IN4JSProject

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

the class AbstractN4JSProjectTest method testGetSourceContainers_01.

@SuppressWarnings("javadoc")
@Test
public void testGetSourceContainers_01() {
    IN4JSProject project = getN4JSCore().create(myProjectURI);
    ImmutableList<? extends IN4JSSourceContainer> sourceContainers = project.getSourceContainers();
    assertEquals(1, sourceContainers.size());
    assertEquals("src", sourceContainers.get(0).getRelativeLocation());
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) Test(org.junit.Test)

Example 88 with IN4JSProject

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

the class AbstractN4JSProjectTest method testGetLibraries_01.

@SuppressWarnings("javadoc")
@Test
public void testGetLibraries_01() {
    IN4JSProject project = getN4JSCore().create(myProjectURI);
    ImmutableList<? extends IN4JSArchive> libraries = project.getLibraries();
    assertEquals(1, libraries.size());
    assertEquals(archiveFileURI, libraries.get(0).getLocation());
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) Test(org.junit.Test)

Example 89 with IN4JSProject

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

the class TaskGenerateAdoc method getProjects.

private Set<IN4JSProject> getProjects() {
    Set<IN4JSProject> projects = new HashSet<>();
    for (Object element : selection.toList()) {
        if (element instanceof IResource) {
            URI uri = URI.createPlatformResourceURI((((IResource) element)).getFullPath().toString(), true);
            Optional<? extends IN4JSProject> optProject = n4JSCore.findProject(uri);
            IN4JSProject project = optProject.get();
            projects.add(project);
        }
    }
    return projects;
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) URI(org.eclipse.emf.common.util.URI) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

Example 90 with IN4JSProject

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

the class RepoRelativePath method compute.

/**
 * Creates the RepoRelativePath from a given resource. Returns null, if resource is not contained in a repository.
 * If a repository is found, the simple name of the origin is used.
 */
public static RepoRelativePath compute(Resource resource, IN4JSCore n4jsCore) {
    URI uri = resource.getURI();
    Optional<? extends IN4JSProject> optProj = n4jsCore.findProject(uri);
    if (!optProj.isPresent()) {
        return null;
    }
    IN4JSProject project = optProj.get();
    Path path = project.getLocationPath();
    String uriFileString = uri.toString();
    String uriProjString = project.getLocation().toString();
    String fileRelString = uriFileString.substring(uriProjString.length());
    String absFileName = path.toAbsolutePath() + fileRelString;
    File file = new File(absFileName);
    if (!file.exists()) {
        return null;
    }
    File repoFolder = getRepoFolder(file);
    String repoName = getRepoName(repoFolder);
    String cloneFolder = repoFolder == null ? "NO_FOLDER" : repoFolder.getName();
    String projName = project.getProjectId();
    String repoPath = getRepoPath(absFileName, projName, cloneFolder);
    String projPath = fileRelString;
    if (File.separatorChar != '/') {
        projPath = projPath.replace(File.separatorChar, '/');
        repoPath = repoPath.replace(File.separatorChar, '/');
    }
    return new RepoRelativePath(repoName, repoPath, projName, projPath, -1);
}
Also used : Path(java.nio.file.Path) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) URI(org.eclipse.emf.common.util.URI) File(java.io.File)

Aggregations

IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)93 URI (org.eclipse.emf.common.util.URI)32 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)13 List (java.util.List)11 Inject (com.google.inject.Inject)9 Map (java.util.Map)9 IProject (org.eclipse.core.resources.IProject)9 IN4JSCore (org.eclipse.n4js.projectModel.IN4JSCore)9 Optional (com.google.common.base.Optional)7 File (java.io.File)7 Collection (java.util.Collection)7 HashSet (java.util.HashSet)7 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)7 Set (java.util.Set)6 Collectors (java.util.stream.Collectors)6 IOException (java.io.IOException)5 IN4JSArchive (org.eclipse.n4js.projectModel.IN4JSArchive)5 IN4JSSourceContainer (org.eclipse.n4js.projectModel.IN4JSSourceContainer)5 FluentIterable.from (com.google.common.collect.FluentIterable.from)4