@@ -53,6 +53,7 @@ extension SwiftLanguageServer {
5353 /// Must be called on self.queue.
5454 private func _variableTypeInfos(
5555 _ uri: DocumentURI ,
56+ _ range: Range < Position > ? = nil ,
5657 _ completion: @escaping ( Swift . Result < [ VariableTypeInfo ] , VariableTypeInfoError > ) -> Void
5758 ) {
5859 dispatchPrecondition ( condition: . onQueue( queue) )
@@ -67,6 +68,13 @@ extension SwiftLanguageServer {
6768 skreq [ keys. request] = requests. variable_type
6869 skreq [ keys. sourcefile] = snapshot. document. uri. pseudoPath
6970
71+ if let range = range,
72+ let start = snapshot. utf8Offset ( of: range. lowerBound) ,
73+ let end = snapshot. utf8Offset ( of: range. upperBound) {
74+ skreq [ keys. offset] = start
75+ skreq [ keys. length] = end - start
76+ }
77+
7078 // FIXME: SourceKit should probably cache this for us
7179 if let compileCommand = self . commandsByFile [ uri] {
7280 skreq [ keys. compilerargs] = compileCommand. compilerArgs
@@ -107,10 +115,11 @@ extension SwiftLanguageServer {
107115 /// - completion: Completion block to asynchronously receive the VariableTypeInfos, or error.
108116 func variableTypeInfos(
109117 _ uri: DocumentURI ,
118+ _ range: Range < Position > ? = nil ,
110119 _ completion: @escaping ( Swift . Result < [ VariableTypeInfo ] , VariableTypeInfoError > ) -> Void
111120 ) {
112121 queue. async {
113- self . _variableTypeInfos ( uri, completion)
122+ self . _variableTypeInfos ( uri, range , completion)
114123 }
115124 }
116125}
0 commit comments