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;
}
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);
}
}
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();
}
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);
}
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<>();
}
Aggregations