Search in sources :

Example 11 with IN4JSProject

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

the class AbstractN4JSProjectTest method testGetDependencies_03.

@SuppressWarnings("javadoc")
@Test
public void testGetDependencies_03() {
    IN4JSProject project = getN4JSCore().create(myProjectURI);
    ImmutableList<? extends IN4JSProject> first = project.getDependencies();
    ImmutableList<? extends IN4JSProject> second = project.getDependencies();
    assertEquals(first, second);
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) Test(org.junit.Test)

Example 12 with IN4JSProject

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

the class AbstractN4JSProjectTest method testGetLocation_02.

@SuppressWarnings("javadoc")
@Test
public void testGetLocation_02() {
    URI doesNotExist = myProjectURI.trimSegments(1).appendSegment("doesNotExist");
    IN4JSProject project = getN4JSCore().create(doesNotExist);
    assertEquals(doesNotExist, project.getLocation());
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) URI(org.eclipse.emf.common.util.URI) Test(org.junit.Test)

Example 13 with IN4JSProject

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

the class N4JSDReader method readN4JSDs.

/**
 * Reads all N4JSD files in project, scans for types and links the tests.
 *
 * @return all types in a mapped with fully qualified type name (inclusive module spec) as key, the type info only
 *         contains the types, no other information yet.
 * @throws InterruptedException
 *             thrown when user cancels the operation
 */
public Collection<SpecInfo> readN4JSDs(Collection<IN4JSProject> projects, Function<IN4JSProject, ResourceSet> resSetProvider, SubMonitorMsg monitor) throws InterruptedException {
    Multimap<String, SpecInfo> specInfoByName = HashMultimap.create();
    ResourceSet resSet = null;
    SubMonitorMsg sub = monitor.convert(2 * 100 * projects.size());
    for (IN4JSProject project : projects) {
        if (resSet == null) {
            resSet = resSetProvider.apply(project);
        }
        readScripts(specInfoByName, project, resSet, sub.newChild(100));
    }
    for (IN4JSProject project : projects) {
        if (resSet == null) {
            resSet = resSetProvider.apply(project);
        }
        linkTests(specInfoByName, project, resSet, sub.newChild(100));
    }
    return specInfoByName.values();
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet)

Example 14 with IN4JSProject

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

the class ImportsFactory method createNamedImport.

/**
 * Creates a new named import of 'name' from 'module'
 */
private ImportDeclaration createNamedImport(String name, IN4JSProject contextProject, TExportableElement te, Adapter nodelessMarker) {
    TModule tmodule = te.getContainingModule();
    IN4JSProject targetProject = core.findProject(te.eResource().getURI()).orNull();
    String moduleQN;
    if (targetProject != null && tmodule.getQualifiedName().toString().equals(targetProject.getMainModule())) {
        // If the project has a main module, use project import instead.
        moduleQN = targetProject.getProjectId();
    } else {
        // Standard case
        moduleQN = te.getContainingModule().getQualifiedName();
    }
    QualifiedName qn = qualifiedNameConverter.toQualifiedName(moduleQN);
    String firstSegment = qn.getFirstSegment();
    IN4JSProject project = ImportSpecifierUtil.getDependencyWithID(firstSegment, contextProject);
    return createImportDeclaration(qn, name, project, nodelessMarker, this::addNamedImport);
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) QualifiedName(org.eclipse.xtext.naming.QualifiedName) TModule(org.eclipse.n4js.ts.types.TModule)

Example 15 with IN4JSProject

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

the class ImportsFactory method createNamespaceImport.

/**
 * Creates a new default import with name 'name' from object description.
 */
private ImportDeclaration createNamespaceImport(String name, IN4JSProject contextProject, TExportableElement te, Adapter nodelessMarker) {
    String moduleQN = te.getContainingModule().getQualifiedName();
    QualifiedName qn = qualifiedNameConverter.toQualifiedName(moduleQN);
    String firstSegment = qn.getFirstSegment();
    IN4JSProject project = ImportSpecifierUtil.getDependencyWithID(firstSegment, contextProject);
    if (project == null) {
        IN4JSProject projectByNamespace = ImportSpecifierUtil.getDependencyWithID(name, contextProject);
        IN4JSProject projectByEObject = core.findProject(te.eResource().getURI()).orNull();
        if (projectByNamespace != null && projectByEObject != null && projectByNamespace.getLocation() == projectByEObject.getLocation())
            project = projectByNamespace;
    }
    return createImportDeclaration(qn, name, project, nodelessMarker, this::addNamespaceImport);
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) QualifiedName(org.eclipse.xtext.naming.QualifiedName)

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