@@ -35,7 +35,6 @@ package final actor DocumentationManager {
3535 _ documentURI: DocumentURI ,
3636 at position: Position ? = nil
3737 ) async throws -> DoccDocumentationResponse {
38- let position = position ?? Position ( line: 0 , utf16index: 0 )
3938 guard let sourceKitLSPServer = sourceKitLSPServer else {
4039 throw ResponseError . internalError ( " SourceKit-LSP is shutting down " )
4140 }
@@ -55,6 +54,9 @@ package final actor DocumentationManager {
5554 var overridingDocumentationComments = [ String: [ String] ] ( )
5655 switch snapshot. language {
5756 case . swift:
57+ guard let position else {
58+ throw ResponseError . invalidParams ( " A position must be provided for Swift files " )
59+ }
5860 guard let languageService = await sourceKitLSPServer. languageService ( for: documentURI, . swift, in: workspace) ,
5961 let swiftLanguageService = languageService as? SwiftLanguageService
6062 else {
@@ -71,17 +73,17 @@ package final actor DocumentationManager {
7173 return . error( . noDocumentation)
7274 }
7375 // Retrieve the symbol graph as well as information about the symbol
74- let position = await swiftLanguageService. adjustPositionToStartOfIdentifier (
76+ let symbolPosition = await swiftLanguageService. adjustPositionToStartOfIdentifier (
7577 snapshot. position ( of: nearestDocumentableSymbol. position) ,
7678 in: snapshot
7779 )
7880 let ( cursorInfo, _, symbolGraph) = try await swiftLanguageService. cursorInfo (
7981 documentURI,
80- position ..< position ,
82+ Range ( symbolPosition ) ,
8183 includeSymbolGraph: true ,
8284 fallbackSettingsAfterTimeout: false
8385 )
84- guard let symbolGraph = symbolGraph ,
86+ guard let symbolGraph,
8587 let cursorInfo = cursorInfo. first,
8688 let symbolUSR = cursorInfo. symbolInfo. usr
8789 else {
0 commit comments