Build a workspace scan by self-scanning a Composer project's autoload directories (PSR-4 + classmap + vendor packages). Used by the merged classmap + self-scan pipeline and by the `"self"` / `"full"` indexing strategies. The `project_root` is the directory containing `composer.json` (either the workspace root for single-project, or a subproject root for monorepo). `skip_paths` contains absolute
(
&self,
project_root: &std::path::Path,
vendor_dir: &str,
preloaded_package: Option<&composer::ComposerPackage>,
skip_paths: &HashSet<PathBuf>,
)
| 2056 | /// present in the Composer classmap). Pass an empty set to |
| 2057 | /// scan everything. |
| 2058 | pub(crate) fn build_self_scan_composer( |
| 2059 | &self, |
| 2060 | project_root: &std::path::Path, |
| 2061 | vendor_dir: &str, |
| 2062 | preloaded_package: Option<&composer::ComposerPackage>, |
| 2063 | skip_paths: &HashSet<PathBuf>, |
| 2064 | ) -> WorkspaceScanResult { |
| 2065 | // Use the pre-parsed package when available; only read from disk |
| 2066 | // as a fallback (e.g. monorepo subproject calls). |
| 2067 | let owned_package; |
| 2068 | let package = match preloaded_package { |
| 2069 | Some(p) => p, |
| 2070 | None => { |
| 2071 | owned_package = composer::read_composer_package(project_root); |
| 2072 | match owned_package.as_ref() { |
| 2073 | Some(p) => p, |
| 2074 | None => { |
| 2075 | let skip_dirs = HashSet::new(); |
| 2076 | return classmap_scanner::scan_workspace_fallback_full( |
| 2077 | project_root, |
| 2078 | &skip_dirs, |
| 2079 | ); |
| 2080 | } |
| 2081 | } |
| 2082 | } |
| 2083 | }; |
| 2084 | |
| 2085 | let scan_dirs = composer::extract_scan_dirs(package); |
| 2086 | |
| 2087 | let psr4_dirs: Vec<(String, PathBuf)> = scan_dirs |
| 2088 | .psr4 |
| 2089 | .iter() |
| 2090 | .map(|(prefix, dir)| (prefix.clone(), project_root.join(dir))) |
| 2091 | .collect(); |
| 2092 | |
| 2093 | let classmap_dirs: Vec<PathBuf> = scan_dirs |
| 2094 | .classmap |
| 2095 | .iter() |
| 2096 | .map(|dir| project_root.join(dir)) |
| 2097 | .collect(); |
| 2098 | |
| 2099 | // Scan user source directories (classes only for PSR-4). |
| 2100 | let vendor_dir_paths = vec![project_root.join(vendor_dir)]; |
| 2101 | let classmap = classmap_scanner::scan_psr4_directories_with_skip( |
| 2102 | &psr4_dirs, |
| 2103 | &classmap_dirs, |
| 2104 | &vendor_dir_paths, |
| 2105 | skip_paths, |
| 2106 | ); |
| 2107 | |
| 2108 | // Scan vendor packages from installed.json. |
| 2109 | let vendor_scan = |
| 2110 | classmap_scanner::scan_vendor_packages_with_skip(project_root, vendor_dir, skip_paths); |
| 2111 | |
| 2112 | let mut result = WorkspaceScanResult { |
| 2113 | classmap, |
| 2114 | ..Default::default() |
| 2115 | }; |
no test coverage detected