Search in sources :

Example 1 with IN4JSEclipseSourceContainer

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

the class N4JSEclipseModel method getN4JSSourceContainer.

public Optional<? extends IN4JSSourceContainer> getN4JSSourceContainer(IResource resource) {
    N4JSEclipseProject project = getN4JSProject(resource.getProject());
    ImmutableList<? extends IN4JSEclipseSourceContainer> containers = project.getSourceContainers();
    IPath fullPath = resource.getFullPath();
    for (IN4JSEclipseSourceContainer container : containers) {
        if (matchPaths(fullPath, container)) {
            return Optional.of(container);
        }
    }
    return Optional.absent();
}
Also used : IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) IPath(org.eclipse.core.runtime.IPath) IN4JSEclipseSourceContainer(org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer)

Example 2 with IN4JSEclipseSourceContainer

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

the class N4JSToBeBuiltComputer method updateStorage.

@Override
public boolean updateStorage(ToBeBuilt toBeBuilt, IStorage storage, IProgressMonitor monitor) {
    if (storage instanceof IFile) {
        IFile file = (IFile) storage;
        String extension = file.getFileExtension();
        // changed archive - schedule contents
        if (IN4JSArchive.NFAR_FILE_EXTENSION.equals(extension)) {
            IProject project = file.getProject();
            String key = project.getName() + "|" + storage.getFullPath().toPortableString();
            Set<URI> cachedURIs = knownEntries.remove(key);
            if (cachedURIs != null) {
                toBeBuilt.getToBeDeleted().addAll(cachedURIs);
            }
            cachedURIs = Sets.newHashSet();
            storageMapper.collectNfarURIs((IFile) storage, cachedURIs);
            knownEntries.put(key, cachedURIs);
            toBeBuilt.getToBeUpdated().addAll(cachedURIs);
            return true;
        } else if (IN4JSProject.N4MF_MANIFEST.equals(file.getName())) {
            // changed manifest - schedule all resources from source folders
            final IN4JSEclipseProject project = eclipseCore.create(file.getProject()).orNull();
            if (null != project && project.exists()) {
                List<? extends IN4JSEclipseSourceContainer> sourceContainers = project.getSourceContainers();
                Set<URI> toBeUpdated = toBeBuilt.getToBeUpdated();
                for (IN4JSEclipseSourceContainer sourceContainer : sourceContainers) {
                    for (URI uri : sourceContainer) {
                        if (uriValidator.canBuild(uri, new URIBasedStorage(uri))) {
                            toBeUpdated.add(uri);
                        }
                    }
                }
            }
            IProject resourceProject = file.getProject();
            String projectName = resourceProject.getName();
            Set<URI> toBeDeleted = toBeBuilt.getToBeDeleted();
            for (final IResourceDescription description : builderState.getAllResourceDescriptions()) {
                URI uri = description.getURI();
                if (uri.isPlatformResource()) {
                    if (projectName.equals(uri.segment(1))) {
                        toBeDeleted.add(uri);
                    }
                }
            }
            // still return false because we want to do the normal processing for the manifest file, too
            return false;
        }
    }
    return false;
}
Also used : IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) IFile(org.eclipse.core.resources.IFile) Set(java.util.Set) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) URIBasedStorage(org.eclipse.n4js.ts.ui.navigation.URIBasedStorage) IN4JSEclipseSourceContainer(org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer) List(java.util.List) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject)

Example 3 with IN4JSEclipseSourceContainer

use of org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer 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 4 with IN4JSEclipseSourceContainer

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

the class N4JSEclipseModel method createProjectN4JSSourceContainer.

@Override
protected IN4JSEclipseSourceContainer createProjectN4JSSourceContainer(N4JSProject project, SourceFragmentType type, String relativeLocation) {
    N4JSEclipseProject casted = (N4JSEclipseProject) project;
    IProject eclipseProject = casted.getProject();
    final IContainer container;
    if (".".equals(relativeLocation)) {
        container = eclipseProject;
    } else {
        container = eclipseProject.getFolder(relativeLocation);
    }
    return new EclipseSourceContainer(casted, type, container);
}
Also used : IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) IContainer(org.eclipse.core.resources.IContainer) IN4JSEclipseSourceContainer(org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer) IProject(org.eclipse.core.resources.IProject)

Aggregations

IN4JSEclipseSourceContainer (org.eclipse.n4js.ui.projectModel.IN4JSEclipseSourceContainer)4 IN4JSEclipseProject (org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject)3 IProject (org.eclipse.core.resources.IProject)2 URI (org.eclipse.emf.common.util.URI)2 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 Set (java.util.Set)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 ProjectDescription (org.eclipse.n4js.n4mf.ProjectDescription)1 SourceFragment (org.eclipse.n4js.n4mf.SourceFragment)1 URIBasedStorage (org.eclipse.n4js.ts.ui.navigation.URIBasedStorage)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1