org.eclipse.jdt.internal.core.util.Util.relativePath()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(15.7k)|赞(0)|评价(0)|浏览(190)

本文整理了Java中org.eclipse.jdt.internal.core.util.Util.relativePath()方法的一些代码示例,展示了Util.relativePath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.relativePath()方法的具体详情如下:
包路径:org.eclipse.jdt.internal.core.util.Util
类名称:Util
方法名:relativePath

Util.relativePath介绍

[英]Returns the toString() of the given full path minus the first given number of segments. The returned string is always a relative path (it has no leading slash)
[中]返回给定完整路径的toString()减去第一个给定的段数。返回的字符串始终是相对路径(它没有前导斜杠)

代码示例

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

@Override
  public boolean visit(IResourceProxy proxy) {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
        indexedFileNames.put(containerRelativePath, file);
      }
      return false;
    }
    return true;
  }
}, IResource.NONE);

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
        indexedFileNames.put(containerRelativePath, file);
      }
      return false;
    }
    return true;
  }
}, IResource.NONE);

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
        indexedFileNames.put(containerRelativePath, file);
      }
      return false;
    }
    return true;
  }
}, IResource.NONE);

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
        indexedFileNames.put(containerRelativePath, file);
      }
      return false;
    }
    return true;
  }
}, IResource.NONE);

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
        indexedFileNames.put(containerRelativePath, file);
      }
      return false;
    }
    return true;
  }
}, IResource.NONE);

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

public boolean visit(IResourceProxy proxy) {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
        indexedFileNames.put(containerRelativePath, file);
      }
      return false;
    }
    return true;
  }
}, IResource.NONE);

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, IProgressMonitor progressMonitor) {
  IPackageFragmentRoot root = (IPackageFragmentRoot) this.typeParameter.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
  String documentPath;
  String relativePath;
  if (root.isArchive()) {
     IType type = (IType) this.typeParameter.getAncestor(IJavaElement.TYPE);
    relativePath = (type.getFullyQualifiedName('$')).replace('.', '/') + SuffixConstants.SUFFIX_STRING_class;
    documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
  } else {
    IPath path = this.typeParameter.getPath();
    documentPath = path.toString();
    relativePath = Util.relativePath(path, 1/*remove project segment*/);
  }
  if (scope instanceof JavaSearchScope) {
    JavaSearchScope javaSearchScope = (JavaSearchScope) scope;
    // Get document path access restriction from java search scope
    // Note that requestor has to verify if needed whether the document violates the access restriction or not
    AccessRuleSet access = javaSearchScope.getAccessRuleSet(relativePath, index.containerPath);
    if (access != JavaSearchScope.NOT_ENCLOSED) { // scope encloses the path
      if (!requestor.acceptIndexMatch(documentPath, this, participant, access))
        throw new OperationCanceledException();
    }
  } else if (scope.encloses(documentPath)) {
    if (!requestor.acceptIndexMatch(documentPath, this, participant, null))
      throw new OperationCanceledException();
  }
}

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

public boolean visit(IResourceProxy proxy) {
    if (IndexAllProject.this.isCancelled) return false;
    switch(proxy.getType()) {
      case IResource.FILE :
        if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
          IFile file = (IFile) proxy.requestResource();
          if (exclusionPatterns != null || inclusionPatterns != null)
            if (Util.isExcluded(file, inclusionPatterns, exclusionPatterns))
              return false;
          indexedFileNames.put(Util.relativePath(file.getFullPath(), 1/*remove project segment*/), file);
        }
        return false;
      case IResource.FOLDER :
        if (exclusionPatterns != null && inclusionPatterns == null) {
          // if there are inclusion patterns then we must walk the children
          if (Util.isExcluded(proxy.requestFullPath(), inclusionPatterns, exclusionPatterns, true))
            return false;
        }
        if (hasOutputs && outputs.contains(proxy.requestFullPath()))
          return false;
    }
    return true;
  }
},

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

