Entry point for `textDocument/references`. Returns all locations where the symbol under the cursor is referenced. When `include_declaration` is true the declaration site itself is included in the results.
(
&self,
uri: &str,
content: &str,
position: Position,
include_declaration: bool,
)
| 45 | /// referenced. When `include_declaration` is true the declaration |
| 46 | /// site itself is included in the results. |
| 47 | pub fn find_references( |
| 48 | &self, |
| 49 | uri: &str, |
| 50 | content: &str, |
| 51 | position: Position, |
| 52 | include_declaration: bool, |
| 53 | ) -> Option<Vec<Location>> { |
| 54 | let start_total = std::time::Instant::now(); |
| 55 | tracing::info!( |
| 56 | "Find References: starting at {} line {} char {}", |
| 57 | uri, |
| 58 | position.line, |
| 59 | position.character |
| 60 | ); |
| 61 | |
| 62 | // Consult the precomputed symbol map for the current file |
| 63 | // (retries one byte earlier for end-of-token edge cases). |
| 64 | let symbol = self.lookup_symbol_at_position(uri, content, position); |
| 65 | |
| 66 | // When the cursor is on a symbol span, dispatch by kind. |
| 67 | if let Some(ref sym) = symbol { |
| 68 | tracing::info!( |
| 69 | "Find References: found symbol kind {:?} at offset {}", |
| 70 | sym.kind, |
| 71 | sym.start |
| 72 | ); |
| 73 | let locations = self.dispatch_symbol_references( |
| 74 | &sym.kind, |
| 75 | uri, |
| 76 | content, |
| 77 | sym.start, |
| 78 | include_declaration, |
| 79 | ); |
| 80 | tracing::info!( |
| 81 | "Find References: total time for {:?}: {:?}", |
| 82 | sym.kind, |
| 83 | start_total.elapsed() |
| 84 | ); |
| 85 | if !locations.is_empty() { |
| 86 | return Some(locations); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | // Fallback for declaration sites in config/*.php |
| 91 | let start_laravel = std::time::Instant::now(); |
| 92 | if let Some(locations) = |
| 93 | laravel::find_config_references(self, uri, content, position, include_declaration) |
| 94 | { |
| 95 | tracing::info!( |
| 96 | "Find References: found Laravel config references in {:?}", |
| 97 | start_laravel.elapsed() |
| 98 | ); |
| 99 | tracing::info!( |
| 100 | "Find References: total time (fallback path): {:?}", |
| 101 | start_total.elapsed() |
| 102 | ); |
| 103 | return Some(locations); |
| 104 | } |