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

Function extract_scan_dirs

src/composer.rs:130–155  ·  view source on GitHub ↗

Extract the PSR-4 and classmap directory lists from a [`ComposerPackage`] for workspace scanning. This keeps mago types private to this module — callers receive plain strings and don't need to depend on `mago_composer`.

(package: &ComposerPackage)

Source from the content-addressed store, hash-verified

128/// This keeps mago types private to this module — callers receive
129/// plain strings and don't need to depend on `mago_composer`.
130pub fn extract_scan_dirs(package: &ComposerPackage) -> ScanDirs {
131 let mut psr4 = Vec::new();
132 let mut classmap = Vec::new();
133
134 if let Some(autoload) = &package.autoload {
135 for (prefix, paths) in &autoload.psr_4 {
136 let normalised = normalise_prefix(prefix);
137 paths.for_each_path(|dir| {
138 psr4.push((normalised.clone(), dir.to_owned()));
139 });
140 }
141 classmap.extend(autoload.classmap.iter().cloned());
142 }
143
144 if let Some(autoload_dev) = &package.autoload_dev {
145 for (prefix, paths) in &autoload_dev.psr_4 {
146 let normalised = normalise_prefix(prefix);
147 paths.for_each_path(|dir| {
148 psr4.push((normalised.clone(), dir.to_owned()));
149 });
150 }
151 classmap.extend(autoload_dev.classmap.iter().cloned());
152 }
153
154 ScanDirs { psr4, classmap }
155}
156
157/// Read the configured vendor directory from a parsed [`ComposerPackage`].
158///

Callers 1

Calls 5

pushMethod · 0.80
cloneMethod · 0.80
extendMethod · 0.80
iterMethod · 0.80
normalise_prefixFunction · 0.70

Tested by

no test coverage detected