@@ -35,7 +35,6 @@ package final actor DocumentationManager {
35
35
_ documentURI: DocumentURI ,
36
36
at position: Position ? = nil
37
37
) async throws -> DoccDocumentationResponse {
38
- let position = position ?? Position ( line: 0 , utf16index: 0 )
39
38
guard let sourceKitLSPServer = sourceKitLSPServer else {
40
39
throw ResponseError . internalError ( " SourceKit-LSP is shutting down " )
41
40
}
@@ -55,6 +54,9 @@ package final actor DocumentationManager {
55
54
var overridingDocumentationComments = [ String: [ String] ] ( )
56
55
switch snapshot. language {
57
56
case . swift:
57
+ guard let position else {
58
+ throw ResponseError . invalidParams ( " A position must be provided for Swift files " )
59
+ }
58
60
guard let languageService = await sourceKitLSPServer. languageService ( for: documentURI, . swift, in: workspace) ,
59
61
let swiftLanguageService = languageService as? SwiftLanguageService
60
62
else {
@@ -71,17 +73,17 @@ package final actor DocumentationManager {
71
73
return . error( . noDocumentation)
72
74
}
73
75
// Retrieve the symbol graph as well as information about the symbol
74
- let position = await swiftLanguageService. adjustPositionToStartOfIdentifier (
76
+ let symbolPosition = await swiftLanguageService. adjustPositionToStartOfIdentifier (
75
77
snapshot. position ( of: nearestDocumentableSymbol. position) ,
76
78
in: snapshot
77
79
)
78
80
let ( cursorInfo, _, symbolGraph) = try await swiftLanguageService. cursorInfo (
79
81
documentURI,
80
- position ..< position ,
82
+ Range ( symbolPosition ) ,
81
83
includeSymbolGraph: true ,
82
84
fallbackSettingsAfterTimeout: false
83
85
)
84
- guard let symbolGraph = symbolGraph ,
86
+ guard let symbolGraph,
85
87
let cursorInfo = cursorInfo. first,
86
88
let symbolUSR = cursorInfo. symbolInfo. usr
87
89
else {
0 commit comments