Java Code Examples for com.intellij.openapi.vfs.LocalFileSystem#findFileByPath()

The following examples show how to use com.intellij.openapi.vfs.LocalFileSystem#findFileByPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChangesUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@javax.annotation.Nullable
private static VirtualFile getValidParentUnderReadAction(@Nonnull FilePath filePath) {
  ThrowableComputable<VirtualFile,RuntimeException> action = () -> {
    VirtualFile result = null;
    FilePath parent = filePath;
    LocalFileSystem lfs = LocalFileSystem.getInstance();

    while (result == null && parent != null) {
      result = lfs.findFileByPath(parent.getPath());
      parent = parent.getParentPath();
    }

    return result;
  };
  return AccessRule.read(action);
}
 
Example 2
Source File: IdeDocumentHistoryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public VirtualFile[] getChangedFiles() {
  List<VirtualFile> files = new ArrayList<>();

  final LocalFileSystem lfs = LocalFileSystem.getInstance();
  final List<String> paths = myRecentlyChangedFiles.CHANGED_PATHS;
  for (String path : paths) {
    final VirtualFile file = lfs.findFileByPath(path);
    if (file != null) {
      files.add(file);
    }
  }

  return VfsUtilCore.toVirtualFileArray(files);
}