@@ -23,12 +23,12 @@ use lsp_types::{
23
23
notification:: DidOpenTextDocument ,
24
24
request:: {
25
25
CodeActionRequest , Completion , Formatting , GotoTypeDefinition , HoverRequest ,
26
- WillRenameFiles , WorkspaceSymbolRequest ,
26
+ InlayHintRequest , InlayHintResolveRequest , WillRenameFiles , WorkspaceSymbolRequest ,
27
27
} ,
28
28
CodeActionContext , CodeActionParams , CompletionParams , DidOpenTextDocumentParams ,
29
29
DocumentFormattingParams , FileRename , FormattingOptions , GotoDefinitionParams , HoverParams ,
30
- PartialResultParams , Position , Range , RenameFilesParams , TextDocumentItem ,
31
- TextDocumentPositionParams , WorkDoneProgressParams ,
30
+ InlayHint , InlayHintLabel , InlayHintParams , PartialResultParams , Position , Range ,
31
+ RenameFilesParams , TextDocumentItem , TextDocumentPositionParams , WorkDoneProgressParams ,
32
32
} ;
33
33
use rust_analyzer:: lsp:: ext:: { OnEnter , Runnables , RunnablesParams , UnindexedProject } ;
34
34
use serde_json:: json;
@@ -75,6 +75,48 @@ use std::collections::Spam;
75
75
assert ! ( res. to_string( ) . contains( "HashMap" ) ) ;
76
76
}
77
77
78
+ #[ test]
79
+ fn resolves_inlay_hints ( ) {
80
+ if skip_slow_tests ( ) {
81
+ return ;
82
+ }
83
+
84
+ let server = Project :: with_fixture (
85
+ r#"
86
+ //- /Cargo.toml
87
+ [package]
88
+ name = "foo"
89
+ version = "0.0.0"
90
+
91
+ //- /src/lib.rs
92
+ struct Foo;
93
+ fn f() {
94
+ let x = Foo;
95
+ }
96
+ "# ,
97
+ )
98
+ . server ( )
99
+ . wait_until_workspace_is_loaded ( ) ;
100
+
101
+ let res = server. send_request :: < InlayHintRequest > ( InlayHintParams {
102
+ range : Range :: new ( Position :: new ( 0 , 0 ) , Position :: new ( 3 , 1 ) ) ,
103
+ text_document : server. doc_id ( "src/lib.rs" ) ,
104
+ work_done_progress_params : WorkDoneProgressParams :: default ( ) ,
105
+ } ) ;
106
+ let mut hints = serde_json:: from_value :: < Option < Vec < InlayHint > > > ( res) . unwrap ( ) . unwrap ( ) ;
107
+ let hint = hints. pop ( ) . unwrap ( ) ;
108
+ assert ! ( hint. data. is_some( ) ) ;
109
+ assert ! (
110
+ matches!( & hint. label, InlayHintLabel :: LabelParts ( parts) if parts[ 1 ] . location. is_none( ) )
111
+ ) ;
112
+ let res = server. send_request :: < InlayHintResolveRequest > ( hint) ;
113
+ let hint = serde_json:: from_value :: < InlayHint > ( res) . unwrap ( ) ;
114
+ assert ! ( hint. data. is_none( ) ) ;
115
+ assert ! (
116
+ matches!( & hint. label, InlayHintLabel :: LabelParts ( parts) if parts[ 1 ] . location. is_some( ) )
117
+ ) ;
118
+ }
119
+
78
120
#[ test]
79
121
fn test_runnables_project ( ) {
80
122
if skip_slow_tests ( ) {
0 commit comments