MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / handle_with_position

Method handle_with_position

src/server.rs:1416–1428  ·  view source on GitHub ↗

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>,
    )

Source from the content-addressed store, hash-verified

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).

Callers 11

goto_definitionMethod · 0.80
goto_implementationMethod · 0.80
goto_type_definitionMethod · 0.80
hoverMethod · 0.80
referencesMethod · 0.80
signature_helpMethod · 0.80
document_highlightMethod · 0.80
linked_editing_rangeMethod · 0.80
prepare_renameMethod · 0.80
renameMethod · 0.80

Calls 2

with_file_contentMethod · 0.80
unwrapMethod · 0.45

Tested by

no test coverage detected