@Override
  public boolean visit(IResourceProxy proxy) {
    if (IndexAllProject.this.isCancelled) return false;
    switch(proxy.getType()) {
      case IResource.FILE :
        if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
          IFile file = (IFile) proxy.requestResource();
          if (exclusionPatterns != null || inclusionPatterns != null)
            if (Util.isExcluded(file, inclusionPatterns, exclusionPatterns))
              return false;
          indexedFileNames.put(Util.relativePath(file.getFullPath(), 1/*remove project segment*/), file);
        }
        return false;
      case IResource.FOLDER :
        if (exclusionPatterns != null && inclusionPatterns == null) {
          // if there are inclusion patterns then we must walk the children
          if (Util.isExcluded(proxy.requestFullPath(), inclusionPatterns, exclusionPatterns, true))
            return false;
        }
        if (hasOutputs && outputs.contains(proxy.requestFullPath()))
          return false;
    }
    return true;
  }
},

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) {
    if (IndexAllProject.this.isCancelled) return false;
    switch(proxy.getType()) {
      case IResource.FILE :
        if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
          IFile file = (IFile) proxy.requestResource();
          if (exclusionPatterns != null || inclusionPatterns != null)
            if (Util.isExcluded(file, inclusionPatterns, exclusionPatterns))
              return false;
          indexedFileNames.put(Util.relativePath(file.getFullPath(), 1/*remove project segment*/), file);
        }
        return false;
      case IResource.FOLDER :
        if (exclusionPatterns != null && inclusionPatterns == null) {
          // if there are inclusion patterns then we must walk the children
          if (Util.isExcluded(proxy.requestFullPath(), inclusionPatterns, exclusionPatterns, true))
            return false;
        }
        if (hasOutputs && outputs.contains(proxy.requestFullPath()))
          return false;
    }
    return true;
  }
},

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) {
    if (IndexAllProject.this.isCancelled) return false;
    switch(proxy.getType()) {
      case IResource.FILE :
        if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
          IFile file = (IFile) proxy.requestResource();
          if (exclusionPatterns != null || inclusionPatterns != null)
            if (Util.isExcluded(file, inclusionPatterns, exclusionPatterns))
              return false;
          indexedFileNames.put(Util.relativePath(file.getFullPath(), 1/*remove project segment*/), file);
        }
        return false;
      case IResource.FOLDER :
        if (exclusionPatterns != null && inclusionPatterns == null) {
          // if there are inclusion patterns then we must walk the children
          if (Util.isExcluded(proxy.requestFullPath(), inclusionPatterns, exclusionPatterns, true))
            return false;
        }
        if (hasOutputs && outputs.contains(proxy.requestFullPath()))
          return false;
    }
    return true;
  }
},

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) {
    if (IndexAllProject.this.isCancelled) return false;
    switch(proxy.getType()) {
      case IResource.FILE :
        if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
          IFile file = (IFile) proxy.requestResource();
          if (exclusionPatterns != null || inclusionPatterns != null)
            if (Util.isExcluded(file, inclusionPatterns, exclusionPatterns))
              return false;
          indexedFileNames.put(Util.relativePath(file.getFullPath(), 1/*remove project segment*/), file);
        }
        return false;
      case IResource.FOLDER :
        if (exclusionPatterns != null && inclusionPatterns == null) {
          // if there are inclusion patterns then we must walk the children
          if (Util.isExcluded(proxy.requestFullPath(), inclusionPatterns, exclusionPatterns, true))
            return false;
        }
        if (hasOutputs && outputs.contains(proxy.requestFullPath()))
          return false;
    }
    return true;
  }
},

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) {
    if (IndexAllProject.this.isCancelled) return false;
    switch(proxy.getType()) {
      case IResource.FILE :
        if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
          IFile file = (IFile) proxy.requestResource();
          if (exclusionPatterns != null || inclusionPatterns != null)
            if (Util.isExcluded(file, inclusionPatterns, exclusionPatterns))
              return false;
          indexedFileNames.put(Util.relativePath(file.getFullPath(), 1/*remove project segment*/), file);
        }
        return false;
      case IResource.FOLDER :
        if (exclusionPatterns != null && inclusionPatterns == null) {
          // if there are inclusion patterns then we must walk the children
          if (Util.isExcluded(proxy.requestFullPath(), inclusionPatterns, exclusionPatterns, true))
            return false;
        }
        if (hasOutputs && outputs.contains(proxy.requestFullPath()))
          return false;
    }
    return true;
  }
},

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) throws CoreException {
    if (IndexAllProject.this.isCancelled) return false;
    switch(proxy.getType()) {
      case IResource.FILE :
        if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
          IFile file = (IFile) proxy.requestResource();
          URI location = file.getLocationURI();
          if (location == null) return false;
          if (exclusionPatterns != null || inclusionPatterns != null)
            if (Util.isExcluded(file, inclusionPatterns, exclusionPatterns))
              return false;
          String relativePathString = Util.relativePath(file.getFullPath(), 1/*remove project segment*/);
          indexedFileNames.put(relativePathString,
            indexedFileNames.get(relativePathString) == null
                || indexLastModified < EFS.getStore(location).fetchInfo().getLastModified()
              ? (Object) file
              : (Object) OK);
        }
        return false;
      case IResource.FOLDER :
        if (exclusionPatterns != null || inclusionPatterns != null)
          if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns))
            return false;
        if (hasOutputs && outputs.contains(proxy.requestFullPath()))
          return false;
    }
    return true;
  }
},

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) throws CoreException {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        URI location = file.getLocationURI();
        if (location != null) {
          String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
          indexedFileNames.put(containerRelativePath,
            indexedFileNames.get(containerRelativePath) == null
                || indexLastModified <
                EFS.getStore(location).fetchInfo().getLastModified()
              ? (Object) file
              : (Object) OK);
        }
      }
      return false;
    }
    return true;
  }
},

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) throws CoreException {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        URI location = file.getLocationURI();
        if (location != null) {
          String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
          indexedFileNames.put(containerRelativePath,
            indexedFileNames.get(containerRelativePath) == null
                || indexLastModified <
                EFS.getStore(location).fetchInfo().getLastModified()
              ? (Object) file
              : (Object) OK);
        }
      }
      return false;
    }
    return true;
  }
},

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) throws CoreException {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        URI location = file.getLocationURI();
        if (location != null) {
          String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
          indexedFileNames.put(containerRelativePath,
            indexedFileNames.get(containerRelativePath) == null
                || indexLastModified <
                EFS.getStore(location).fetchInfo().getLastModified()
              ? (Object) file
              : (Object) OK);
        }
      }
      return false;
    }
    return true;
  }
},

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

