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

Method resolve_class_in_file

src/definition/resolve.rs:633–652  ·  view source on GitHub ↗

Resolve a class definition in a file on disk. This is the cross-file counterpart of [`find_definition_in_uri_classes_index`]. It ensures the target file is parsed and cached in `uri_classes_index`, then uses the stored `keyword_offset` to produce a precise `Location` without text searching.

(
        &self,
        file_path: &std::path::Path,
        fqn: &str,
    )

Source from the content-addressed store, hash-verified

631 /// uses the stored `keyword_offset` to produce a precise `Location`
632 /// without text searching.
633 pub(super) fn resolve_class_in_file(
634 &self,
635 file_path: &std::path::Path,
636 fqn: &str,
637 ) -> Option<Location> {
638 let target_uri_string = crate::util::path_to_uri(file_path);
639
640 // Ensure the file is parsed and cached. If the file has
641 // already been parsed (opened via `did_open`, loaded from
642 // autoload files, or parsed in a previous cross-file jump),
643 // skip re-parsing.
644 let already_cached = self.parsed_uris.read().contains(&target_uri_string);
645
646 if !already_cached {
647 self.parse_and_cache_file(file_path);
648 }
649
650 // Use AST-based lookup (keyword_offset).
651 self.find_definition_in_uri_classes_index_cross_file(fqn, &target_uri_string)
652 }
653
654 /// Like [`find_definition_in_uri_classes_index`] but for cross-file jumps where
655 /// we know the target file's URI (not the current file).

Callers 2

Calls 4

path_to_uriFunction · 0.85
containsMethod · 0.80
parse_and_cache_fileMethod · 0.80

Tested by

no test coverage detected