/** * Returns the value associated with the given key */ public T get(IPath key) { Node<T> node = this.root.getMostSpecificNode(key); if (!node.exists || node.depth < key.segmentCount()) { return null; } return node.value; }
public static boolean hasDotDot(IPath path) { for (int i = 0, length = path.segmentCount(); i < length; i++) { if (DOT_DOT.equals(path.segment(i))) return true; } return false; }
protected boolean isNonProjectSpecificContainer(IPath containerPath) { if (containerPath.segmentCount() > 0) { String id= containerPath.segment(0); if (id.equals(JavaCore.USER_LIBRARY_CONTAINER_ID) || id.equals(JavaRuntime.JRE_CONTAINER)) { return true; } } return false; }
/** * @param path full absolute workspace path */ private static boolean isInternalFilePath(IPath path) { IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); // in case this is full workspace path it should start with project segment if(path.segmentCount() > 1 && wsRoot.getFile(path).exists()) { return true; } return false; }
/** * @deprecated use {@link #getFileStore(IPath)} instead */ @Deprecated @Override public IFileStore getChild(IPath path) { IFileStore result = this; for (int i = 0, imax = path.segmentCount(); i < imax; i++) result = result.getChild(path.segment(i)); return result; }
/** * Gets the source attachment path chosen by the user * @return the source attachment path */ public IPath getSourceAttachmentPath() { return (getFilePath().segmentCount() == 0) ? null : getFilePath(); }
/** * Returns true if this resource represents the project description file, and * false otherwise. */ protected boolean isProjectDescriptionFile(IResource resource) { return resource.getType() == IResource.FILE && resource.getFullPath().segmentCount() == 2 && resource.getName().equals(IProjectDescription.DESCRIPTION_FILE_NAME); }
/** * Gets the description file (as workspace resource). * * @return a file which points to the description */ public IFile getDescriptionFile() { IPath path= getDescriptionLocation(); if (path.isValidPath(path.toString()) && path.segmentCount() >= 2) return JavaPlugin.getWorkspace().getRoot().getFile(path); else return null; }
/** * The path is known to match a source/library folder entry. * @param path IPath * @return IPackageFragmentRoot */ public IPackageFragmentRoot getFolderPackageFragmentRoot(IPath path) { if (path.segmentCount() == 1) { // default project root return getPackageFragmentRoot(this.project); } return getPackageFragmentRoot(this.project.getWorkspace().getRoot().getFolder(path)); }
@Override public int visit(Entry sourceEntry) { IPath destinationPath = destination.append(sourceEntry.getPath().removeFirstSegments(source.segmentCount())); HistoryEntry destinationEntry = new HistoryEntry(destinationPath, (HistoryEntry) sourceEntry); // we may be copying to the same source bucket, collect to make change effective later // since we cannot make changes to it while iterating changes.add(destinationEntry); return CONTINUE; } }
@Override public int visit(Entry entry) { PropertyEntry sourceEntry = (PropertyEntry) entry; IPath destinationPath = destination.append(sourceEntry.getPath().removeFirstSegments(source.segmentCount())); PropertyEntry destinationEntry = new PropertyEntry(destinationPath, sourceEntry); changes.add(destinationEntry); return CONTINUE; } }
Node<T> createNode(IPath key) { if (this.depth == key.segmentCount()) { this.exists = true; return this; } String nextSegment = getSegment(key); Node<T> next = createChild(nextSegment); return next.createNode(key); }
private IPackageFragmentRoot findPackageFragmentRoot(IJavaProject jProject, IPath path) throws JavaModelException { if (jProject == null || path == null || path.segmentCount() <= 0) return null; IPackageFragmentRoot pkgRoot= jProject.findPackageFragmentRoot(path); if (pkgRoot != null) return pkgRoot; else return findPackageFragmentRoot(jProject, path.removeLastSegments(1)); }
/** * @deprecated use {@link #resolveURI(URI)} instead. */ @Override @Deprecated public IPath resolvePath(IPath path) { if (path == null || path.segmentCount() == 0 || path.isAbsolute() || path.getDevice() != null) return path; URI value = resolveURI(URIUtil.toURI(path)); return value == null ? path : URIUtil.toPath(value); }
@Override public IClasspathAttribute performEdit(Shell shell, ClasspathAttributeAccess attribute) { String initialLocation= attribute.getClasspathAttribute().getValue(); IPath locationPath= initialLocation == null ? null : new Path(initialLocation); IPath newPath= BuildPathDialogAccess.configureExternalAnnotationsAttachment(shell, locationPath); if(null == newPath) // Was the dialog cancelled? return null; return JavaCore.newClasspathAttribute(IClasspathAttribute.EXTERNAL_ANNOTATION_PATH, newPath.segmentCount() == 0 ? null : newPath.toPortableString()); }
/** * @see org.eclipse.core.resources.IPathVariableManager#resolvePath(IPath) */ @Deprecated @Override public IPath resolvePath(IPath path) { if (path == null || path.segmentCount() == 0 || path.isAbsolute() || path.getDevice() != null) return path; IPath value = getValue(path.segment(0)); return value == null ? path : value.append(path.removeFirstSegments(1)); }
private static boolean addToExclusions(IPath entryPath, CPListElement curr) { IPath[] exclusionFilters= (IPath[]) curr.getAttribute(CPListElement.EXCLUSION); if (!JavaModelUtil.isExcludedPath(entryPath, exclusionFilters)) { IPath pathToExclude= entryPath.removeFirstSegments(curr.getPath().segmentCount()).addTrailingSeparator(); IPath[] newExclusionFilters= new IPath[exclusionFilters.length + 1]; System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length); newExclusionFilters[exclusionFilters.length]= pathToExclude; curr.setAttribute(CPListElement.EXCLUSION, newExclusionFilters); return true; } return false; }
protected void mkdirs(IPath path, IWorkspaceRoot root) throws CoreException { if (path.segmentCount() <= 1) return; IFolder folder = root.getFolder(path); if (!folder.exists()) { mkdirs(path.removeLastSegments(1), root); folder.create(true, true, null); } }
private IResource getUnderlyingDirectory(EclipseSourceDirectory directory) { IProject project = this.project.getProject(); IPath path = project.getFullPath().append(directory.getPath()); if (path.segmentCount() == 1) { return project; } return project.getFolder(path.removeFirstSegments(1)); }
protected IPath createNewPath(IPackageFragment oldPackage) { IPath oldPackagePath= createPath(oldPackage.getElementName()); IPath newPackagePath= createPath(getNewName(oldPackage)); return oldPackage.getPath().removeLastSegments(oldPackagePath.segmentCount()).append(newPackagePath); }