-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.script.php
More file actions
executable file
·33 lines (29 loc) · 981 Bytes
/
Copy pathtypes.script.php
File metadata and controls
executable file
·33 lines (29 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
use lang\ClassLoader;
function completionsIn($l, $path) {
$namespace= $path ? $path.'.' : '';
foreach ($l->packageContents($path) as $content) {
$end= strlen($content) - 1;
if ('/' === $content[$end]) {
$package= substr($content, 0, $end);
yield sprintf("1 %s%s\tnamespace>>%s\\", $namespace, $package, strtr($package, '.', '\\'));
} else if (strstr($content, xp::CLASS_FILE_EXT)) {
$type= substr($content, 0, -strlen(xp::CLASS_FILE_EXT));
yield sprintf("2 %s%s\ttype>>%s", $namespace, $type, strtr($type, '.', '\\'));
}
}
}
function completions($path) {
foreach (ClassLoader::getLoaders() as $l) {
if (!$l->providesResource('composer.json')) {
foreach (completionsIn($l, $path) as $completion) {
yield $completion;
}
}
}
}
$completions= iterator_to_array(completions($argv[1]));
sort($completions);
foreach (array_unique($completions) as $completion) {
echo substr($completion, 2), "\n";
}