@@ -12,7 +12,7 @@ definition_xpath <- paste(
1212# ' writes the function definition to a temporary file and returns that
1313# ' as the location.
1414# ' @keywords internal
15- definition_reply <- function (id , uri , workspace , document , point ) {
15+ definition_reply <- function (id , uri , workspace , document , point , rootPath ) {
1616
1717 token_result <- document $ detect_token(point )
1818 resolved <- FALSE
@@ -56,6 +56,29 @@ definition_reply <- function(id, uri, workspace, document, point) {
5656 resolved <- TRUE
5757 }
5858 }
59+ } else if (token_name == " STR_CONST" ) {
60+ str_line1 <- as.integer(xml_attr(token , " line1" ))
61+ str_line2 <- as.integer(xml_attr(token , " line2" ))
62+ if (str_line1 == str_line2 ) {
63+ str_col1 <- as.integer(xml_attr(token , " col1" ))
64+ str_col2 <- as.integer(xml_attr(token , " col2" ))
65+ str_expr <- substr(document $ content [str_line1 ], str_col1 , str_col2 )
66+ str_text <- tryCatch(as.character(parse(text = str_expr , keep.source = FALSE )),
67+ error = function (e ) NULL )
68+ if (is.character(str_text )) {
69+ path <- fs :: path_abs(str_text , rootPath )
70+ if (file.exists(path ) && ! dir.exists(path ) && is_text_file(path )) {
71+ result <- list (
72+ uri = path_to_uri(path ),
73+ range = range(
74+ start = position(0 , 0 ),
75+ end = position(0 , 0 )
76+ )
77+ )
78+ }
79+ }
80+ }
81+ resolved <- TRUE
5982 } else {
6083 resolved <- TRUE
6184 }
0 commit comments