use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class ProjectCompareHelper method getImplementationID.
/**
* Retrieves the implementation ID for an implementor of some API
*
* @param apiImplModule
* the implementor
* @return implementation ID if applicable - unset if the parameter is not implementing an API or is itself from an
* API definition.
*/
public Optional<String> getImplementationID(TModule apiImplModule) {
Optional<? extends IN4JSProject> opt = n4jsCore.findProject(apiImplModule.eResource().getURI());
IN4JSProject implProject = opt.get();
return implProject.getImplementationId();
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class RunnerFrontEnd method configureDependenciesAndPaths.
/**
* Configures paths based on project dependencies and API-IMPL relations.
*/
private void configureDependenciesAndPaths(RunConfiguration config) {
// 1) for all API projects among the direct and indirect dependencies we have to provide a mapping
// from the projectId of the API project to the projectId of the implementation project to be used
final ApiUsage apiUsage = runnerHelper.getProjectExtendedDepsAndApiImplMapping(config.getRuntimeEnvironment(), config.getUserSelection(), config.getImplementationId(), true);
final List<IN4JSProject> deps = apiUsage.projects;
final Map<IN4JSProject, IN4JSProject> apiImplProjectMapping = apiUsage.concreteApiImplProjectMapping;
config.setApiImplProjectMappingFromProjects(apiImplProjectMapping);
// 2) collect paths to all output folders of all N4JS projects (dependencies) with the compiled code
// (these are the .../es5/ folders)
final List<IN4JSProject> depsImpl = deps.stream().map(p -> {
final IN4JSProject p2 = apiImplProjectMapping.get(p);
final IN4JSProject p3 = p2 != null ? p2 : p;
return p3;
}).collect(Collectors.toList());
final Collection<String> coreProjectPaths = runnerHelper.getCoreProjectPaths(depsImpl);
config.setCoreProjectPaths(coreProjectPaths);
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class RunnerFrontEnd method configureRuntimeEnvironment.
/**
* Configures provided configuration based on the {@link RunConfiguration#getRuntimeEnvironment() runtime
* environment} value it stores.
*
* Recomputes {@link RunConfiguration#getInitModules() init modules} and {@link RunConfiguration#getExecModule()
* exec module} based on current state of the workspace.
*
* @param config
* the runtime configuration whose derived values are computed.
*/
public void configureRuntimeEnvironment(RunConfiguration config, Iterable<IN4JSProject> projects) {
RuntimeEnvironment runtimeEnvironment = config.getRuntimeEnvironment();
Optional<IN4JSProject> findRuntimeEnvironmentProject = hRuntimeEnvironments.findRuntimeEnvironmentProject(runtimeEnvironment, projects);
if (findRuntimeEnvironmentProject.isPresent()) {
IN4JSProject runtimeEnvironmentProject = findRuntimeEnvironmentProject.get();
// 3) collect custom(!) init modules based on selected runtime environment
final List<String> initModulePaths = getInitModulesPathsFrom(runtimeEnvironmentProject);
config.setInitModules(initModulePaths);
// 4) find compiled .js file to be executed first (the "executionModule" of the runtime environment)
Optional<String> executionModule = getExecModulePathFrom(runtimeEnvironmentProject);
if (executionModule.isPresent()) {
config.setExecModule(executionModule.get());
}
}
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class RunnerFrontEnd method configureExecutionData.
/**
* Configures execution data from user selection, init modules, and apiImplProjectMapping
*
* this should transform user selection into execution data, but concrete runner/tester may transform this further
* into its own representation.
*
* Testers need to pass test discovery result. Runners need to pass module/class/method selection.
*/
private void configureExecutionData(RunConfiguration config) {
final URI userSelection = config.getUserSelection();
if (userSelection != null && (hasValidFileExtension(userSelection.toString()))) {
final String userSelection_targetFileName = resourceNameComputer.generateFileDescriptor(userSelection, null);
IN4JSProject project = resolveProject(userSelection);
String base = AbstractSubGenerator.calculateProjectBasedOutputDirectory(project);
config.setExecutionData(RunConfiguration.EXEC_DATA_KEY__USER_SELECTION, base + "/" + userSelection_targetFileName);
} else {
// this can happen if the RunConfiguration 'config' is actually a TestConfiguration, because then the user
// selection is allowed to point to a project or folder (and method CompilerUtils#getModuleName() above
// would throw an exception)
config.setExecutionData(RunConfiguration.EXEC_DATA_KEY__USER_SELECTION, null);
}
config.setExecutionData(RunConfiguration.EXEC_DATA_KEY__INIT_MODULES, config.getInitModules());
config.setExecutionData(RunConfiguration.EXEC_DATA_KEY__PROJECT_NAME_MAPPING, config.getApiImplProjectMapping());
}
use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.
the class RuntimeEnvironmentsHelper method recursiveCollectRlFromChain.
private void recursiveCollectRlFromChain(IN4JSProject runtimeEnvironment, Collection<IN4JSProject> collection) {
Optional<String> extended = runtimeEnvironment.getExtendedRuntimeEnvironmentId();
if (extended.isPresent()) {
String id = extended.get();
List<IN4JSProject> extendedRE = from(getAllProjects()).filter(p -> id.equals(p.getProjectId())).toList();
if (extendedRE.isEmpty()) {
return;
}
if (extendedRE.size() > 1) {
LOGGER.debug("multiple projects match id " + id);
LOGGER.error(new RuntimeException("Cannot obtain transitive list of provided libraries"));
return;
}
IN4JSProject extendedRuntimeEnvironemnt = extendedRE.get(0);
recursiveProvidedRuntimeLibrariesCollector(extendedRuntimeEnvironemnt.getProvidedRuntimeLibraries(), collection, p -> isRuntimeLibrary(p));
recursiveCollectRlFromChain(extendedRuntimeEnvironemnt, collection);
}
}
Aggregations