use of org.eclipse.n4js.projectModel.IN4JSSourceContainer in project n4js by eclipse.
the class NFARExportOperation method countSelectedResources.
private int countSelectedResources() {
// manifest
int result = 1;
for (IN4JSSourceContainer container : project.getSourceContainers()) {
int numberOfURIs = Iterators.size(container.iterator());
// compiled variants
numberOfURIs *= 2;
result += numberOfURIs;
}
return result;
}
use of org.eclipse.n4js.projectModel.IN4JSSourceContainer in project n4js by eclipse.
the class N4HeadlessCompiler method collectResources.
/**
* Collects all resources belonging to the given project and adds them to the given resource set.
*
* @param markedProject
* the project being loaded
* @param resourceSet
* the resource set to load the resources into
* @param recorder
* the progress recorder
*/
private void collectResources(MarkedProject markedProject, ResourceSet resourceSet, N4ProgressStateRecorder recorder) {
markedProject.clearResources();
for (IN4JSSourceContainer container : markedProject.project.getSourceContainers()) {
// Conditionally filter test resources if not desired
if (shouldLoadSourceContainer(container)) {
if (logger.isCreateDebugOutput()) {
logger.debug("Collecting resources from source container " + container.getLocation());
}
Iterables.filter(container, uri -> shouldLoadResource(uri)).forEach(uri -> {
Resource resource = resourceSet.createResource(uri);
if (resource != null) {
if (logger.isCreateDebugOutput()) {
logger.debug(" Creating resource " + resource.getURI());
}
markedProject.resources.add(resource);
if (container.isExternal()) {
markedProject.externalResources.add(resource);
}
if (container.isTest()) {
markedProject.testResources.add(resource);
}
} else {
recorder.markFailedCreateResource(uri);
logger.warn(" Could not create resource for " + uri);
}
});
}
}
}
use of org.eclipse.n4js.projectModel.IN4JSSourceContainer in project n4js by eclipse.
the class N4JSModel method getN4JSSourceContainers.
public ImmutableList<? extends IN4JSSourceContainer> getN4JSSourceContainers(N4JSProject project) {
ImmutableList.Builder<IN4JSSourceContainer> result = ImmutableList.builder();
URI location = project.getLocation();
ProjectDescription description = getProjectDescription(location);
if (description != null) {
List<SourceFragment> sourceFragments = newArrayList(from(description.getSourceFragment()));
sourceFragments.sort((f1, fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) -> f1.compareByFragmentType(fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT));
for (SourceFragment sourceFragment : sourceFragments) {
List<String> paths = sourceFragment.getPaths();
for (String path : paths) {
// XXX poor man's canonical path conversion. Consider headless compiler with npm projects.
final String relativeLocation = ".".equals(path) ? "" : path;
IN4JSSourceContainer sourceContainer = this.createProjectN4JSSourceContainer(project, sourceFragment.getSourceFragmentType(), relativeLocation);
result.add(sourceContainer);
}
}
}
return result.build();
}
use of org.eclipse.n4js.projectModel.IN4JSSourceContainer in project n4js by eclipse.
the class N4JSModel method getSourceContainers.
public ImmutableList<IN4JSSourceContainer> getSourceContainers(N4JSArchive archive) {
ImmutableList.Builder<IN4JSSourceContainer> result = ImmutableList.builder();
URI location = archive.getLocation();
ProjectDescription description = getProjectDescription(location);
if (description != null) {
List<SourceFragment> sourceFragments = newArrayList(from(description.getSourceFragment()));
sourceFragments.sort((f1, fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) -> f1.compareByFragmentType(fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT));
for (SourceFragment sourceFragment : sourceFragments) {
List<String> paths = sourceFragment.getPaths();
for (String path : paths) {
result.add(createArchiveN4JSSourceContainer(archive, sourceFragment.getSourceFragmentType(), path));
}
}
}
return result.build();
}
use of org.eclipse.n4js.projectModel.IN4JSSourceContainer 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