@@ -10,12 +10,8 @@ import org.jetbrains.bsp.bazel.workspacecontext.WorkspaceContext
10
10
import java.net.URI
11
11
import java.nio.file.Files
12
12
import java.nio.file.Paths
13
- import kotlin.io.path.Path
14
13
import kotlin.io.path.name
15
14
import kotlin.io.path.toPath
16
- import kotlin.io.path.listDirectoryEntries
17
- import kotlin.io.path.isSymbolicLink
18
- import kotlin.io.path.readSymbolicLink
19
15
20
16
class IntelliJProjectTreeViewFix (
21
17
private val bazelPathsResolver : BazelPathsResolver ,
@@ -58,28 +54,14 @@ class IntelliJProjectTreeViewFix(
58
54
59
55
private fun computeSymlinksToExclude (workspaceRoot : URI ): Set <URI > {
60
56
val stableSymlinkNames = setOf (" bazel-out" , " bazel-testlogs" , " bazel-bin" )
61
- val execRoot = Path (bazelInfo.execRoot)
62
- val execRootSymlinkNames = execRoot.name.let { name ->
63
- // newer bazel versions put workspace name as last component of exec root
64
- // still, the symlink to this directory is in form of bazel-<sanitized-workspace-name>
65
- // it seems to not accept '_' as a character, and it is replaced with '-'
66
- //
67
- // In older bazel versions, the exec root directory is named __main__ and I am using
68
- // less efficient heuristic: finding all bazel-* files that are symlinks that point to
69
- // exec root
70
- if (name != " __main__" ) {
71
- setOf (" bazel-" + name.replace(" [^A-Za-z0-9]" .toRegex(), " -" ))
72
- } else {
73
- workspaceRoot.toPath()
74
- .listDirectoryEntries(" bazel-*" )
75
- .filterNot { it.name in stableSymlinkNames }
76
- .filter { it.isSymbolicLink() && it.readSymbolicLink() == execRoot }
77
- .map { it.name }
78
- }
79
- }
80
-
81
- return (stableSymlinkNames + execRootSymlinkNames).map {
82
- workspaceRoot.toPath().resolve(it).toUri()
57
+ val workspaceRootPath = workspaceRoot.toPath()
58
+ val sanitizedWorkspaceRootPath = workspaceRootPath
59
+ .name
60
+ .replace(" [^A-Za-z0-9]" .toRegex(), " -" )
61
+ val workspaceSymlinkNames = setOf (" bazel-$sanitizedWorkspaceRootPath " )
62
+
63
+ return (stableSymlinkNames + workspaceSymlinkNames).map {
64
+ workspaceRootPath.resolve(it).toUri()
83
65
}.toSet()
84
66
}
85
67
0 commit comments