public static IResource getResource(Path path) { final IPath iPath = getIPath(path); final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); final IResource res = Files.isDirectory(path) ? root.getContainerForLocation(iPath) : root.getFileForLocation(iPath); return res; }
private Set<IContainer> getIncludedPaths(IMemento memento) { IMemento child = memento.getChild(INCLUDED_PATHS_NODE_KEY); Set<IContainer> result = new HashSet<IContainer>(); if (child != null) { IMemento[] pathNode = child.getChildren(INCLUDED_PATH_KEY); if (pathNode != null) { for (IMemento path : pathNode) { String includedPath = path.getString(INCLUDED_PATH_KEY); IContainer container = ResourcesPlugin.getWorkspace().getRoot() .getContainerForLocation(new Path(includedPath)); result.add(container); } return result; } } return null; }
private static IResource[] getResourcesImpl(GitModelObject[] children) { List<IResource> result = new ArrayList<IResource>(children.length); for (GitModelObject object : children) { IPath location = object.getLocation(); IResource resource; if (object.isContainer()) resource = ROOT.getContainerForLocation(location); else resource = ROOT.getFileForLocation(location); if (resource != null) result.add(resource); } return result.toArray(new IResource[result.size()]); }
private IContainer getContainer(ILaunchConfiguration configuration) throws CoreException { String projectPath = configuration.getAttribute(DotnetRunDelegate.PROJECT_FOLDER, ""); //$NON-NLS-1$ if (projectPath == null) { return null; } IPath location = new Path(projectPath); if (location.toFile().isDirectory()) { return ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(location); } else if (location.segmentCount() == 1) { return ResourcesPlugin.getWorkspace().getRoot().getProject(location.segments()[0]); } else { return ResourcesPlugin.getWorkspace().getRoot().getFolder(location); } }
public Object getSourceElement(IStackFrame stackFrame) { if (stackFrame instanceof ScriptStackFrame) { ScriptStackFrame sf = (ScriptStackFrame) stackFrame; URI uri = sf.getSourceURI(); String pathname = uri.getPath(); if (Platform.getOS().equals(Platform.OS_WIN32)) { pathname = pathname.substring(1); } File file = new File(pathname); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IContainer container = root.getContainerForLocation(new Path(file.getParent())); if (container != null) { IResource resource = container.findMember(file.getName()); if (resource instanceof IFile) { return resource; } } else { return file; } } return null; }
private Repository getRepositoryForPath(String containerPath) { IPath path = Path.fromPortableString(containerPath); IContainer mappedContainer = ResourcesPlugin.getWorkspace().getRoot() .getContainerForLocation(path); GitProjectData projectData = GitProjectData.get((IProject) mappedContainer); if (projectData == null) return null; RepositoryMapping mapping = projectData.getRepositoryMapping(mappedContainer); if (mapping != null) return mapping.getRepository(); return null; }
@Override public void mkDir(Path path) throws IOException { IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(getIPath(path)); if (container == null) { JAVA.mkDir(path); } else { try { if (container instanceof IFolder) { final LinkedList<IFolder> folders = new LinkedList<>(); while (!container.exists()) { folders.addFirst((IFolder) container); container = container.getParent(); } for (final IFolder folder : folders) { folder.create(true, true, null); } } } catch (CoreException | ClassCastException | NullPointerException e) { throw new IOException(e); } } }
private static IPath getRootPath(IPath path, String definingPluginId) { IPluginModelBase model = PluginRegistry.findModel(definingPluginId); if (model != null && model.getInstallLocation() != null) { IPath newPath = new Path(model.getInstallLocation()).append(path); IWorkspaceRoot root = PDEPlugin.getWorkspace().getRoot(); IContainer container = root.getContainerForLocation(newPath); if (container != null) return container.getFullPath(); } return path; }
private void setDefaultValues(File dir, String buildFilename) { try { IContainer container = PDEPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(dir.toString())); if (container != null && container.exists()) { IProject project = container.getProject(); if (project != null) { project.refreshLocal(IResource.DEPTH_INFINITE, null); IFile file = container.getFile(new Path(buildFilename)); if (file.exists()) BaseBuildAction.setDefaultValues(file); } } } catch (CoreException e) { } }
public static IJavaProject getJavaProject(final IPath path) { final IJavaProject[] javaProjects = getJavaProjects(); for (final IJavaProject javaProject : javaProjects) { final IPath fullPath = javaProject.getProject().getFullPath(); if (fullPath.equals(path)) { return javaProject; } } final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IContainer container = root.getContainerForLocation(path); if (container != null) { return getJavaProject(container); } container = root.getContainerForLocation(root.getLocation().append(path)); return getJavaProject(container); }
@Override public IProject[] getProjects() { IProject[] projects = null; if (!object.isContainer()) { IProject project = getProject(ResourcesPlugin.getWorkspace() .getRoot().getFileForLocation(object.getLocation())); if (project != null) projects = new IProject[] { project }; } else if (object instanceof GitModelTree) { IProject project = getProject(ResourcesPlugin.getWorkspace() .getRoot().getContainerForLocation(object.getLocation())); if (project != null) projects = new IProject[] { project }; } else if (object instanceof HasProjects) projects = ((HasProjects) object).getProjects(); return projects != null ? projects : new IProject[0]; } }
IResource resource = wsroot.getFileForLocation(rootPath); if (resource == null) { resource = wsroot.getContainerForLocation(rootPath);
IContainer container = root.getContainerForLocation(new Path(bundle.getLocation())); if (container == null) return true;
String inputFileLocation = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, ""); //$NON-NLS-1$ IContainer projectFolder = ResourcesPlugin.getWorkspace().getRoot() .getContainerForLocation(new Path(projectLocation)); File projectFileLocation = new File(projectLocation);
protected void resolveProjectPathEntry(boolean includeSource, IPath p) { IPath projectPath = makeAbsolute(p); IWorkspace ws = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = ws.getRoot(); IProject project = (IProject) root.getContainerForLocation(projectPath); try { P javaProject = makeProject(project); if (javaProject != null) { if (isPluginProject(project)) { resolvePluginClassPath(project, includeSource); } resolveProjectClasspathEntries(javaProject, scopeType == AnalysisScopeType.SOURCE_FOR_PROJ_AND_LINKED_PROJS ? includeSource : false); } } catch (CoreException e1) { e1.printStackTrace(); Assertions.UNREACHABLE(); } catch (IOException e) { e.printStackTrace(); Assertions.UNREACHABLE(); } }
ouputFolder = member; } else { ouputFolder = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path);
IContainer container = root.getContainerForLocation(new Path(pom.getAbsolutePath())); if (container == null) { digestStore.updateDigest(pom.toPath());
IContainer container = root.getContainerForLocation(new Path(bundle.getLocation())); if (container == null) return true;
} else { String path = fLaunchConfiguration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, "/"); //$NON-NLS-1$ IContainer container = PDEPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(path)); if (container != null) { IConfigurationFileInfo info = factory.createConfigFileInfo();
IResource res = root.getContainerForLocation(obj.getLocation()); if (res == null) res = root.getFolder(obj.getLocation());