congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
IPath.uptoSegment
Code IndexAdd Tabnine to your IDE (free)

How to use
uptoSegment
method
in
org.eclipse.core.runtime.IPath

Best Java code snippets using org.eclipse.core.runtime.IPath.uptoSegment (Showing top 20 results out of 315)

origin: org.eclipse.jdt/org.eclipse.jdt.core

private DirectoryNode getAnnotationBase(DirectoryNode current, IPath annotationBase, int baseDepth, int nextDepth) {
  IPath nextHead = annotationBase.uptoSegment(nextDepth);
  Map<IPath, DirectoryNode> children = current.getChildren(); // create if necessary
  DirectoryNode nextHeadNode = children.get(nextHead);
  if (nextHeadNode == null)
    children.put(nextHead, nextHeadNode = new DirectoryNode(current, nextHead));
  if (baseDepth == nextDepth)
    return nextHeadNode;
  return getAnnotationBase(nextHeadNode, annotationBase, baseDepth, nextDepth+1);
}
origin: org.eclipse.tycho/org.eclipse.jdt.core

private DirectoryNode getAnnotationBase(DirectoryNode current, IPath annotationBase, int baseDepth, int nextDepth) {
  IPath nextHead = annotationBase.uptoSegment(nextDepth);
  Map<IPath, DirectoryNode> children = current.getChildren(); // create if necessary
  DirectoryNode nextHeadNode = children.get(nextHead);
  if (nextHeadNode == null)
    children.put(nextHead, nextHeadNode = new DirectoryNode(current, nextHead));
  if (baseDepth == nextDepth)
    return nextHeadNode;
  return getAnnotationBase(nextHeadNode, annotationBase, baseDepth, nextDepth+1);
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

private DirectoryNode getAnnotationBase(DirectoryNode current, IPath annotationBase, int baseDepth, int nextDepth) {
  IPath nextHead = annotationBase.uptoSegment(nextDepth);
  Map<IPath, DirectoryNode> children = current.getChildren(); // create if necessary
  DirectoryNode nextHeadNode = children.get(nextHead);
  if (nextHeadNode == null)
    children.put(nextHead, nextHeadNode = new DirectoryNode(current, nextHead));
  if (baseDepth == nextDepth)
    return nextHeadNode;
  return getAnnotationBase(nextHeadNode, annotationBase, baseDepth, nextDepth+1);
}
origin: org.eclipse/org.eclipse.jst.server.tomcat.core

/**
 * Replace the current JRE container classpath with the given entry.
 * 
 * @param cp
 * @param entry
 */
public static void replaceJREContainer(List cp, IRuntimeClasspathEntry entry) {
  int size = cp.size();
  for (int i = 0; i < size; i++) {
    IRuntimeClasspathEntry entry2 = (IRuntimeClasspathEntry) cp.get(i);
    if (entry2.getPath().uptoSegment(2).isPrefixOf(entry.getPath())) {
      cp.set(i, entry);
      return;
    }
  }
  
  cp.add(0, entry);
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

/**
 * Initializes this object's children table based on the contents of
 * the specified source file.
 */
protected void initialize() {
  children = new HashMap(1000);
  Enumeration entries = zipFile.entries();
  while (entries.hasMoreElements()) {
    ZipEntry entry = (ZipEntry) entries.nextElement();
    if (!entry.isDirectory()) {
      IPath path = new Path(entry.getName()).addTrailingSeparator();
      int pathSegmentCount = path.segmentCount();
      for (int i = 1; i < pathSegmentCount; i++) {
        createContainer(path.uptoSegment(i));
      }
      createFile(entry);
    }
  }
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

/**
 * Initializes this object's children table based on the contents of the
 * specified source file.
 */
protected void initialize() {
  children = new HashMap(1000);
  children.put(root, new ArrayList());
  Enumeration entries = zipFile.entries();
  while (entries.hasMoreElements()) {
    ZipEntry entry = (ZipEntry) entries.nextElement();
    IPath path = new Path(entry.getName()).addTrailingSeparator();
    if (entry.isDirectory()) {
      createContainer(path);
    } else
    {
      // Ensure the container structure for all levels above this is initialized
      // Once we hit a higher-level container that's already added we need go no further
      int pathSegmentCount = path.segmentCount();
      if (pathSegmentCount > 1) {
        createContainer(path.uptoSegment(pathSegmentCount - 1));
      }
      createFile(entry);
    }
  }
}
origin: org.eclipse.jdt/org.eclipse.jdt.core

/**
 * @see AbstractJavaSearchScope#packageFragmentRoot(String, int, String)
 */
@Override
public IPackageFragmentRoot packageFragmentRoot(String resourcePathString, int jarSeparatorIndex, String jarPath) {
  Map<IPath, RootInfo> rootInfos = JavaModelManager.getDeltaState().roots;
  DeltaProcessor.RootInfo rootInfo = null;
  if (jarPath != null) {
    IPath path = new Path(jarPath);
    rootInfo = rootInfos.get(path);
  } else {
    IPath path = new Path(resourcePathString);
    if (ExternalFoldersManager.isInternalPathForExternalFolder(path)) {
      IResource resource = JavaModel.getWorkspaceTarget(path.uptoSegment(2/*linked folders for external folders are always of size 2*/));
      if (resource != null)
        rootInfo = rootInfos.get(resource.getLocation());
    } else {
      rootInfo = rootInfos.get(path);
      while (rootInfo == null && path.segmentCount() > 0) {
        path = path.removeLastSegments(1);
        rootInfo = rootInfos.get(path);
      }
    }
  }
  if (rootInfo == null)
    return null;
  return rootInfo.getPackageFragmentRoot(null/*no resource hint*/);
}

origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

/**
 * @see AbstractJavaSearchScope#packageFragmentRoot(String, int, String)
 */
public IPackageFragmentRoot packageFragmentRoot(String resourcePathString, int jarSeparatorIndex, String jarPath) {
  HashMap rootInfos = JavaModelManager.getDeltaState().roots;
  DeltaProcessor.RootInfo rootInfo = null;
  if (jarPath != null) {
    IPath path = new Path(jarPath);
    rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path);
  } else {
    IPath path = new Path(resourcePathString);
    if (ExternalFoldersManager.isInternalPathForExternalFolder(path)) {
      IResource resource = JavaModel.getWorkspaceTarget(path.uptoSegment(2/*linked folders for external folders are always of size 2*/));
      if (resource != null)
        rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(resource.getLocation());
    } else {
      rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path);
      while (rootInfo == null && path.segmentCount() > 0) {
        path = path.removeLastSegments(1);
        rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path);
      }
    }
  }
  if (rootInfo == null)
    return null;
  return rootInfo.getPackageFragmentRoot(null/*no resource hint*/);
}

origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

/**
 * @see AbstractJavaSearchScope#packageFragmentRoot(String, int, String)
 */
public IPackageFragmentRoot packageFragmentRoot(String resourcePathString, int jarSeparatorIndex, String jarPath) {
  HashMap rootInfos = JavaModelManager.getDeltaState().roots;
  DeltaProcessor.RootInfo rootInfo = null;
  if (jarPath != null) {
    IPath path = new Path(jarPath);
    rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path);
  } else {
    IPath path = new Path(resourcePathString);
    if (ExternalFoldersManager.isInternalPathForExternalFolder(path)) {
      IResource resource = JavaModel.getWorkspaceTarget(path.uptoSegment(2/*linked folders for external folders are always of size 2*/));
      if (resource != null)
        rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(resource.getLocation());
    } else {
      rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path);
      while (rootInfo == null && path.segmentCount() > 0) {
        path = path.removeLastSegments(1);
        rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path);
      }
    }
  }
  if (rootInfo == null)
    return null;
  return rootInfo.getPackageFragmentRoot(null/*no resource hint*/);
}

origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

private IPath getFolderPath(IPath packPath, IPath relpath) {
  int remainingSegments= packPath.segmentCount() - relpath.segmentCount();
  if (remainingSegments >= 0) {
    IPath common= packPath.removeFirstSegments(remainingSegments);
    if (common.equals(relpath)) {
      return packPath.uptoSegment(remainingSegments);
    }
  }
  return null;
}
origin: trylimits/Eclipse-Postfix-Code-Completion

/**
 * @see AbstractJavaSearchScope#packageFragmentRoot(String, int, String)
 */
