com.intellij.openapi.util.io.FileUtil.isAncestor()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(143)

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

FileUtil.isAncestor介绍

暂无

代码示例

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

public boolean isExcluded(@Nullable String importPath) {
 if (importPath == null) {
  return false;
 }
 for (String excludedPath : myExcludedPackages) {
  if (FileUtil.isAncestor(excludedPath, importPath, false)) return true;
 }
 return false;
}

代码示例来源:origin: KronicDeth/intellij-elixir

private static void assertRelativePaths(File[] baseDirs, Collection<File> files, String[] expected){
  List<String> relativePaths = new ArrayList<String>();
  for (File file: files){
   String path = file.getAbsolutePath();
   for(File baseDir:baseDirs){
    if(baseDir != null && FileUtil.isAncestor(baseDir, file, false)){
     path = FileUtil.getRelativePath(baseDir, file);
     break;
    }
   }
   relativePaths.add(FileUtil.toSystemIndependentName(path));
  }
  UsefulTestCase.assertSameElements(relativePaths, expected);

 }
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

: FileUtil.join(getWorkingDirectory(), myDirectoryPath);
if (!FileUtil.isAncestor(getWorkingDirectory(), directoryPath, false)) {
 throw new RuntimeConfigurationError("Working directory should be ancestor of testing directory");

代码示例来源:origin: Camelcade/Perl5-IDEA

@Override
public String mapPathToRemote(@NotNull String localPathName) {
 File localPath = new File(localPathName);
 if (FileUtil.isAncestor(myLocalProjectPath, localPath, false)) {
  return FileUtil.toSystemIndependentName(
   new File(myRemoteProjectPath, Objects.requireNonNull(FileUtil.getRelativePath(myLocalProjectPath, localPath))).getPath()
  );
 }
 else {
  return localPathName;
 }
}

代码示例来源:origin: AlexanderBartash/hybris-integration-intellij-idea-plugin

private static <P extends JpsElement> void addSourceFolderIfNotIgnored(
  @NotNull final ContentEntry contentEntry,
  @NotNull final File testSrcDir,
  @NotNull final JpsModuleSourceRootType<P> rootType,
  @NotNull P properties,
  @NotNull final List<File> dirsToIgnore
) {
  if (dirsToIgnore.stream().noneMatch(it -> FileUtil.isAncestor(it, testSrcDir, false))) {
    contentEntry.addSourceFolder(
      VfsUtil.pathToUrl(testSrcDir.getAbsolutePath()),
      rootType,
      properties
    );
  }
}

代码示例来源:origin: Camelcade/Perl5-IDEA

@NotNull
 @Override
 public String mapPathToLocal(@NotNull String remotePathName) {
  File remotePath = new File(remotePathName);
  if (FileUtil.isAncestor(myRemoteProjectPath, remotePath, false)) {
   return FileUtil.toSystemDependentName(
    new File(myLocalProjectPath, Objects.requireNonNull(FileUtil.getRelativePath(myRemoteProjectPath, remotePath))).getPath()
   );
  }
  else {
   return remotePathName;
  }
 }
}

代码示例来源:origin: Camelcade/Perl5-IDEA

@Contract("null->null")
@Nullable
public final String getLocalPath(@Nullable String remotePathname) {
 if (remotePathname == null) {
  return null;
 }
 File remotePath = new File(remotePathname);
 File remoteHelpersPath = new File(getHelpersRootPath());
 if (FileUtil.isAncestor(remoteHelpersPath, remotePath, false)) {
  return new File(
   PerlPluginUtil.getPluginHelpersRoot(), Objects.requireNonNull(FileUtil.getRelativePath(remoteHelpersPath, remotePath))).getPath();
 }
 String localPath = doGetLocalPath(remotePathname);
 if (localPath == null) {
  LOG.warn("Unable to map remote to local " + remotePathname + " for " + this);
 }
 return localPath;
}

代码示例来源:origin: Camelcade/Perl5-IDEA

@Nullable
@Override
protected String doGetLocalPath(@NotNull String remotePath) {
 File remoteFile = new File(remotePath);
 if (FileUtil.isAncestor(CONTAINER_ROOT_FILE, remoteFile, false)) {
  return PerlFileUtil.unLinuxisePath('/' + FileUtil.getRelativePath(CONTAINER_ROOT_FILE, remoteFile));
 }
 return FileUtil.toSystemIndependentName(FileUtil.join(getLocalCacheRoot(), remotePath));
}

代码示例来源:origin: Camelcade/Perl5-IDEA

@Contract("null->null")
@Nullable
public final String getRemotePath(@Nullable String localPathName) {
 if (localPathName == null) {
  return null;
 }
 // checking helpers
 File localPathFile = new File(localPathName);
 File localHelpersPath = new File(PerlPluginUtil.getPluginHelpersRoot());
 if (FileUtil.isAncestor(localHelpersPath, localPathFile, false)) {
  return FileUtil.toSystemIndependentName(
   new File(getHelpersRootPath(), Objects.requireNonNull(FileUtil.getRelativePath(localHelpersPath, localPathFile))).getPath());
 }
 // checking local cache if any
 String localCacheRoot = getLocalCacheRoot();
 if (localCacheRoot != null) {
  File localCacheFile = new File(localCacheRoot);
  if (FileUtil.isAncestor(localCacheFile, localPathFile, false)) {
   return FileUtil.toSystemIndependentName("/" + FileUtil.getRelativePath(localCacheFile, localPathFile));
  }
 }
 // mapping with host data
 String remotePath = doGetRemotePath(localPathName);
 if (remotePath == null) {
  LOG.warn("Unable to map local to remote " + localPathName + " for " + this);
 }
 return remotePath;
}

相关文章