diff --git a/scripts/lib/PhutilLibraryMapBuilder.php b/scripts/lib/PhutilLibraryMapBuilder.php index dace26a3..88a73946 100755 --- a/scripts/lib/PhutilLibraryMapBuilder.php +++ b/scripts/lib/PhutilLibraryMapBuilder.php @@ -21,7 +21,7 @@ final class PhutilLibraryMapBuilder { const LIBRARY_MAP_VERSION = 2; const SYMBOL_CACHE_VERSION_KEY = '__symbol_cache_version__'; - const SYMBOL_CACHE_VERSION = 10; + const SYMBOL_CACHE_VERSION = 11; /* -( Mapping libphutil Libraries )---------------------------------------- */ diff --git a/scripts/phutil_symbols.php b/scripts/phutil_symbols.php index 72f0b53b..8a7fbeed 100755 --- a/scripts/phutil_symbols.php +++ b/scripts/phutil_symbols.php @@ -225,11 +225,12 @@ foreach ($classes as $class) { // - Static property access // - Use of class constant // - typehints +// - catch +// - instanceof +// - newv() // // TODO: Possibly support these: // -// - instanceof -// - catch // - String literal in ReflectionClass(). @@ -289,6 +290,54 @@ foreach ($parameters as $parameter) { ); } +// This is "catch (Exception $ex)". +$catches = $root->selectDescendantsOfType('n_CATCH'); +foreach ($catches as $catch) { + $need[] = array( + 'type' => 'class/interface', + 'symbol' => $catch->getChildOfType(0, 'n_CLASS_NAME'), + ); +} + +// This is "$x instanceof X". +$instanceofs = $root->selectDescendantsOfType('n_BINARY_EXPRESSION'); +foreach ($instanceofs as $instanceof) { + $operator = $instanceof->getChildOfType(1, 'n_OPERATOR'); + if ($operator->getConcreteString() != 'instanceof') { + continue; + } + $class = $instanceof->getChildByIndex(2); + if ($class->getTypeName() != 'n_CLASS_NAME') { + continue; + } + $need[] = array( + 'type' => 'class/interface', + 'symbol' => $class, + ); +} + +// This is "newv('X')". +$calls = $root->selectDescendantsOfType('n_FUNCTION_CALL'); +foreach ($calls as $call) { + $call_name = $call->getChildByIndex(0)->getConcreteString(); + if ($call_name != 'newv') { + continue; + } + $params = $call->getChildByIndex(1)->getChildren(); + if (!count($params)) { + continue; + } + $symbol = reset($params); + $symbol_value = $symbol->getStringLiteralValue(); + if ($symbol_value && strpos($symbol_value, '$') === false) { + $need[] = array( + 'type' => 'class', + 'name' => $symbol_value, + 'symbol' => $symbol, + ); + } +} + // -( Interfaces )------------------------------------------------------------