public boolean visit(IResourceProxy proxy) throws CoreException {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        URI location = file.getLocationURI();
        if (location != null) {
          String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
          indexedFileNames.put(containerRelativePath,
            indexedFileNames.get(containerRelativePath) == null
                || indexLastModified <
                EFS.getStore(location).fetchInfo().getLastModified()
              ? (Object) file
              : (Object) OK);
        }
      }
      return false;
    }
    return true;
  }
},

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

@Override
  public boolean visit(IResourceProxy proxy) throws CoreException {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        URI location = file.getLocationURI();
        if (location != null) {
          String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
          indexedFileNames.put(containerRelativePath,
            indexedFileNames.get(containerRelativePath) == null
                || indexLastModified <
                EFS.getStore(location).fetchInfo().getLastModified()
              ? (Object) file
              : (Object) OK);
        }
      }
      return false;
    }
    return true;
  }
},

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

public boolean visit(IResourceProxy proxy) throws CoreException {
    if (IndexBinaryFolder.this.isCancelled) return false;
    if (proxy.getType() == IResource.FILE) {
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
        IFile file = (IFile) proxy.requestResource();
        URI location = file.getLocationURI();
        if (location != null) {
          String containerRelativePath = Util.relativePath(file.getFullPath(), IndexBinaryFolder.this.containerPath.segmentCount());
          indexedFileNames.put(containerRelativePath,
            indexedFileNames.get(containerRelativePath) == null
                || indexLastModified <
                EFS.getStore(location).fetchInfo().getLastModified()
              ? (Object) file
              : (Object) OK);
        }
      }
      return false;
    }
    return true;
  }
},

相关文章

Util类方法