@@ -23,12 +23,12 @@ use lsp_types::{
2323 notification:: DidOpenTextDocument ,
2424 request:: {
2525 CodeActionRequest , Completion , Formatting , GotoTypeDefinition , HoverRequest ,
26- WillRenameFiles , WorkspaceSymbolRequest ,
26+ InlayHintRequest , InlayHintResolveRequest , WillRenameFiles , WorkspaceSymbolRequest ,
2727 } ,
2828 CodeActionContext , CodeActionParams , CompletionParams , DidOpenTextDocumentParams ,
2929 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 ,
3232} ;
3333use rust_analyzer:: lsp:: ext:: { OnEnter , Runnables , RunnablesParams , UnindexedProject } ;
3434use serde_json:: json;
@@ -75,6 +75,48 @@ use std::collections::Spam;
7575 assert ! ( res. to_string( ) . contains( "HashMap" ) ) ;
7676}
7777
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+
78120#[ test]
79121fn test_runnables_project ( ) {
80122 if skip_slow_tests ( ) {
0 commit comments