Helper: open a file and request completion at the given line/character. Returns `None` when the server returns `Ok(None)` (i.e. no completions at all), and `Some(items)` otherwise.
(
backend: &phpantom_lsp::Backend,
uri: &Url,
text: &str,
line: u32,
character: u32,
)
| 14 | /// Returns `None` when the server returns `Ok(None)` (i.e. no completions |
| 15 | /// at all), and `Some(items)` otherwise. |
| 16 | async fn complete_at_raw( |
| 17 | backend: &phpantom_lsp::Backend, |
| 18 | uri: &Url, |
| 19 | text: &str, |
| 20 | line: u32, |
| 21 | character: u32, |
| 22 | ) -> Option<Vec<CompletionItem>> { |
| 23 | let open_params = DidOpenTextDocumentParams { |
| 24 | text_document: TextDocumentItem { |
| 25 | uri: uri.clone(), |
| 26 | language_id: "php".to_string(), |
| 27 | version: 1, |
| 28 | text: text.to_string(), |
| 29 | }, |
| 30 | }; |
| 31 | backend.did_open(open_params).await; |
| 32 | |
| 33 | let completion_params = CompletionParams { |
| 34 | text_document_position: TextDocumentPositionParams { |
| 35 | text_document: TextDocumentIdentifier { uri: uri.clone() }, |
| 36 | position: Position { line, character }, |
| 37 | }, |
| 38 | work_done_progress_params: WorkDoneProgressParams::default(), |
| 39 | partial_result_params: PartialResultParams::default(), |
| 40 | context: None, |
| 41 | }; |
| 42 | |
| 43 | match backend.completion(completion_params).await.unwrap() { |
| 44 | Some(CompletionResponse::Array(items)) => Some(items), |
| 45 | Some(CompletionResponse::List(list)) => Some(list.items), |
| 46 | None => None, |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | // ═══════════════════════════════════════════════════════════════════════════ |
| 51 | // Single-quoted strings — always suppress |
no test coverage detected