Search in sources :

Example 21 with ProjectDescription

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;
}
Also used : ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription)

Example 22 with ProjectDescription

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;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription)

Example 23 with ProjectDescription

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());
}
Also used : ExecModule(org.eclipse.n4js.n4mf.ExecModule) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription)

Example 24 with ProjectDescription

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();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) IN4JSEclipseSourceContainer(org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer) URI(org.eclipse.emf.common.util.URI) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) SourceFragment(org.eclipse.n4js.n4mf.SourceFragment)

Example 25 with ProjectDescription

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();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IN4JSEclipseArchive(org.eclipse.n4js.ui.projectModel.IN4JSEclipseArchive) IFile(org.eclipse.core.resources.IFile) ImmutableList(com.google.common.collect.ImmutableList) ProjectDependency(org.eclipse.n4js.n4mf.ProjectDependency) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) URI(org.eclipse.emf.common.util.URI)

Aggregations

ProjectDescription (org.eclipse.n4js.n4mf.ProjectDescription)37 URI (org.eclipse.emf.common.util.URI)19 SimpleProjectDescription (org.eclipse.n4js.n4mf.SimpleProjectDescription)11 Test (org.junit.Test)9 ImmutableList (com.google.common.collect.ImmutableList)7 File (java.io.File)6 EObject (org.eclipse.emf.ecore.EObject)6 ProjectDependency (org.eclipse.n4js.n4mf.ProjectDependency)6 Resource (org.eclipse.emf.ecore.resource.Resource)5 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)5 SourceFragment (org.eclipse.n4js.n4mf.SourceFragment)5 N4JSExternalProject (org.eclipse.n4js.external.N4JSExternalProject)4 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)4 IOException (java.io.IOException)3 IFile (org.eclipse.core.resources.IFile)3 ExtendedRuntimeEnvironment (org.eclipse.n4js.n4mf.ExtendedRuntimeEnvironment)3 ProjectReference (org.eclipse.n4js.n4mf.ProjectReference)3 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)3 Optional (com.google.common.base.Optional)2 IResource (org.eclipse.core.resources.IResource)2