@@ -19,14 +19,6 @@ hover_reply <- function(id, uri, workspace, document, point) {
19
19
token_result <- document $ detect_token(point )
20
20
range <- token_result $ range
21
21
22
- if (is.null(token_result $ package )) {
23
- signs <- workspace $ guess_namespace(token_result $ token )
24
- } else {
25
- signs <- token_result $ package
26
- }
27
-
28
- sig <- workspace $ get_signature(token_result $ token , signs ,
29
- exported_only = token_result $ accessor != " :::" )
30
22
contents <- NULL
31
23
resolved <- FALSE
32
24
@@ -48,7 +40,7 @@ hover_reply <- function(id, uri, workspace, document, point) {
48
40
if (token_name %in% c(" SYMBOL" , " SYMBOL_FUNCTION_CALL" )) {
49
41
# symbol
50
42
preceding_dollar <- xml_find_first(token , " preceding-sibling::OP-DOLLAR" )
51
- if (length(preceding_dollar ) == 0 && (is.null( signs ) || signs != WORKSPACE || is.null( sig )) ) {
43
+ if (length(preceding_dollar ) == 0 ) {
52
44
enclosing_scopes <- xdoc_find_enclosing_scopes(xdoc ,
53
45
row , col , top = TRUE )
54
46
xpath <- glue(hover_xpath ,
@@ -205,8 +197,30 @@ hover_reply <- function(id, uri, workspace, document, point) {
205
197
206
198
if (! resolved ) {
207
199
contents <- workspace $ get_help(token_result $ token , token_result $ package )
208
- if (is.null(contents ) && ! is.null(sig )) {
200
+ if (is.null(contents )) {
201
+ def_text <- NULL
202
+
209
203
doc <- workspace $ get_documentation(token_result $ token , token_result $ package )
204
+ signs <- if (is.null(token_result $ package )) {
205
+ workspace $ guess_namespace(token_result $ token )
206
+ } else {
207
+ token_result $ package
208
+ }
209
+ sig <- workspace $ get_signature(token_result $ token , signs ,
210
+ exported_only = token_result $ accessor != " :::" )
211
+
212
+ if (is.null(sig )) {
213
+ def <- workspace $ get_definition(token_result $ token , token_result $ package ,
214
+ exported_only = token_result $ accessor != " :::" )
215
+ if (! is.null(def )) {
216
+ def_doc <- workspace $ documents $ get(def $ uri )
217
+ def_line1 <- def $ range $ start $ line + 1
218
+ def_text <- def_doc $ line(def_line1 )
219
+ }
220
+ } else {
221
+ def_text <- sig
222
+ }
223
+
210
224
doc_string <- NULL
211
225
if (is.character(doc )) {
212
226
doc_string <- doc
@@ -217,7 +231,10 @@ hover_reply <- function(id, uri, workspace, document, point) {
217
231
doc_string <- doc $ markdown
218
232
}
219
233
}
220
- contents <- c(sprintf(" ```r\n %s\n ```" , sig ), doc_string )
234
+ contents <- c(
235
+ if (! is.null(def_text )) sprintf(" ```r\n %s\n ```" , def_text ),
236
+ doc_string
237
+ )
221
238
}
222
239
}
223
240
0 commit comments