use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class N4JSResourceDescriptionManager method hasDependencyTo.
/**
* Returns true iff the project containing the 'fromUri' has a direct dependency to the project containing the
* 'toUri'.
*/
private boolean hasDependencyTo(URI fromUri, URI toUri) {
final IN4JSProject fromProject = n4jsCore.findProject(fromUri).orNull();
final IN4JSProject toProject = n4jsCore.findProject(toUri).orNull();
if (null != fromProject && null != toProject) {
if (Objects.equals(fromProject, toProject)) {
return true;
}
for (IN4JSProject fromProjectDependency : fromProject.getDependenciesAndImplementedApis()) {
// workspace one and/or vice versa.
if (Objects.equals(fromProjectDependency, toProject) && fromProjectDependency.isExternal() == fromProject.isExternal()) {
return true;
}
}
}
return false;
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class AbstractTypeVisibilityChecker method isTestedProjectOf.
/**
* Returns with {@code true} if the context module argument belongs to a {@link ProjectType#TEST test} project and
* any of its tested projects contains the element module argument.
*
* @param contextModule
* the content module.
* @param elementModule
* the element module.
* @return {@code true} if the element module's container project is the tested project of the context module.
* Otherwise returns with {@code false}.
*/
public boolean isTestedProjectOf(final TModule contextModule, final TModule elementModule) {
if (null == elementModule || null == contextModule || null == elementModule.eResource() || null == contextModule.eResource()) {
return false;
}
for (final IN4JSProject testedProject : getTestedProjects(contextModule.eResource().getURI())) {
final URI testProjectLocation = testedProject.getLocation();
if (null != testProjectLocation) {
final Resource eResource = elementModule.eResource();
if (null != eResource) {
final URI resourceUri = eResource.getURI();
final IN4JSProject elementProject = core.findProject(resourceUri).orNull();
if (null != elementProject) {
if (emptyIfNull(elementProject.getProjectId()).equals(testedProject.getProjectId())) {
return true;
}
}
}
}
}
return false;
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class N4JSModel method getTestedProjects.
public Collection<IN4JSProject> getTestedProjects(final N4JSProject project) {
if (null == project || !project.exists()) {
return emptyList();
}
// Shortcut to avoid reading the project description at all.
if (!TEST.equals(project.getProjectType())) {
return emptyList();
}
final Builder<IN4JSProject> builder = ImmutableList.builder();
final URI location = project.getLocation();
final ProjectDescription description = getProjectDescription(location);
if (null != description) {
for (TestedProject testedProject : description.getAllTestedProjects()) {
if (null != testedProject.getProject()) {
URI hostLocation = workspace.getLocation(location, testedProject, PROJECT);
if (null == hostLocation) {
hostLocation = externalLibraryWorkspace.getLocation(location, testedProject, PROJECT);
}
if (hostLocation != null) {
final N4JSProject tested = getN4JSProject(hostLocation);
if (null != tested && tested.exists()) {
builder.add(tested);
}
}
}
}
}
return builder.build();
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class N4JSModel method getDependencies.
private ImmutableList<? extends IN4JSProject> getDependencies(N4JSProject project, boolean includeApis) {
ImmutableList.Builder<IN4JSProject> result = ImmutableList.builder();
URI location = project.getLocation();
ProjectDescription description = getProjectDescription(location);
if (description != null) {
result.addAll(resolveProjectReferences(project, description.getAllRequiredRuntimeLibraries()));
result.addAll(resolveProjectReferences(project, description.getAllProjectDependencies()));
result.addAll(getTestedProjects(project));
if (includeApis) {
result.addAll(resolveProjectReferences(project, description.getImplementedProjects()));
}
}
return result.build();
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class ProjectImportEnablingScope method getElements.
@Override
public Iterable<IEObjectDescription> getElements(QualifiedName name) {
switch(computeImportType(name, this.contextProject)) {
case PROJECT_IMPORT:
final String firstSegment = name.getFirstSegment();
final IN4JSProject targetProject = findProject(firstSegment, contextProject);
return getElementsWithDesiredProjectID(ImportSpecifierUtil.getMainModuleOfProject(targetProject), name.getFirstSegment());
case COMPLETE_IMPORT:
return getElementsWithDesiredProjectID(name.skipFirst(1), name.getFirstSegment());
case SIMPLE_IMPORT:
return parent.getElements(name);
default:
return Collections.emptyList();
}
}
Aggregations