@@ -78,14 +78,13 @@ pub fn goto_definition<'a>(
78
78
79
79
#[ cfg( test) ]
80
80
mod tests {
81
- use std:: path:: PathBuf ;
82
-
83
81
use assert_matches:: assert_matches;
84
82
use tower_lsp:: lsp_types;
85
83
86
84
use super :: * ;
87
85
use crate :: lsp:: documents:: Document ;
88
86
use crate :: lsp:: indexer;
87
+ use crate :: lsp:: util:: test_path;
89
88
90
89
#[ test]
91
90
fn test_goto_definition ( ) {
@@ -96,15 +95,13 @@ foo <- 42
96
95
print(foo)
97
96
"# ;
98
97
let doc = Document :: new ( code, None ) ;
99
- let path = PathBuf :: from ( "/foo/test.R" ) ;
98
+ let ( path, uri ) = test_path ( ) ;
100
99
101
100
indexer:: update ( & doc, & path) . unwrap ( ) ;
102
101
103
102
let params = GotoDefinitionParams {
104
103
text_document_position_params : lsp_types:: TextDocumentPositionParams {
105
- text_document : lsp_types:: TextDocumentIdentifier {
106
- uri : Url :: from_file_path ( & path) . unwrap ( ) ,
107
- } ,
104
+ text_document : lsp_types:: TextDocumentIdentifier { uri } ,
108
105
position : lsp_types:: Position :: new ( 2 , 7 ) ,
109
106
} ,
110
107
work_done_progress_params : Default :: default ( ) ,
@@ -114,9 +111,6 @@ print(foo)
114
111
assert_matches ! (
115
112
goto_definition( & doc, params) . unwrap( ) ,
116
113
Some ( GotoDefinitionResponse :: Link ( ref links) ) => {
117
- assert!( !links. is_empty( ) ) ;
118
- assert_eq!( links[ 0 ] . target_uri, Url :: from_file_path( & path) . unwrap( ) ) ;
119
-
120
114
assert_eq!(
121
115
links[ 0 ] . target_range,
122
116
lsp_types:: Range {
@@ -138,14 +132,13 @@ foo <- 1
138
132
print(foo)
139
133
"# ;
140
134
let doc = Document :: new ( code, None ) ;
141
- let path = PathBuf :: from ( "/foo/section_test.R" ) ;
135
+ let ( path, uri) = test_path ( ) ;
136
+
142
137
indexer:: update ( & doc, & path) . unwrap ( ) ;
143
138
144
139
let params = lsp_types:: GotoDefinitionParams {
145
140
text_document_position_params : lsp_types:: TextDocumentPositionParams {
146
- text_document : lsp_types:: TextDocumentIdentifier {
147
- uri : lsp_types:: Url :: from_file_path ( & path) . unwrap ( ) ,
148
- } ,
141
+ text_document : lsp_types:: TextDocumentIdentifier { uri } ,
149
142
position : lsp_types:: Position :: new ( 3 , 7 ) ,
150
143
} ,
151
144
work_done_progress_params : Default :: default ( ) ,
@@ -155,14 +148,6 @@ print(foo)
155
148
assert_matches ! (
156
149
goto_definition( & doc, params) . unwrap( ) ,
157
150
Some ( lsp_types:: GotoDefinitionResponse :: Link ( ref links) ) => {
158
- assert!( !links. is_empty( ) ) ;
159
-
160
- let link = & links[ 0 ] ;
161
- assert_eq!(
162
- link. target_uri,
163
- lsp_types:: Url :: from_file_path( & path) . unwrap( )
164
- ) ;
165
-
166
151
// The section should is not the target, the variable has priority
167
152
assert_eq!(
168
153
links[ 0 ] . target_range,
0 commit comments