Search in sources :

Example 66 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class MavenTestClasspathProviderTest method buildMocks.

private void buildMocks(List<ClasspathEntry> entries) throws JavaModelException {
    when(classpathService.getClasspath(anyString())).thenReturn(entries.stream().map(ClasspathEntry::dto).collect(Collectors.toList()));
    for (ClasspathEntry entry : entries) {
        if (!entry.external && entry.kind == IClasspathEntry.CPE_LIBRARY) {
            IPath resourceLocation = new Path(entry.fileSystemPath);
            IResource result = mock(IResource.class);
            when(result.getLocation()).thenReturn(resourceLocation);
            when(workspaceRoot.findMember(new Path(entry.fullPath))).thenReturn(result);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IResource(org.eclipse.core.resources.IResource)

Example 67 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class Container method findMember.

@Override
public IResource findMember(String memberPath, boolean phantom) {
    IPath childPath = getFullPath().append(memberPath);
    ResourceInfo info = workspace.getResourceInfo(childPath);
    return info == null ? null : workspace.newResource(childPath, info.getType());
}
Also used : IPath(org.eclipse.core.runtime.IPath)

Example 68 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class FileUtil method computeOverlap.

/**
	 * Returns true if the given file system locations overlap. If "bothDirections" is true,
	 * this means they are the same, or one is a proper prefix of the other.  If "bothDirections"
	 * is false, this method only returns true if the locations are the same, or the first location
	 * is a prefix of the second.  Returns false if the locations do not overlap
	 * Does the right thing with respect to case insensitive platforms.
	 */
private static boolean computeOverlap(IPath location1, IPath location2, boolean bothDirections) {
    IPath one = location1;
    IPath two = location2;
    // If we are on a case-insensitive file system then convert to all lower case.
    if (!Workspace.caseSensitive) {
        one = new Path(location1.toOSString().toLowerCase());
        two = new Path(location2.toOSString().toLowerCase());
    }
    return one.isPrefixOf(two) || (bothDirections && two.isPrefixOf(one));
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath)

Example 69 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class Project method getDescription.

@Override
public IProjectDescription getDescription() throws CoreException {
    return new IProjectDescription() {

        @Override
        public IBuildConfiguration[] getBuildConfigReferences(String s) {
            return new IBuildConfiguration[0];
        }

        @Override
        public ICommand[] getBuildSpec() {
            return new ICommand[0];
        }

        @Override
        public String getComment() {
            return null;
        }

        @Override
        public IProject[] getDynamicReferences() {
            return new IProject[0];
        }

        @Override
        public IPath getLocation() {
            return null;
        }

        @Override
        public URI getLocationURI() {
            return null;
        }

        @Override
        public String getName() {
            return null;
        }

        @Override
        public String[] getNatureIds() {
            RegisteredProject project = workspace.getProjectRegistry().getProject(path.toString());
            if (project == null) {
                ResourcesPlugin.log(new Status(IStatus.ERROR, "resource", "Can't find project: " + path.toOSString()));
                return new String[0];
            }
            Map<String, List<String>> attributes = project.getAttributes();
            String language = "";
            if (attributes.containsKey("language")) {
                language = attributes.get("language").get(0);
            }
            return "java".equals(language) ? new String[] { "org.eclipse.jdt.core.javanature" } : new String[] { language };
        }

        @Override
        public IProject[] getReferencedProjects() {
            return new IProject[0];
        }

        @Override
        public boolean hasNature(String s) {
            String[] natureIds = getNatureIds();
            for (String id : natureIds) {
                if (s.equals(id)) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public ICommand newCommand() {
            return null;
        }

        @Override
        public void setActiveBuildConfig(String s) {
        }

        @Override
        public void setBuildConfigs(String[] strings) {
        }

        @Override
        public void setBuildConfigReferences(String s, IBuildConfiguration[] iBuildConfigurations) {
        }

        @Override
        public void setBuildSpec(ICommand[] iCommands) {
        }

        @Override
        public void setComment(String s) {
        }

        @Override
        public void setDynamicReferences(IProject[] iProjects) {
        }

        @Override
        public void setLocation(IPath iPath) {
        }

        @Override
        public void setLocationURI(URI uri) {
        }

        @Override
        public void setName(String s) {
        }

        @Override
        public void setNatureIds(String[] strings) {
        }

        @Override
        public void setReferencedProjects(IProject[] iProjects) {
        }
    };
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) ICommand(org.eclipse.core.resources.ICommand) IProjectDescription(org.eclipse.core.resources.IProjectDescription) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) List(java.util.List) URI(java.net.URI) IProject(org.eclipse.core.resources.IProject) IBuildConfiguration(org.eclipse.core.resources.IBuildConfiguration)

Example 70 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class Resource method isConflicting.

@Override
public boolean isConflicting(ISchedulingRule rule) {
    if (this == rule)
        return true;
    //must not schedule at same time as notification
    if (rule.getClass().equals(WorkManager.NotifyRule.class))
        return true;
    if (rule instanceof MultiRule) {
        MultiRule multi = (MultiRule) rule;
        ISchedulingRule[] children = multi.getChildren();
        for (int i = 0; i < children.length; i++) if (isConflicting(children[i]))
            return true;
        return false;
    }
    if (!(rule instanceof IResource))
        return false;
    IResource resource = (IResource) rule;
    if (!workspace.equals(resource.getWorkspace()))
        return false;
    IPath otherPath = resource.getFullPath();
    return path.isPrefixOf(otherPath) || otherPath.isPrefixOf(path);
}
Also used : IPath(org.eclipse.core.runtime.IPath) MultiRule(org.eclipse.core.runtime.jobs.MultiRule) IResource(org.eclipse.core.resources.IResource) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Aggregations

IPath (org.eclipse.core.runtime.IPath)800 Path (org.eclipse.core.runtime.Path)219 File (java.io.File)161 IFile (org.eclipse.core.resources.IFile)150 CoreException (org.eclipse.core.runtime.CoreException)135 IResource (org.eclipse.core.resources.IResource)112 IOException (java.io.IOException)100 ArrayList (java.util.ArrayList)92 IProject (org.eclipse.core.resources.IProject)85 IFolder (org.eclipse.core.resources.IFolder)80 Test (org.junit.Test)72 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)58 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)55 IStatus (org.eclipse.core.runtime.IStatus)48 InputStream (java.io.InputStream)44 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)42 Status (org.eclipse.core.runtime.Status)36 IJavaProject (org.eclipse.jdt.core.IJavaProject)36 URL (java.net.URL)33 IContainer (org.eclipse.core.resources.IContainer)33