public IPackageFragmentRoot packageFragmentRoot(String resourcePathString, int jarSeparatorIndex, String jarPath) {
  HashMap rootInfos = JavaModelManager.getDeltaState().roots;
  DeltaProcessor.RootInfo rootInfo = null;
  if (jarPath != null) {
    IPath path = new Path(jarPath);
    rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path);
  } else {
    IPath path = new Path(resourcePathString);
    if (ExternalFoldersManager.isInternalPathForExternalFolder(path)) {
      IResource resource = JavaModel.getWorkspaceTarget(path.uptoSegment(2/*linked folders for external folders are always of size 2*/));
      if (resource != null)
        rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(resource.getLocation());
    } else {
      rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path);
      while (rootInfo == null && path.segmentCount() > 0) {
        path = path.removeLastSegments(1);
        rootInfo = (DeltaProcessor.RootInfo) rootInfos.get(path);
      }
    }
  }
  if (rootInfo == null)
    return null;
  return rootInfo.getPackageFragmentRoot(null/*no resource hint*/);
}

origin: org.eclipse/org.eclipse.jdt.ui

private IPath getFolderPath(IPath packPath, IPath relpath) {
  int remainingSegments= packPath.segmentCount() - relpath.segmentCount();
  if (remainingSegments >= 0) {
    IPath common= packPath.removeFirstSegments(remainingSegments);
    if (common.equals(relpath)) {
      return packPath.uptoSegment(remainingSegments);
    }
  }
  return null;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

/**
 * Initializes this object's children table based on the contents of the
 * specified source file.
 */
protected void initialize() {
  children = new HashMap(1000);
  children.put(root, new ArrayList());
  Enumeration entries = tarFile.entries();
  while (entries.hasMoreElements()) {
    TarEntry entry = (TarEntry) entries.nextElement();
    IPath path = new Path(entry.getName()).addTrailingSeparator();
    if (entry.getFileType() == TarEntry.DIRECTORY) {
      createContainer(path);
    } else
    {
      // Ensure the container structure for all levels above this is initialized
      // Once we hit a higher-level container that's already added we need go no further
      int pathSegmentCount = path.segmentCount();
      if (pathSegmentCount > 1) {
        createContainer(path.uptoSegment(pathSegmentCount - 1));
      }
      createFile(entry);
    }
  }
}
origin: org.eclipse.jdt/org.eclipse.jdt.ui

private IPath getFolderPath(IPath packPath, IPath relpath) {
  int remainingSegments= packPath.segmentCount() - relpath.segmentCount();
  if (remainingSegments >= 0) {
    IPath common= packPath.removeFirstSegments(remainingSegments);
    if (common.equals(relpath)) {
      return packPath.uptoSegment(remainingSegments);
    }
  }
  return null;
}
origin: org.eclipse.pde/org.eclipse.pde.ui

private IFolder generateJavaSourceFolder(IFolder sourceFolder, IProgressMonitor monitor) throws CoreException {
  Object packageValue = getValue(KEY_PACKAGE_NAME);
  String packageName = packageValue != null ? packageValue.toString() : null;
  if (packageName == null)
    packageName = model.getPluginBase().getId();
  IPath path = new Path(packageName.replace('.', File.separatorChar));
  if (sourceFolder != null)
    path = sourceFolder.getProjectRelativePath().append(path);
  for (int i = 1; i <= path.segmentCount(); i++) {
    IPath subpath = path.uptoSegment(i);
    IFolder subfolder = project.getFolder(subpath);
    if (subfolder.exists() == false)
      subfolder.create(true, true, monitor);
  }
  return project.getFolder(path);
}
origin: org.eclipse.emf/org.eclipse.emf.codegen.ecore

public static boolean ensureProjectExists(String workspacePath, Object object, Object projectType, boolean force, Monitor monitor)
{
 try
 {
  IPath path = new Path(workspacePath);
  if (path.isAbsolute())
  {
   IWorkspace workspace = ResourcesPlugin.getWorkspace();
   IProject project = workspace.getRoot().getProject(path.segment(0));
   if (!project.exists() || force)
   {
    IPath javaSource = path.uptoSegment(1).append("src");
    org.eclipse.emf.codegen.ecore.Generator.createEMFProject
     (javaSource,
      null,
      Collections.<IProject>emptyList(),
      monitor,
      org.eclipse.emf.codegen.ecore.Generator.EMF_PLUGIN_PROJECT_STYLE);
   }
   return workspace.getRoot().getProject(path.segment(0)).exists();
  }
 }
 catch (Exception exception)
 {
  CodeGenEcorePlugin.INSTANCE.log(exception);
 }
 return false;
}
origin: org.eclipse.pde/org.eclipse.pde.ui

private IFolder generateJavaSourceFolder(IFolder sourceFolder, IProgressMonitor monitor) throws CoreException {
  Object packageValue = getValue(KEY_PACKAGE_NAME);
  //
  String packageName = packageValue != null ? packageValue.toString() : null;
  if (packageName == null)
    packageName = fModel.getPluginBase().getId();
  IPath path = new Path(packageName.replace('.', File.separatorChar));
  if (sourceFolder != null)
    path = sourceFolder.getProjectRelativePath().append(path);
  for (int i = 1; i <= path.segmentCount(); i++) {
    IPath subpath = path.uptoSegment(i);
    IFolder subfolder = fProject.getFolder(subpath);
    if (subfolder.exists() == false)
      subfolder.create(true, true, monitor);
  }
  return fProject.getFolder(path);
}
origin: org.eclipse.pde/org.eclipse.pde.ui

@Override
public String getText(Object obj) {
  IClasspathEntry entry = (IClasspathEntry) obj;
  int kind = entry.getEntryKind();
  if (kind == IClasspathEntry.CPE_PROJECT)
    return entry.getPath().segment(0);
  IPath path = entry.getPath();
  String name = path.lastSegment();
  return name + " - " //$NON-NLS-1$
      + path.uptoSegment(path.segmentCount() - 1).toOSString();
}
origin: org.eclipse/org.eclipse.compare

protected IFile createPath(IContainer container, IPath path) throws CoreException {
  if (path.segmentCount() > 1) {
    IContainer childContainer;
    if (container instanceof IWorkspaceRoot) {
      IProject project = ((IWorkspaceRoot)container).getProject(path.segment(0));
      if (!project.exists())
        project.create(null);
      if (!project.isOpen())
        project.open(null);
      childContainer = project;
    } else {
      IFolder f= container.getFolder(path.uptoSegment(1));
      if (!f.exists())
        f.create(false, true, null);
      childContainer = f;
    }
    return createPath(childContainer, path.removeFirstSegments(1));
  }
  // a leaf
  return container.getFile(path);
}

origin: org.eclipse.platform/org.eclipse.compare

protected IFile createPath(IContainer container, IPath path) throws CoreException {
  if (path.segmentCount() > 1) {
    IContainer childContainer;
    if (container instanceof IWorkspaceRoot) {
      IProject project = ((IWorkspaceRoot)container).getProject(path.segment(0));
      if (!project.exists())
        project.create(null);
      if (!project.isOpen())
        project.open(null);
      childContainer = project;
    } else {
      IFolder f= container.getFolder(path.uptoSegment(1));
      if (!f.exists())
        f.create(false, true, null);
      childContainer = f;
    }
    return createPath(childContainer, path.removeFirstSegments(1));
  }
  // a leaf
  return container.getFile(path);
}
org.eclipse.core.runtimeIPathuptoSegment

Javadoc

Returns a copy of this path truncated after the given number of segments. The number must not be negative. The device id is preserved.

If this path has a trailing separator, the result will too (assuming there are some segments left). If there is no trailing separator, the result will not have a trailing separator. Copying up to segment zero simply means making an copy with no path segments.

Popular methods of IPath

  • toString
    Returns a string representation of this path, including its device id. The same separator, "/", is u
  • toFile
    Returns a java.io.File corresponding to this path.
  • toOSString
    Returns a string representation of this path which uses the platform-dependent path separator define
  • append
    Returns the canonicalized path obtained from the concatenation of the given path's segments to the e
  • segmentCount
    Returns the number of segments in this path. Note that both root and empty paths have 0 segments.
  • removeLastSegments
    Returns a copy of this path with the given number of segments removed from the end. The device id is
  • lastSegment
    Returns the last segment of this path, ornull if it does not have any segments.
  • removeFirstSegments
    Returns a copy of this path with the given number of segments removed from the beginning. The device
  • segment
    Returns the specified segment of this path, ornull if the path does not have such a segment.
  • equals
    Returns whether this path equals the given object. Equality for paths is defined to be: same sequenc
  • isAbsolute
    Returns whether this path is an absolute path (ignoring any device id). Absolute paths start with a
  • isPrefixOf
    Returns whether this path is a prefix of the given path. To be a prefix, this path's segments must a
  • isAbsolute,
  • isPrefixOf,
  • toPortableString,
  • makeRelative,
  • makeAbsolute,
  • getDevice,
  • isEmpty,
  • addTrailingSeparator,
  • getFileExtension,
  • setDevice

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • requestLocationUpdates (LocationManager)
  • setRequestProperty (URLConnection)
  • Path (java.nio.file)
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Collectors (java.util.stream)
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now