use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class FileBasedWorkspace method getProjectDescription.
@Override
public ProjectDescription getProjectDescription(URI location) {
LazyProjectDescriptionHandle handle = projectElementHandles.get(location);
if (handle == null) {
// check case without trailing path separator
if (location.hasTrailingPathSeparator()) {
handle = projectElementHandles.get(location.trimSegments(1));
}
}
if (handle == null) {
return null;
}
ProjectDescription description = handle.resolve();
return description;
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class LazyProjectDescriptionHandle method loadManifest.
protected ProjectDescription loadManifest(URI manifest) {
ResourceSet resourceSet = resourceSetProvider.get();
Resource resource = resourceSet.getResource(manifest, true);
List<EObject> contents = resource.getContents();
if (contents.isEmpty() || !(contents.get(0) instanceof ProjectDescription)) {
return null;
}
// do some error handling:
if (!resource.getErrors().isEmpty()) {
throw new N4JSBrokenProjectException("Reading project description from " + manifest + " raised the following errors: " + Joiner.on('\n').join(resource.getErrors().stream().map(error -> error.getMessage() + " at line " + error.getLine()).iterator()));
}
ProjectDescription result = (ProjectDescription) contents.get(0);
contents.clear();
return result;
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class N4JSProject method getExecModule.
@Override
public Optional<BootstrapModule> getExecModule() {
if (!exists()) {
return absent();
}
final ProjectDescription pd = model.getProjectDescription(getLocation());
if (pd == null) {
return absent();
}
final ExecModule execModule = pd.getExecModule();
if (null == execModule) {
return absent();
}
return Optional.fromNullable(execModule.getExecModule());
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class N4JSEclipseModel method getN4JSSourceContainers.
@Override
public ImmutableList<? extends IN4JSEclipseSourceContainer> getN4JSSourceContainers(N4JSProject project) {
ImmutableList.Builder<IN4JSEclipseSourceContainer> result = ImmutableList.builder();
URI location = project.getLocation();
ProjectDescription description = getProjectDescription(location);
if (description != null) {
List<SourceFragment> sourceFragments = newArrayList(from(description.getSourceFragment()));
sourceFragments.sort((f1, f2) -> f1.compareByFragmentType(f2));
for (SourceFragment sourceFragment : sourceFragments) {
List<String> paths = sourceFragment.getPaths();
for (String p : paths) {
IN4JSEclipseSourceContainer sourceContainer = createProjectN4JSSourceContainer(project, sourceFragment.getSourceFragmentType(), p);
result.add(sourceContainer);
}
}
}
return result.build();
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class N4JSEclipseModel method doGetLibraries.
protected ImmutableList<? extends IN4JSEclipseArchive> doGetLibraries(N4JSEclipseProject project, URI location) {
ImmutableList.Builder<IN4JSEclipseArchive> result = ImmutableList.builder();
ProjectDescription description = getProjectDescription(location);
if (description != null) {
List<ProjectDependency> dependencies = description.getAllProjectDependencies();
for (ProjectDependency dependency : dependencies) {
URI dependencyLocation = getInternalWorkspace().getLocation(location, dependency, N4JSSourceContainerType.ARCHIVE);
if (dependencyLocation != null) {
IFile archive = workspace.getFile(new Path(dependencyLocation.toPlatformString(true)));
result.add(getN4JSArchive(project, archive));
}
}
}
return result.build();
}
Aggregations