use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class RuntimeEnvironmentsHelper method recursiveDependencyCollector.
/**
* Collects dependencies of the provided source container, by analyzing direct dependencies of the container and
* recursively their dependencies. Dependencies in form of {@link IN4JSSourceContainerAware} are mapped to
* {@link IN4JSProject}s, that is instances of {@link IN4JSProject} project are returned as they are, while
* instances of {@link IN4JSArchive} have contained project extracted.
*
* Discovered dependencies are collected only if they pass test specified by provided predicate.
*
* @param sourceContainer
* whose dependencies will be collected
* @param collection
* where dependencies are collected
* @param predicate
* to test if given dependency should be collected
*/
private void recursiveDependencyCollector(IN4JSSourceContainerAware sourceContainer, Collection<IN4JSProject> collection, Predicate<IN4JSProject> predicate) {
IN4JSProject project = (extractProject(sourceContainer));
if (predicate.test(project))
collection.add(project);
sourceContainer.getAllDirectDependencies().forEach(dep -> recursiveDependencyCollector(dep, collection, predicate));
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class TesterFileBasedShippedCodeConfigurationHelper method configureFromFileSystem.
/**
* Reconfigures provided run configuration in regards of {@link TestConfiguration#getExecModule()},
* {@link TestConfiguration#getInitModules()} and {@link TestConfiguration#getCoreProjectPaths()} by plain using
* file system access to the shipped code. Intended to be used in situations where proper workspace setup is not
* available and run configurations created by default are lacking essential information.
*
* It is up to the caller to decide when it is appropriate to call this method.
*
* @param config
* the configuration to be reconfigured.
*/
public void configureFromFileSystem(TestConfiguration config) {
Iterable<IN4JSProject> allShippedProjects = RunnerN4JSCore.getAllShippedProjects();
IN4JSProject customRuntimeEnvironment = getCustomRuntimeEnvironment(config, allShippedProjects);
reconfigure(config, allShippedProjects, customRuntimeEnvironment);
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class N4JSAllContainersState method isSourceContainerModification.
private boolean isSourceContainerModification(final IResourceDelta delta) {
final String fullPath = delta.getFullPath().toString();
final URI folderUri = URI.createPlatformResourceURI(fullPath, true);
final IN4JSProject project = core.findProject(folderUri).orNull();
if (null != project && project.exists()) {
return from(project.getSourceContainers()).transform(container -> container.getLocation()).filter(uri -> uri.isPlatformResource()).transform(uri -> uri.toString()).transform(uri -> uri.replaceFirst(PLATFORM_RESOURCE_SCHEME, "")).firstMatch(uri -> uri.equals(fullPath)).isPresent();
}
return false;
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class ProjectTypeLabelDecorator method decorate.
@Override
public void decorate(final Object element, final IDecoration decoration) {
try {
if (element instanceof IProject) {
final URI uri = createPlatformResourceURI(((IProject) element).getName(), true);
final IN4JSProject project = core.findProject(uri).orNull();
if (null != project) {
final ImageRef imageRef = IMAGE_REF_CACHE.get(project.getProjectType());
if (null != imageRef) {
final ImageDescriptor descriptor = imageRef.asImageDescriptor().orNull();
if (null != descriptor) {
decoration.addOverlay(descriptor);
}
}
}
}
} catch (final Exception e) {
// Exception should not propagate from here, otherwise the lightweight decorator stops working once till
// next application startup.
LOGGER.error("Error while trying to get decorator for " + element, e);
}
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class SourceFolderSelectionDialog method collectSourceFolders.
private List<String> collectSourceFolders(IProject project) {
if (null == project) {
return null;
}
// Collect source folders for the given project
URI uri = URI.createPlatformResourceURI(project.getName(), true);
IN4JSProject n4Project = n4jsCore.findProject(uri).orNull();
if (null == n4Project) {
return null;
}
return n4Project.getSourceContainers().stream().filter(// Filter out external and library folders
src -> (src.isTest() || src.isSource())).map(src -> src.getRelativeLocation()).collect(Collectors.toList());
}
Aggregations