Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.Path


    JavaElementDelta delta = newJavaElementDelta();
    ICompilationUnit unit = getCompilationUnit();
    IPackageFragment pkg = (IPackageFragment) getParentElement();
    IContainer folder = (IContainer) pkg.getResource();
    worked(1);
    IFile compilationUnitFile = folder.getFile(new Path(fName));
    if (compilationUnitFile.exists()) {
      // update the contents of the existing unit if fForce is true
      if (force) {
        IBuffer buffer = unit.getBuffer();
        if (buffer == null) return;
View Full Code Here


    public OutputFileNameProvider(IProject p) {
      try {
        outputLocation = JavaCore.create(p).getOutputLocation();
      } catch (JavaModelException e) {
        outputLocation = new Path(".");
        AspectJCore.getPlugin().getLog().log(e.getStatus());
      }
    }
View Full Code Here

  } else {
    int length = this.names.length;
    if (length == 0) {
      return root.getResource();
    } else {
      IPath path = new Path(this.names[0]);
      for (int i = 1; i < length; i++)
        path = path.append(this.names[i]);
      return ((IContainer)root.getResource()).getFolder(path);
    }
  }
}
View Full Code Here

      }
      ZipFile zip = null;
      try {
        // this path will be a relative path to the workspace in case the zipfile in the workspace otherwise it will be a path in the
        // local file system
        Path zipFilePath = null;

        monitor.enterWrite(); // ask permission to write
        if (resource != null) {
          URI location = this.resource.getLocationURI();
          if (location == null) return false;
View Full Code Here

        return root.getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME);
      char[] pkgName = CharOperation.subarray(fileName, jarSeparator+1, pkgEnd);
      CharOperation.replace(pkgName, '/', '.');
      return root.getPackageFragment(new String(pkgName));
    } else {
      Path path = new Path(new String(fileName, 0, pkgEnd));
      IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
      IContainer folder = path.segmentCount() == 1 ? workspaceRoot.getProject(path.lastSegment()) : (IContainer) workspaceRoot.getFolder(path);
      IJavaElement element = JavaCore.create(folder);
      if (element == null) return null;
      switch (element.getElementType()) {
        case IJavaElement.PACKAGE_FRAGMENT:
          return (IPackageFragment) element;
View Full Code Here

    // Create a new Parser
    SourceIndexerRequestor requestor = new SourceIndexerRequestor(this);
    String documentPath = this.document.getPath();
    SourceElementParser parser = ((InternalSearchDocument) this.document).parser;
    if (parser == null) {
      IPath path = new Path(documentPath);
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
      parser = JavaModelManager.getJavaModelManager().indexManager.getSourceElementParser(JavaCore.create(project), requestor);
    } else {
      parser.requestor = requestor;
    }
   
View Full Code Here

        this.lastPkgFragmentRoot= root;
        this.packageHandles= new HashtableOfArrayToObject(5);
      }
      // create handle
      String classFilePath= resourcePath.substring(separatorIndex + 1);
      String[] simpleNames = new Path(classFilePath).segments();
      String[] pkgName;
      int length = simpleNames.length-1;
      if (length > 0) {
        pkgName = new String[length];
        System.arraycopy(simpleNames, 0, pkgName, 0, length);
      } else {
        pkgName = CharOperation.NO_STRINGS;
      }
      IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName);
      if (pkgFragment == null) {
        pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName);
        this.packageHandles.put(pkgName, pkgFragment);
      }
      IClassFile classFile= pkgFragment.getClassFile(simpleNames[length]);
      return (Openable) classFile;
    } else {
      // path to a file in a directory
      // Optimization: cache package fragment root handle and package handles
      int rootPathLength = -1;
      if (this.lastPkgFragmentRootPath == null
        || !(resourcePath.startsWith(this.lastPkgFragmentRootPath)
          && (rootPathLength = this.lastPkgFragmentRootPath.length()) > 0
          && resourcePath.charAt(rootPathLength) == '/')) {
        IPackageFragmentRoot root= this.getPkgFragmentRoot(resourcePath);
        if (root == null)
          return null; // match is outside classpath
        this.lastPkgFragmentRoot = root;
        this.lastPkgFragmentRootPath = this.lastPkgFragmentRoot.getPath().toString();
        this.packageHandles = new HashtableOfArrayToObject(5);
      }
      // create handle
      resourcePath = resourcePath.substring(this.lastPkgFragmentRootPath.length() + 1);
      String[] simpleNames = new Path(resourcePath).segments();
      String[] pkgName;
      int length = simpleNames.length-1;
      if (length > 0) {
        pkgName = new String[length];
        System.arraycopy(simpleNames, 0, pkgName, 0, length);
View Full Code Here

   * See createOpenable(...) for the format of the jar path string.
   * If not null, uses the given scope as a hint for getting Java project handles.
   */
  private IPackageFragmentRoot getJarPkgFragmentRoot(String jarPathString, IJavaSearchScope scope) {

    IPath jarPath= new Path(jarPathString);
   
    Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), jarPath, false);
    if (target instanceof IFile) {
      // internal jar: is it on the classpath of its project?
      //  e.g. org.eclipse.swt.win32/ws/win32/swt.jar
View Full Code Here

  /**
   * Returns the package fragment root that contains the given resource path.
   */
  private IPackageFragmentRoot getPkgFragmentRoot(String pathString) {

    IPath path= new Path(pathString);
    IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i= 0, max= projects.length; i < max; i++) {
      try {
        IProject project = projects[i];
        if (!project.isAccessible()
View Full Code Here

      if (subFolder == null) {
        // create deepest folder only if not a move (folder will be moved in processPackageFragmentResource)
        if (!(moveFolder && i == newFragName.length-1)) {
          createFolder(parentFolder, subFolderName, force);
        }
        parentFolder = parentFolder.getFolder(new Path(subFolderName));
        sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
        if (Util.isReadOnly(sourceFolder)) {
          containsReadOnlyPackageFragment = true;
        }
        IPackageFragment sideEffectPackage = root.getPackageFragment(sideEffectPackageName);
        if (i < newFragName.length - 1 // all but the last one are side effect packages
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.