virtualToIoFiles(@NotNull Collection extends VirtualFile> files) {
return ContainerUtil.map2List(files, file -> virtualToIoFile(file));
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
index 5976ddbfe006..02064b36d9a2 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
@@ -128,7 +128,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* ({@link File#separatorChar}) replaced to the forward slash ({@code '/'}).
*
* @return the path
- * @see #toPath()
+ * @see #toNioPath()
*/
@NotNull
public abstract String getPath();
@@ -137,29 +137,19 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @return a related {@link Path} for a given virtual file where possible otherwise an
* exception is thrown.
* The returned {@link Path} may not have a default filesystem behind.
+ *
+ * Use {@link #getFileSystem()} and {@link VirtualFileSystem#getNioPath(VirtualFile)}
+ * to avoid the exception
*
* @throws UnsupportedOperationException if this VirtualFile does not have an associated {@link Path}
- *
- * @see #toPathOrNull()
*/
@NotNull
- public Path toPath() {
- Path path = toPathOrNull();
+ public Path toNioPath() {
+ Path path = getFileSystem().getNioPath(this);
if (path != null) return path;
throw new UnsupportedOperationException("Failed to map " + this + " (filesystem " + getFileSystem() + ") into nio Path");
}
- /**
- * @return a related {@link Path} for a given virtual file where possible otherwise {@code null}.
- * The returned {@link Path} may not have a default filesystem behind.
- *
- * @see #toPath()
- */
- @Nullable
- public Path toPathOrNull() {
- return getFileSystem().getNioPath(this);
- }
-
/**
* Returns the URL of this file. The URL is a string that uniquely identifies a file in all file systems.
* It has the following format: {@code ://}.
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileLookup.kt b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileLookup.kt
index 63e1d2c433f1..77ad86e0ae5a 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileLookup.kt
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileLookup.kt
@@ -34,7 +34,7 @@ interface VirtualFileLookup {
/**
* Searches for a [VirtualFile] corresponding to the given nio [Path].
- * The [VirtualFile.toPath] method should return the same Path back.
+ * The [VirtualFile.toNioPath] method should return the same Path back.
*/
fun fromNioPath(path: Path) : VirtualFile?
diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java
index 168b30485e7b..552e6dff798e 100644
--- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java
@@ -851,7 +851,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
File newDir = tempDir.newDirectory("someDir-32");
VirtualFile newDirFile = myFS.refreshAndFindFileByPath(newDir.getPath());
assertNotNull(newDirFile);
- assertThat(newDirFile.toPath()).isNotNull().isEqualTo(newDir.toPath());
+ assertThat(newDirFile.toNioPath()).isNotNull().isEqualTo(newDir.toPath());
}
@Test
@@ -859,6 +859,6 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
File newDir = tempDir.newFile("someFile-32");
VirtualFile newDirFile = myFS.refreshAndFindFileByPath(newDir.getPath());
assertNotNull(newDirFile);
- assertThat(newDirFile.toPath()).isNotNull().isEqualTo(newDir.toPath());
+ assertThat(newDirFile.toNioPath()).isNotNull().isEqualTo(newDir.toPath());
}
}
\ No newline at end of file