Search in sources :

Example 1 with IN4JSEclipseProject

use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.

the class NfarStorageMapper method initializeCache.

@Override
public void initializeCache() {
    Optional<? extends IN4JSEclipseProject> projectOpt = null;
    IN4JSEclipseProject n4jsProject = null;
    for (IProject project : workspace.getRoot().getProjects()) {
        projectOpt = eclipseCore.create(project);
        if (projectOpt.isPresent()) {
            n4jsProject = projectOpt.get();
            if (n4jsProject.exists()) {
                updateCache(n4jsProject);
            }
        }
    }
    Listener listener = new Listener();
    workspace.addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE);
}
Also used : IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) IProject(org.eclipse.core.resources.IProject)

Example 2 with IN4JSEclipseProject

use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.

the class NfarStorageMapper method collectNfarURIs.

public void collectNfarURIs(IProject project, Set<URI> target) {
    Optional<? extends IN4JSEclipseProject> projectOpt = eclipseCore.create(project);
    if (projectOpt.isPresent()) {
        IN4JSEclipseProject n4jsProject = projectOpt.get();
        Set<URI> archives = knownLibArchives.get(n4jsProject.getLocation());
        if (archives != null) {
            for (URI archiveURI : archives) {
                Set<URI> entries = knownEntries.get(archiveURI);
                if (entries != null) {
                    target.addAll(entries);
                }
            }
        }
    }
}
Also used : IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) URI(org.eclipse.emf.common.util.URI)

Example 3 with IN4JSEclipseProject

use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.

the class N4MFProjectDependencyStrategy method getProjectDependencies.

@Override
public List<IProject> getProjectDependencies(final IProject project) {
    final IN4JSEclipseProject n4Project = core.create(project).orNull();
    if (null != n4Project) {
        // This covers project dependencies, tests (if any), required REs and required RLs and APIs.
        final Collection<? extends IN4JSEclipseProject> dependencies = n4Project.getDependenciesAndImplementedApis();
        // This is for the provided runtime libraries.
        final Collection<IN4JSEclipseProject> providedRuntimeLibs = from(n4Project.getProvidedRuntimeLibraries()).filter(IN4JSEclipseProject.class).toList();
        // This is for the extended RE, if specified.
        final IN4JSSourceContainerAware srcContainerAware = n4Project.getExtendedRuntimeEnvironment().orNull();
        final IN4JSEclipseProject extendedRE = srcContainerAware instanceof IN4JSEclipseProject ? (IN4JSEclipseProject) srcContainerAware : null;
        int projectCount = dependencies.size() + providedRuntimeLibs.size();
        if (null != extendedRE) {
            projectCount++;
        }
        final IProject[] projects = new IProject[projectCount];
        int i = 0;
        for (final IN4JSEclipseProject dependency : dependencies) {
            projects[i++] = dependency.getProject();
        }
        for (final IN4JSEclipseProject providedRuntimeLib : providedRuntimeLibs) {
            projects[i++] = providedRuntimeLib.getProject();
        }
        if (null != extendedRE) {
            projects[i] = extendedRE.getProject();
        }
        return from(asList(projects)).filter(p -> !(p instanceof ExternalProject)).toList();
    } else {
        return emptyList();
    }
}
Also used : List(java.util.List) IProject(org.eclipse.core.resources.IProject) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) FluentIterable.from(com.google.common.collect.FluentIterable.from) Collection(java.util.Collection) Inject(com.google.inject.Inject) IN4JSEclipseCore(org.eclipse.n4js.ui.projectModel.IN4JSEclipseCore) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) IN4JSSourceContainerAware(org.eclipse.n4js.projectModel.IN4JSSourceContainerAware) IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) ExternalProject(org.eclipse.n4js.utils.resources.ExternalProject) IN4JSSourceContainerAware(org.eclipse.n4js.projectModel.IN4JSSourceContainerAware) IProject(org.eclipse.core.resources.IProject)

