Search in sources :

Example 46 with IN4JSProject

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

the class N4JSEclipseModel method findAllProjectMappings.

public Map<String, IN4JSProject> findAllProjectMappings() {
    final Map<String, IN4JSProject> workspaceProjectMapping = newLinkedHashMap();
    for (IProject project : workspace.getProjects()) {
        if (project.isOpen()) {
            N4JSEclipseProject n4jsProject = getN4JSProject(project);
            workspaceProjectMapping.put(n4jsProject.getProjectId(), n4jsProject);
        }
    }
    for (IProject project : externalLibraryWorkspace.getProjects()) {
        if (!workspaceProjectMapping.containsKey(project.getName())) {
            N4JSEclipseProject n4jsProject = getN4JSProject(project);
            workspaceProjectMapping.put(n4jsProject.getProjectId(), n4jsProject);
        }
    }
    return workspaceProjectMapping;
}
Also used : IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) IProject(org.eclipse.core.resources.IProject)

Example 47 with IN4JSProject

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

the class ApiImplMapping method put.

/**
 * Add a single API -> implementation association to the receiving mapping (if it is not present already).
 */
public void put(IN4JSProject api, IN4JSProject impl) {
    final String apiId = api.getProjectId();
    if (apiId == null)
        // just ignore (complaining about this problem is not our business)
        return;
    final String implId = impl.getImplementationId().orNull();
    if (implId == null) {
        projectsWithUndefImplIds.add(impl);
        return;
    }
    ApiImplMapping.ApiImplAssociation assoc = assocs.get(apiId);
    if (assoc == null) {
        assoc = new ApiImplAssociation(api);
        assocs.put(apiId, assoc);
    }
    final IN4JSProject replaced = assoc.putImpl(impl);
    if (replaced != null && !Objects.equals(replaced, impl)) {
        // ooops! we have several projects defining an implementation for project 'api' with the same
        // implementation id -> remember them!
        putConflict(apiId, implId, replaced, impl);
    }
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject)

Example 48 with IN4JSProject

use of org.eclipse.n4js.projectModel.IN4JSProject 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 49 with IN4JSProject

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

the class N4IDLAwareTopLevelElementsCollector method getTopLevelElements.

@Override
public Iterable<IEObjectDescription> getTopLevelElements(TModule module, Resource contextResource) {
    Optional<? extends IN4JSProject> project = n4jsCore.findProject(contextResource.getURI());
    Iterable<IEObjectDescription> allTopLevelElements = super.getTopLevelElements(module, contextResource);
    // if project isn't available, include all top-level elements
    if (!project.isPresent()) {
        LOGGER.warn(String.format("Failed to determine project of resource %s.", contextResource.getURI()));
        return allTopLevelElements;
    }
    // if the containing resources isn't available, include all top-level elements
    if (null == module.eResource()) {
        LOGGER.warn(String.format("Failed to determine resource of TModule %s.", module));
        return allTopLevelElements;
    }
    // otherwise filter by context version
    Optional<? extends IN4JSProject> moduleProject = n4jsCore.findProject(module.eResource().getURI());
    if (!moduleProject.isPresent()) {
        LOGGER.warn(String.format("Failed to determine project of TModule %s.", module.getQualifiedName()));
        return allTopLevelElements;
    }
    IN4JSProject contextN4JSProject = project.get();
    IN4JSProject versionedN4JSProject = moduleProject.get();
    final int contextVersion = getProjectContextVersion(versionedN4JSProject, contextN4JSProject);
    // in case of an invalid context version
    if (contextVersion < 1) {
        return allTopLevelElements;
    }
    // filter top-level elements according to N4IDL versioning rules
    N4IDLVersionableFilter versionableFilter = new N4IDLVersionableFilter(contextVersion);
    return versionableFilter.filterElements(allTopLevelElements);
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 50 with IN4JSProject

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

the class AbstractN4JSCore method getPaths.

private List<String> getPaths(URI location, ModuleFilter moduleFilter) {
    Optional<? extends IN4JSSourceContainer> sourceContainerOpt = findN4JSSourceContainer(location);
    if (sourceContainerOpt.isPresent()) {
        IN4JSSourceContainer sourceContainer = sourceContainerOpt.get();
        IN4JSProject project = sourceContainer.getProject();
        String projectLocation = getLocationPath(project.getLocation());
        return handleWildcardsAndRelativeNavigation(projectLocation, sourceContainer.getRelativeLocation(), moduleFilter);
    }
    return new ArrayList<>();
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) ArrayList(java.util.ArrayList) IN4JSSourceContainer(org.eclipse.n4js.projectModel.IN4JSSourceContainer)

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