diff --git a/swift-pterodactyl/Sources/PterodactylLanguageServer/PterodactylServerActor.swift b/swift-pterodactyl/Sources/PterodactylLanguageServer/PterodactylServerActor.swift index 46cf397..29a31cd 100644 --- a/swift-pterodactyl/Sources/PterodactylLanguageServer/PterodactylServerActor.swift +++ b/swift-pterodactyl/Sources/PterodactylLanguageServer/PterodactylServerActor.swift @@ -33,7 +33,7 @@ actor PterodactylServerActor { func initialize(rootUri: DocumentUri?) async { Logger.shared.info("Workspace root URI: \(rootUri ?? "")") guard let rootUri else { return } - let rootPath = URL(filePath: rootUri, directoryHint: .isDirectory) + let rootPath = URL(string: rootUri)! self.workspace = try? Workspace(url: rootPath) } @@ -53,7 +53,7 @@ actor PterodactylServerActor { var sourceTree = workspace.sourceTree for (bufferUri, stored) in storedBlobs { - let bufferUrl = URL(fileURLWithPath: bufferUri) + let bufferUrl = URL(string: bufferUri)! sourceTree[bufferUrl] = stored.contents } @@ -103,7 +103,7 @@ actor PterodactylServerActor { savedFeedbacks[uri, default: FeedbackState()].parserFeedbacks = parseFeedbacks try await publishSavedDiagnostics(uri: uri, lineMap: lineMap, version: version) - let url = URL(fileURLWithPath: uri) + let url = URL(string: uri)! guard let sourceTree = try await overlayedSourceTree() else { return } let elabFeedbacks = try await queryEngine.elaborateUnitInSourceTree(sourceTree: sourceTree, url: url).feedbacks @@ -149,7 +149,7 @@ actor PterodactylServerActor { func publishAssistantHtml(uri: DocumentUri) async throws { guard let sourceTree = try await overlayedSourceTree() else { return } - let url = URL(fileURLWithPath: uri) + let url = URL(string: uri)! let htmlContent = try await queryEngine.assistantHtmlContentOfUnit(sourceTree: sourceTree, url: url) Logger.shared.info("Will publish assistant HTML: \(htmlContent)") diff --git a/swift-pterodactyl/Tests/PterodactylBuildTests/Test.swift b/swift-pterodactyl/Tests/PterodactylBuildTests/Test.swift index 4bc753f..aa97c4c 100644 --- a/swift-pterodactyl/Tests/PterodactylBuildTests/Test.swift +++ b/swift-pterodactyl/Tests/PterodactylBuildTests/Test.swift @@ -64,9 +64,9 @@ struct BuildTests { func testImports() async throws { let tree = SourceTree(files: [ - URL(filePath: "src/bar.ext")!: "hello world", - URL(filePath: "src/foo.ext")!: "import bar", - URL(filePath: "src/baz.ext")!: "import foo" + URL(string: "src/bar.ext")!: "hello world", + URL(string: "src/foo.ext")!: "import bar", + URL(string: "src/baz.ext")!: "import foo" ]) let dependencyGraph = await engine.getDependencyGraph(sourceTree: tree)