Position-based handler helper. Extracts the URI and position from the params, fetches file content, runs the closure inside a panic guard, and flattens the nested `Option`. Covers the majority of LSP handlers that take a `TextDocumentPositionParams` and return `Option `.
(
&self,
handler_name: &str,
uri: &str,
position: Position,
f: impl FnOnce(&str, Position) -> Option<T>,
)
| 1414 | /// Covers the majority of LSP handlers that take a |
| 1415 | /// `TextDocumentPositionParams` and return `Option<T>`. |
| 1416 | fn handle_with_position<T>( |
| 1417 | &self, |
| 1418 | handler_name: &str, |
| 1419 | uri: &str, |
| 1420 | position: Position, |
| 1421 | f: impl FnOnce(&str, Position) -> Option<T>, |
| 1422 | ) -> Result<Option<T>> { |
| 1423 | Ok(self |
| 1424 | .with_file_content(handler_name, uri, Some(position), |content, pos| { |
| 1425 | f(content, pos.unwrap()) |
| 1426 | }) |
| 1427 | .flatten()) |
| 1428 | } |
| 1429 | |
| 1430 | /// URI-only handler helper. Like [`handle_with_position`] but for |
| 1431 | /// handlers that only need the document URI (no cursor position). |
no test coverage detected