Search in sources :

Example 56 with IN4JSProject

use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.

the class RuntimeEnvironmentsHelper method recursiveDependencyCollector.

/**
 * Collects dependencies of the provided source container, by analyzing direct dependencies of the container and
 * recursively their dependencies. Dependencies in form of {@link IN4JSSourceContainerAware} are mapped to
 * {@link IN4JSProject}s, that is instances of {@link IN4JSProject} project are returned as they are, while
 * instances of {@link IN4JSArchive} have contained project extracted.
 *
 * Discovered dependencies are collected only if they pass test specified by provided predicate.
 *
 * @param sourceContainer
 *            whose dependencies will be collected
 * @param collection
 *            where dependencies are collected
 * @param predicate
 *            to test if given dependency should be collected
 */
private void recursiveDependencyCollector(IN4JSSourceContainerAware sourceContainer, Collection<IN4JSProject> collection, Predicate<IN4JSProject> predicate) {
    IN4JSProject project = (extractProject(sourceContainer));
    if (predicate.test(project))
        collection.add(project);
    sourceContainer.getAllDirectDependencies().forEach(dep -> recursiveDependencyCollector(dep, collection, predicate));
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject)

Example 57 with IN4JSProject

use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.

the class TesterFileBasedShippedCodeConfigurationHelper method configureFromFileSystem.

/**
 * Reconfigures provided run configuration in regards of {@link TestConfiguration#getExecModule()},
 * {@link TestConfiguration#getInitModules()} and {@link TestConfiguration#getCoreProjectPaths()} by plain using
 * file system access to the shipped code. Intended to be used in situations where proper workspace setup is not
 * available and run configurations created by default are lacking essential information.
 *
 * It is up to the caller to decide when it is appropriate to call this method.
 *
 * @param config
 *            the configuration to be reconfigured.
 */
public void configureFromFileSystem(TestConfiguration config) {
    Iterable<IN4JSProject> allShippedProjects = RunnerN4JSCore.getAllShippedProjects();
    IN4JSProject customRuntimeEnvironment = getCustomRuntimeEnvironment(config, allShippedProjects);
    reconfigure(config, allShippedProjects, customRuntimeEnvironment);
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject)

Example 58 with IN4JSProject

use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.

the class N4JSAllContainersState method isSourceContainerModification.

private boolean isSourceContainerModification(final IResourceDelta delta) {
    final String fullPath = delta.getFullPath().toString();
    final URI folderUri = URI.createPlatformResourceURI(fullPath, true);
    final IN4JSProject project = core.findProject(folderUri).orNull();
    if (null != project && project.exists()) {
        return from(project.getSourceContainers()).transform(container -> container.getLocation()).filter(uri -> uri.isPlatformResource()).transform(uri -> uri.toString()).transform(uri -> uri.replaceFirst(PLATFORM_RESOURCE_SCHEME, "")).firstMatch(uri -> uri.equals(fullPath)).isPresent();
    }
    return false;
}
Also used : IFolder(org.eclipse.core.resources.IFolder) URI(org.eclipse.emf.common.util.URI) INTERACTIVE(org.eclipse.core.runtime.jobs.Job.INTERACTIVE) OwnResourceValidatorAwareValidatingEditorCallback(org.eclipse.n4js.ui.internal.OwnResourceValidatorAwareValidatingEditorCallback) Inject(com.google.inject.Inject) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) OK_STATUS(org.eclipse.core.runtime.Status.OK_STATUS) PlatformUI.getWorkbench(org.eclipse.ui.PlatformUI.getWorkbench) IN4JSCore(org.eclipse.n4js.projectModel.IN4JSCore) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IFileEditorInput(org.eclipse.ui.IFileEditorInput) Logger(org.apache.log4j.Logger) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ALL(org.eclipse.xtext.validation.CheckMode.ALL) IProject(org.eclipse.core.resources.IProject) IResourceDelta(org.eclipse.core.resources.IResourceDelta) PartInitException(org.eclipse.ui.PartInitException) Optional(com.google.common.base.Optional) FluentIterable.from(com.google.common.collect.FluentIterable.from) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) IFile(org.eclipse.core.resources.IFile) N4MF_MANIFEST(org.eclipse.n4js.projectModel.IN4JSProject.N4MF_MANIFEST) FileExtensionTypeHelper(org.eclipse.n4js.fileextensions.FileExtensionTypeHelper) Job(org.eclipse.core.runtime.jobs.Job) IEditorInput(org.eclipse.ui.IEditorInput) Collection(java.util.Collection) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) ResourceUIValidatorExtension(org.eclipse.n4js.ui.internal.ResourceUIValidatorExtension) PlatformUI.isWorkbenchRunning(org.eclipse.ui.PlatformUI.isWorkbenchRunning) Display(org.eclipse.swt.widgets.Display) AbstractAllContainersState(org.eclipse.xtext.ui.containers.AbstractAllContainersState) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) List(java.util.List) IN4JSArchive(org.eclipse.n4js.projectModel.IN4JSArchive) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) IEditorReference(org.eclipse.ui.IEditorReference) Singleton(com.google.inject.Singleton) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) URI(org.eclipse.emf.common.util.URI)

