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

Method resolve_definition

src/definition/resolve.rs:36–63  ·  view source on GitHub ↗

Handle a "go to definition" request. Returns `Some(Location)` when the symbol under the cursor can be resolved to a file and a position inside that file, or `None` when resolution fails at any step.

(
        &self,
        uri: &str,
        content: &str,
        position: Position,
    )

Source from the content-addressed store, hash-verified

34 /// resolved to a file and a position inside that file, or `None` when
35 /// resolution fails at any step.
36 pub(crate) fn resolve_definition(
37 &self,
38 uri: &str,
39 content: &str,
40 position: Position,
41 ) -> Vec<Location> {
42 // Consult precomputed symbol map (retries one byte earlier for
43 // end-of-token edge cases).
44 let symbol = self.lookup_symbol_at_position(uri, content, position);
45 if let Some(ref s) = symbol
46 && let Some(resolved) =
47 self.resolve_from_symbol(&s.kind, uri, content, position, s.start)
48 {
49 return resolved;
50 }
51
52 // Laravel config fallback: declaration sites in config/*.php
53 if let Some(loc) =
54 laravel::resolve_config_key_definition_fallback(self, uri, content, position)
55 {
56 return vec![loc];
57 }
58
59 // env() fallback: not yet indexed in the symbol map.
60 laravel::resolve_env_definition(self, content, position)
61 .into_iter()
62 .collect()
63 }
64
65 /// Look up the symbol at the given byte offset in the precomputed
66 /// symbol map for `uri`.

Callers 2

goto_definitionMethod · 0.80
is_vendor_symbolMethod · 0.80

Calls 5

resolve_env_definitionFunction · 0.85
resolve_from_symbolMethod · 0.80
into_iterMethod · 0.80

Tested by

no test coverage detected