Example 4 with IN4JSEclipseProject

use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.

the class TestResultsView method onDoubleClick.

/**
 * Invoked when user double-clicks a result node in the UI.
 */
protected void onDoubleClick() {
    final ISelection selection = testTreeViewer.getSelection();
    final ResultNode resultNode = (ResultNode) ((IStructuredSelection) selection).getFirstElement();
    if (resultNode == null) {
        return;
    }
    TestElement testElement = resultNode.getElement();
    if (testElement instanceof TestCase) {
        final URI testCaseURI = ((TestCase) testElement).getURI();
        if (testCaseURI == null) {
            return;
        }
        final IN4JSEclipseProject project = core.findProject(testCaseURI).orNull();
        if (null != project && project.exists()) {
            final URI moduleLocation = testCaseURI.trimFragment();
            final String[] projectRelativeSegments = moduleLocation.deresolve(project.getLocation()).segments();
            final String path = Joiner.on(SEPARATOR).join(copyOfRange(projectRelativeSegments, 1, projectRelativeSegments.length));
            final IFile module = project.getProject().getFile(path);
            if (null != module && module.isAccessible()) {
                uriOpener.open(testCaseURI, true);
            } else {
                openError(getShell(), "Cannot open editor", "Test class not found in selected project.");
            }
        } else {
            openError(getShell(), "Cannot open editor", "The container project not found in the workspace.");
        }
    }
}
Also used : IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) IFile(org.eclipse.core.resources.IFile) TestCase(org.eclipse.n4js.tester.domain.TestCase) ISelection(org.eclipse.jface.viewers.ISelection) TestElement(org.eclipse.n4js.tester.domain.TestElement) URI(org.eclipse.emf.common.util.URI)

Example 5 with IN4JSEclipseProject

use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject in project n4js by eclipse.

the class NfarStorageMapper method collectNfarURIs.

public void collectNfarURIs(IFile nfarArchive, Set<URI> target) {
    URI archiveURI = URI.createPlatformResourceURI(nfarArchive.getFullPath().toString(), true);
    Set<URI> entries = knownEntries.get(archiveURI);
    if (entries != null) {
        target.addAll(entries);
    } else if (nfarArchive.exists()) {
        Optional<? extends IN4JSEclipseProject> projectOpt = eclipseCore.create(nfarArchive.getProject());
        if (projectOpt.isPresent()) {
            IN4JSEclipseProject n4jsProject = projectOpt.get();
            if (n4jsProject.exists()) {
                updateCache(n4jsProject);
            }
            entries = knownEntries.get(archiveURI);
            if (entries != null) {
                target.addAll(entries);
            } else {
                // project exists but archive is not on the project path - we have to scan it nevertheless
                Optional<? extends IN4JSEclipseArchive> archive = eclipseCore.findArchive(archiveURI);
                if (archive.isPresent()) {
                    traverseArchive(archive.get(), target);
                }
            }
        }
    }
}
Also used : IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) IN4JSEclipseArchive(org.eclipse.n4js.ui.projectModel.IN4JSEclipseArchive) Optional(com.google.common.base.Optional) URI(org.eclipse.emf.common.util.URI)

Aggregations

IN4JSEclipseProject (org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject)10 URI (org.eclipse.emf.common.util.URI)7 IProject (org.eclipse.core.resources.IProject)5 List (java.util.List)3 Set (java.util.Set)2 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 IN4JSEclipseArchive (org.eclipse.n4js.ui.projectModel.IN4JSEclipseArchive)2 Joiner (com.google.common.base.Joiner)1 Optional (com.google.common.base.Optional)1 BiMap (com.google.common.collect.BiMap)1 FluentIterable.from (com.google.common.collect.FluentIterable.from)1 HashBiMap (com.google.common.collect.HashBiMap)1 Lists (com.google.common.collect.Lists)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Sets (com.google.common.collect.Sets)1 Inject (com.google.inject.Inject)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 IOException (java.io.IOException)1