@@ -27,7 +27,7 @@ actor OnDiskDocumentManager: Sendable {
27
27
private weak var sourceKitLSPServer : SourceKitLSPServer ?
28
28
private var openSnapshots : [ DocumentURI : ( snapshot: DocumentSnapshot , patchedCompileCommand: SwiftCompileCommand ? ) ]
29
29
30
- init ( sourceKitLSPServer: SourceKitLSPServer ) {
30
+ fileprivate init ( sourceKitLSPServer: SourceKitLSPServer ) {
31
31
self . sourceKitLSPServer = sourceKitLSPServer
32
32
self . openSnapshots = [ : ]
33
33
}
@@ -38,7 +38,7 @@ actor OnDiskDocumentManager: Sendable {
38
38
///
39
39
/// - Parameter symbolLocation: The location of the symbol to fetch the symbol graph for.
40
40
func fetchSymbolGraph( at symbolLocation: SymbolLocation ) async throws -> String ? {
41
- let ( snapshot, patchedCompileCommand) = try await openDocumentSnapshot ( at : symbolLocation)
41
+ let ( snapshot, patchedCompileCommand) = try await openDocumentSnapshot ( for : symbolLocation. documentUri )
42
42
let swiftLanguageService = try await swiftLanguageService ( for: symbolLocation. documentUri)
43
43
return try await swiftLanguageService. cursorInfo (
44
44
snapshot,
@@ -48,19 +48,6 @@ actor OnDiskDocumentManager: Sendable {
48
48
) . symbolGraph
49
49
}
50
50
51
- /// Open a unique dummy document in sourcekitd that has the contents of the file on disk for uri, but an arbitrary
52
- /// URI which doesn't exist on disk.
53
- ///
54
- /// The document will be retained until ``closeAllDocuments()`` is called. This will avoid parsing the same
55
- /// document multiple times if more than one symbol needs to be looked up.
56
- ///
57
- /// - Parameter symbolLocation: The location of the document that will be opened.
58
- func openDocumentSnapshot(
59
- at symbolLocation: SymbolLocation
60
- ) async throws -> ( snapshot: DocumentSnapshot , patchedCompileCommand: SwiftCompileCommand ? ) {
61
- try await openDocumentSnapshot ( for: symbolLocation. documentUri)
62
- }
63
-
64
51
/// Open a unique dummy document in sourcekitd that has the contents of the file on disk for uri, but an arbitrary
65
52
/// URI which doesn't exist on disk.
66
53
///
@@ -71,16 +58,16 @@ actor OnDiskDocumentManager: Sendable {
71
58
func openDocumentSnapshot(
72
59
for uri: DocumentURI
73
60
) async throws -> ( snapshot: DocumentSnapshot , patchedCompileCommand: SwiftCompileCommand ? ) {
74
- guard let cachedSnapshot = openSnapshots [ uri] else {
75
- let languageService = try await swiftLanguageService ( for: uri)
76
- let snapshot = try await languageService. openSnapshotFromDiskOpenedInSourcekitd (
77
- uri: uri,
78
- fallbackSettingsAfterTimeout: false
79
- )
80
- openSnapshots [ uri] = snapshot
81
- return snapshot
61
+ if let cachedSnapshot = openSnapshots [ uri] {
62
+ return cachedSnapshot
82
63
}
83
- return cachedSnapshot
64
+ let languageService = try await swiftLanguageService ( for: uri)
65
+ let snapshot = try await languageService. openSnapshotFromDiskOpenedInSourcekitd (
66
+ uri: uri,
67
+ fallbackSettingsAfterTimeout: false
68
+ )
69
+ openSnapshots [ uri] = snapshot
70
+ return snapshot
84
71
}
85
72
86
73
/// Closes all document snapshots that were opened by this ``OnDiskDocumentManager``.
0 commit comments