Example 59 with IN4JSProject

use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.

the class ProjectTypeLabelDecorator method decorate.

@Override
public void decorate(final Object element, final IDecoration decoration) {
    try {
        if (element instanceof IProject) {
            final URI uri = createPlatformResourceURI(((IProject) element).getName(), true);
            final IN4JSProject project = core.findProject(uri).orNull();
            if (null != project) {
                final ImageRef imageRef = IMAGE_REF_CACHE.get(project.getProjectType());
                if (null != imageRef) {
                    final ImageDescriptor descriptor = imageRef.asImageDescriptor().orNull();
                    if (null != descriptor) {
                        decoration.addOverlay(descriptor);
                    }
                }
            }
        }
    } catch (final Exception e) {
        // Exception should not propagate from here, otherwise the lightweight decorator stops working once till
        // next application startup.
        LOGGER.error("Error while trying to get decorator for " + element, e);
    }
}
Also used : IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) ImageRef(org.eclipse.n4js.ui.ImageDescriptorCache.ImageRef) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) URI(org.eclipse.emf.common.util.URI) URI.createPlatformResourceURI(org.eclipse.emf.common.util.URI.createPlatformResourceURI) IProject(org.eclipse.core.resources.IProject)

Example 60 with IN4JSProject

use of org.eclipse.n4js.projectModel.IN4JSProject in project n4js by eclipse.

the class SourceFolderSelectionDialog method collectSourceFolders.

private List<String> collectSourceFolders(IProject project) {
    if (null == project) {
        return null;
    }
    // Collect source folders for the given project
    URI uri = URI.createPlatformResourceURI(project.getName(), true);
    IN4JSProject n4Project = n4jsCore.findProject(uri).orNull();
    if (null == n4Project) {
        return null;
    }
    return n4Project.getSourceContainers().stream().filter(// Filter out external and library folders
    src -> (src.isTest() || src.isSource())).map(src -> src.getRelativeLocation()).collect(Collectors.toList());
}
Also used : URI(org.eclipse.emf.common.util.URI) UIUtils(org.eclipse.n4js.ui.utils.UIUtils) Inject(com.google.inject.Inject) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) Image(org.eclipse.swt.graphics.Image) ListDialog(org.eclipse.ui.dialogs.ListDialog) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) IN4JSCore(org.eclipse.n4js.projectModel.IN4JSCore) Collectors(java.util.stream.Collectors) List(java.util.List) IProject(org.eclipse.core.resources.IProject) ImageDescriptorCache(org.eclipse.n4js.ui.ImageDescriptorCache) LabelProvider(org.eclipse.jface.viewers.LabelProvider) IN4JSProject(org.eclipse.n4js.projectModel.IN4JSProject) URI(org.eclipse.emf.common.util.URI)

Aggregations

IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)93 URI (org.eclipse.emf.common.util.URI)32 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)13 List (java.util.List)11 Inject (com.google.inject.Inject)9 Map (java.util.Map)9 IProject (org.eclipse.core.resources.IProject)9 IN4JSCore (org.eclipse.n4js.projectModel.IN4JSCore)9 Optional (com.google.common.base.Optional)7 File (java.io.File)7 Collection (java.util.Collection)7 HashSet (java.util.HashSet)7 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)7 Set (java.util.Set)6 Collectors (java.util.stream.Collectors)6 IOException (java.io.IOException)5 IN4JSArchive (org.eclipse.n4js.projectModel.IN4JSArchive)5 IN4JSSourceContainer (org.eclipse.n4js.projectModel.IN4JSSourceContainer)5 FluentIterable.from (com.google.common.collect.FluentIterable.from)4