Helper: open a file and request inlay hints for the entire file.
(backend: &phpantom_lsp::Backend, uri: &Url, text: &str)
| 6 | |
| 7 | /// Helper: open a file and request inlay hints for the entire file. |
| 8 | async fn inlay_hints_for(backend: &phpantom_lsp::Backend, uri: &Url, text: &str) -> Vec<InlayHint> { |
| 9 | let open_params = DidOpenTextDocumentParams { |
| 10 | text_document: TextDocumentItem { |
| 11 | uri: uri.clone(), |
| 12 | language_id: "php".to_string(), |
| 13 | version: 1, |
| 14 | text: text.to_string(), |
| 15 | }, |
| 16 | }; |
| 17 | backend.did_open(open_params).await; |
| 18 | |
| 19 | let line_count = text.lines().count() as u32; |
| 20 | let last_line_len = text.lines().last().map(|l| l.len() as u32).unwrap_or(0); |
| 21 | |
| 22 | let range = Range { |
| 23 | start: Position { |
| 24 | line: 0, |
| 25 | character: 0, |
| 26 | }, |
| 27 | end: Position { |
| 28 | line: line_count, |
| 29 | character: last_line_len, |
| 30 | }, |
| 31 | }; |
| 32 | |
| 33 | backend |
| 34 | .handle_inlay_hints(uri.as_ref(), text, range) |
| 35 | .unwrap_or_default() |
| 36 | } |
| 37 | |
| 38 | /// Extract the label string from an InlayHint. |
| 39 | fn hint_label(hint: &InlayHint) -> String { |
no test coverage detected