Search in sources :

Example 11 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class EclipseBasedN4JSWorkspace method loadManifest.

ProjectDescription loadManifest(URI manifest) {
    try {
        ProjectDescription result = null;
        ResourceSet resourceSet = resourceSetProvider.get(null);
        String platformPath = manifest.toPlatformString(true);
        if (manifest.isArchive() || platformPath != null) {
            if (manifest.isArchive() || workspace.getFile(new Path(platformPath)).exists()) {
                Resource resource = resourceSet.getResource(manifest, true);
                if (resource != null) {
                    List<EObject> contents = resource.getContents();
                    if (contents.isEmpty() || !(contents.get(0) instanceof ProjectDescription)) {
                        return null;
                    }
                    result = (ProjectDescription) contents.get(0);
                    contents.clear();
                }
            }
        }
        return result;
    } catch (WrappedException e) {
        throw new IllegalStateException("Unexpected manifest URI: " + manifest, e);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) WrappedException(org.eclipse.emf.common.util.WrappedException) EObject(org.eclipse.emf.ecore.EObject) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription)

Example 12 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class ExternalProjectCacheLoader method load.

@Override
public Optional<Pair<N4JSExternalProject, ProjectDescription>> load(final URI rootLocation) throws Exception {
    ProjectDescription projectDescription = packageManager.loadManifestFromProjectRoot(rootLocation);
    if (null != projectDescription) {
        File projectRoot = new File(rootLocation.toFileString());
        ExternalProject p = new ExternalProject(projectRoot, NATURE_ID, BUILDER_ID);
        IN4JSProject pp = new N4JSEclipseProject(p, rootLocation, model);
        N4JSExternalProject ppp = new N4JSExternalProject(projectRoot, pp);
        return Optional.of(Tuples.create(ppp, projectDescription));
    }
    return Optional.absent();
}
Also used : N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) File(java.io.File)

Example 13 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class EclipseExternalLibraryWorkspace method getLocation.

@Override
public URI getLocation(URI projectURI, ProjectReference reference, N4JSSourceContainerType expectedN4JSSourceContainerType) {
    if (PROJECT.equals(expectedN4JSSourceContainerType)) {
        String name = reference.getProject().getProjectId();
        ExternalProject project = projectProvider.getProject(name);
        if (null == project) {
            return null;
        }
        File referencedProject = new File(project.getLocationURI());
        URI refLocation = URI.createFileURI(referencedProject.getAbsolutePath());
        Pair<N4JSExternalProject, ProjectDescription> pair = projectProvider.getProjectWithDescription(refLocation);
        if (null != pair) {
            return refLocation;
        }
    }
    return null;
}
Also used : N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) N4JSExternalProject(org.eclipse.n4js.external.N4JSExternalProject) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URI(org.eclipse.emf.common.util.URI) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription)

Example 14 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class DependenciesHelper method getAvailableProjectsDescriptions.

private Iterable<ProjectDescription> getAvailableProjectsDescriptions(List<File> allProjectsRoots) {
    List<ProjectDescription> descriptions = new ArrayList<>();
    allProjectsRoots.forEach(root -> {
        File manifest = new File(root, IN4JSProject.N4MF_MANIFEST);
        if (!manifest.isFile()) {
            System.out.println("Cannot read manifest at " + root);
            return;
        }
        ProjectDescription projectDescription = ProjectDescriptionProviderUtil.getFromFile(manifest);
        descriptions.add(projectDescription);
    });
    return descriptions;
}
Also used : ArrayList(java.util.ArrayList) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) File(java.io.File)

Example 15 with ProjectDescription

use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.

the class N4JSModel method getExtendedRuntimeEnvironmentName.

public Optional<String> getExtendedRuntimeEnvironmentName(URI location) {
    if (null == location) {
        return absent();
    }
    final ProjectDescription description = getProjectDescription(location);
    if (null == description) {
        return absent();
    }
    final ExtendedRuntimeEnvironment extendedRe = description.getExtendedRuntimeEnvironment();
    if (null == extendedRe) {
        return absent();
    }
    final ProjectReference reRef = extendedRe.getExtendedRuntimeEnvironment();
    if (null == reRef) {
        return absent();
    }
    final SimpleProjectDescription project = reRef.getProject();
    if (null == project) {
        return absent();
    }
    return fromNullable(project.getProjectId());
}
Also used : ExtendedRuntimeEnvironment(org.eclipse.n4js.n4mf.ExtendedRuntimeEnvironment) ProjectReference(org.eclipse.n4js.n4mf.ProjectReference) SimpleProjectDescription(org.eclipse.n4js.n4mf.SimpleProjectDescription) ProjectDescription(org.eclipse.n4js.n4mf.ProjectDescription) SimpleProjectDescription(org.eclipse.n4js.n4mf.SimpleProjectDescription)

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