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

Function scan_drupal_directories

src/classmap_scanner.rs:757–809  ·  view source on GitHub ↗

Scan Drupal-specific directories for PHP symbols, bypassing `.gitignore`. Drupal projects typically exclude their web root directories (`web/core`, `web/modules/contrib`, etc.) from version control via `.gitignore` because those files are managed by Composer. The normal gitignore-aware walkers would therefore silently skip the most important parts of the codebase. This function walks with gitig

(web_root: &Path)

Source from the content-addressed store, hash-verified

755/// Test directories (`tests/` and `Tests/`) are excluded by name to avoid
756/// indexing duplicate class definitions from unit-test fixtures.
757pub fn scan_drupal_directories(web_root: &Path) -> WorkspaceScanResult {
758 use ignore::WalkBuilder;
759
760 let drupal_dirs = [
761 "core",
762 "modules/contrib",
763 "modules/custom",
764 "themes/contrib",
765 "themes/custom",
766 "profiles",
767 "sites",
768 ];
769
770 let mut php_files: Vec<PathBuf> = Vec::new();
771
772 for rel in &drupal_dirs {
773 let dir = web_root.join(rel);
774 if !dir.exists() {
775 continue;
776 }
777
778 let walker = WalkBuilder::new(&dir)
779 // Gitignore is intentionally disabled — Drupal's .gitignore
780 // excludes web/core and web/modules/contrib which are the
781 // most critical directories to index.
782 .git_ignore(false)
783 .git_global(false)
784 .git_exclude(false)
785 .hidden(true) // still skip .git, .idea, etc.
786 .parents(false)
787 .ignore(false)
788 .filter_entry(|entry| {
789 if entry.file_type().is_some_and(|ft| ft.is_dir()) {
790 let name = entry.file_name().to_str().unwrap_or("");
791 // Exclude test directories (both conventional casings)
792 if name == "tests" || name == "Tests" {
793 return false;
794 }
795 }
796 true
797 })
798 .build();
799
800 for entry in walker.flatten() {
801 let path = entry.path();
802 if path.is_file() && is_drupal_php_file(path) {
803 php_files.push(path.to_path_buf());
804 }
805 }
806 }
807
808 scan_files_parallel_full(&php_files)
809}
810
811/// Return `true` for file extensions that Drupal treats as PHP source.
812fn is_drupal_php_file(path: &Path) -> bool {

Calls 4

is_drupal_php_fileFunction · 0.85
scan_files_parallel_fullFunction · 0.85
buildMethod · 0.80
pushMethod · 0.80