IJPL-156626 IJent: IjentWslNioFileSystem is not DelegateFileSystem anymore

It makes it easier to refactor later.

GitOrigin-RevId: 113a3f35e4b43548b4b4f29f4d9e854cd72a7f94
This commit is contained in:
Vladimir Lagunov
2024-08-02 10:02:46 +02:00
committed by intellij-monorepo-bot
parent 6c1abc53fd
commit 11d706dddf
2 changed files with 15 additions and 31 deletions

View File

@@ -1,8 +1,8 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.execution.wsl.ijent.nio
import com.intellij.platform.core.nio.fs.DelegatingFileSystem
import java.nio.file.*
import java.nio.file.attribute.UserPrincipalLookupService
/**
* See [IjentWslNioFileSystemProvider].
@@ -11,13 +11,9 @@ internal class IjentWslNioFileSystem(
private val provider: IjentWslNioFileSystemProvider,
private val ijentFs: FileSystem,
private val originalFs: FileSystem,
) : DelegatingFileSystem<IjentWslNioFileSystemProvider>() {
) : FileSystem() {
override fun toString(): String = """${javaClass.simpleName}(ijentId=${provider.ijentId}, wslLocalRoot=${provider.wslLocalRoot})"""
override fun getDelegate(): FileSystem = originalFs
override fun getDelegate(root: String): FileSystem = originalFs
override fun close() {
ijentFs.close()
}
@@ -44,4 +40,16 @@ internal class IjentWslNioFileSystem(
addAll(originalFs.supportedFileAttributeViews())
addAll(ijentFs.supportedFileAttributeViews())
}
override fun getPath(first: String, vararg more: String): Path =
originalFs.getPath(first, *more)
override fun getPathMatcher(syntaxAndPattern: String?): PathMatcher =
originalFs.getPathMatcher(syntaxAndPattern)
override fun getUserPrincipalLookupService(): UserPrincipalLookupService =
originalFs.userPrincipalLookupService
override fun newWatchService(): WatchService =
originalFs.newWatchService()
}

View File

@@ -3,7 +3,6 @@ package com.intellij.execution.wsl.ijent.nio
import com.intellij.openapi.util.io.CaseSensitivityAttribute
import com.intellij.openapi.util.io.FileAttributes
import com.intellij.platform.core.nio.fs.DelegatingFileSystemProvider
import com.intellij.platform.core.nio.fs.RoutingAwareFileSystemProvider
import com.intellij.platform.ijent.*
import com.intellij.platform.ijent.community.impl.nio.IjentNioPath
@@ -37,7 +36,7 @@ internal class IjentWslNioFileSystemProvider(
internal val wslLocalRoot: Path,
private val ijentFsProvider: FileSystemProvider,
internal val originalFsProvider: FileSystemProvider,
) : DelegatingFileSystemProvider<IjentWslNioFileSystemProvider, IjentWslNioFileSystem>(), RoutingAwareFileSystemProvider {
) : FileSystemProvider(), RoutingAwareFileSystemProvider {
init {
require(wslLocalRoot.isAbsolute)
}
@@ -66,29 +65,6 @@ internal class IjentWslNioFileSystemProvider(
override fun getScheme(): String =
originalFsProvider.scheme
override fun wrapDelegateFileSystem(delegateFs: FileSystem): IjentWslNioFileSystem {
val ijentFs =
try {
ijentFsProvider.getFileSystem(ijentId.uri)
}
catch (ignored: FileSystemNotFoundException) {
ijentFsProvider.newFileSystem(ijentId.uri, null)
}
return IjentWslNioFileSystem(this, ijentFs = ijentFs, originalFs = delegateFs)
}
override fun getDelegate(path1: Path?, path2: Path?): FileSystemProvider =
originalFsProvider
// While the original file system implements more methods than the IJent FS, it make sens to keep it the default delegate and
// convert paths in place for the IJent FS.
// Everything may turn upside down later.
override fun toDelegatePath(path: Path?): Path? =
path?.toDefaultPath()
override fun fromDelegatePath(path: Path?): Path? =
path?.toDefaultPath()
override fun newFileSystem(path: Path, env: MutableMap<String, *>?): IjentWslNioFileSystem {
val ijentNioPath = path.toIjentPath()
require(ijentNioPath.toUri() == ijentId.uri) { "${ijentNioPath.toUri()} != ${ijentId.uri}" }