Use URL in many cases where we used AbsolutePath

We made quite a few fixes recently to make sure that path handling works correctly using `URL` on Windows. Use `URL` in most places to have a single type that represents file paths instead of sometimes using `AbsolutePath`.

While doing so, also remove usages of `TSCBasic.FileSystem` an `InMemoryFileSystem`. The pattern of using `InMemoryFileSystem` for tests was never consistently used and it was a little confusing that some types took a `FileSystem` parameter while other always assumed to work on the local file system.
This commit is contained in:
Alex Hoppen
2024-11-18 13:10:01 -08:00
parent bce09932ed
commit be546308ca
52 changed files with 1211 additions and 1097 deletions

View File

@@ -10,6 +10,8 @@
//
//===----------------------------------------------------------------------===//
import Foundation
#if compiler(>=6)
package import LanguageServerProtocol
import SKLogging
@@ -43,25 +45,21 @@ package func determineBuildSystem(
buildSystemPreference.removeAll(where: { $0 == defaultBuildSystem })
buildSystemPreference.insert(defaultBuildSystem, at: 0)
}
guard let workspaceFolderUrl = workspaceFolder.fileURL,
let workspaceFolderPath = try? AbsolutePath(validating: workspaceFolderUrl.filePath)
else {
guard let workspaceFolderUrl = workspaceFolder.fileURL else {
return nil
}
for buildSystemType in buildSystemPreference {
switch buildSystemType {
case .buildServer:
if let projectRoot = ExternalBuildSystemAdapter.projectRoot(for: workspaceFolderPath, options: options) {
if let projectRoot = ExternalBuildSystemAdapter.projectRoot(for: workspaceFolderUrl, options: options) {
return BuildSystemSpec(kind: .buildServer, projectRoot: projectRoot)
}
case .compilationDatabase:
if let projectRoot = CompilationDatabaseBuildSystem.projectRoot(for: workspaceFolderPath, options: options) {
if let projectRoot = CompilationDatabaseBuildSystem.projectRoot(for: workspaceFolderUrl, options: options) {
return BuildSystemSpec(kind: .compilationDatabase, projectRoot: projectRoot)
}
case .swiftPM:
if let projectRootURL = SwiftPMBuildSystem.projectRoot(for: workspaceFolderUrl, options: options),
let projectRoot = try? AbsolutePath(validating: projectRootURL.filePath)
{
if let projectRoot = SwiftPMBuildSystem.projectRoot(for: workspaceFolderUrl, options: options) {
return BuildSystemSpec(kind: .swiftPM, projectRoot: projectRoot)
}
}