speedup static access autocomplete
parent
b7c712842f
commit
6d725a234c
|
@ -233,11 +233,11 @@ class CompletionProvider
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
$duration = microtime(true) - $start;
|
$duration = microtime(true) - $start;
|
||||||
file_put_contents(
|
// file_put_contents(
|
||||||
'/home/nicolas/tmp/php_language-server.log',
|
// '/home/nicolas/tmp/php_language-server.log',
|
||||||
sprintf("%d items found, %d checks, memory : %d bytes, %ss\n", sizeof($list->items), $checksCount, memory_get_usage(true), $duration),
|
// sprintf("%d items found, %d checks, memory : %d bytes, %ss\n", sizeof($list->items), $checksCount, memory_get_usage(true), $duration),
|
||||||
FILE_APPEND
|
// FILE_APPEND
|
||||||
);
|
// );
|
||||||
|
|
||||||
} elseif (
|
} elseif (
|
||||||
($scoped = $node->parent) instanceof Node\Expression\ScopedPropertyAccessExpression ||
|
($scoped = $node->parent) instanceof Node\Expression\ScopedPropertyAccessExpression ||
|
||||||
|
@ -252,26 +252,50 @@ class CompletionProvider
|
||||||
//
|
//
|
||||||
// TODO: $a::|
|
// TODO: $a::|
|
||||||
|
|
||||||
|
$checksCount = 0;
|
||||||
|
$start = microtime(true);
|
||||||
// Resolve all possible types to FQNs
|
// Resolve all possible types to FQNs
|
||||||
$fqns = FqnUtilities\getFqnsFromType(
|
$fqns = FqnUtilities\getFqnsFromType(
|
||||||
$classType = $this->definitionResolver->resolveExpressionNodeToType($scoped->scopeResolutionQualifier)
|
$classType = $this->definitionResolver->resolveExpressionNodeToType($scoped->scopeResolutionQualifier)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Append :: operator to only get static members of all parents
|
// Append :: operator to only get static members of all parents
|
||||||
$prefixes = [];
|
$namespaces = [];
|
||||||
foreach ($this->expandParentFqns($fqns) as $prefix) {
|
foreach ($this->expandParentFqns($fqns) as $namespace) {
|
||||||
$prefixes[] = $prefix . '::';
|
$namespaces[] = $namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect all definitions that match any of the prefixes
|
// Collect all definitions that match any of the prefixes
|
||||||
foreach ($this->index->getDefinitions() as $fqn => $def) {
|
foreach ($namespaces as $namespace) {
|
||||||
foreach ($prefixes as $prefix) {
|
foreach ($this->index->getDefinitionsForNamespace($namespace) as $fqn => $def) {
|
||||||
if (substr(strtolower($fqn), 0, strlen($prefix)) === strtolower($prefix) && $def->isMember) {
|
++$checksCount;
|
||||||
|
$prefix = strtolower($namespace . '::');
|
||||||
|
if (substr(strtolower($fqn), 0, strlen($prefix)) === $prefix && !$def->isMember) {
|
||||||
$list->items[] = CompletionItem::fromDefinition($def);
|
$list->items[] = CompletionItem::fromDefinition($def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $prefixes = [];
|
||||||
|
// foreach ($this->expandParentFqns($fqns) as $prefix) {
|
||||||
|
// $prefixes[] = $prefix . '::';
|
||||||
|
// }
|
||||||
|
|
||||||
|
// foreach ($this->index->getDefinitions() as $fqn => $def) {
|
||||||
|
// foreach ($prefixes as $prefix) {
|
||||||
|
// ++$checksCount;
|
||||||
|
// if (substr(strtolower($fqn), 0, strlen($prefix)) === strtolower($prefix) && !$def->isGlobal) {
|
||||||
|
// $list->items[] = CompletionItem::fromDefinition($def);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
$duration = microtime(true) - $start;
|
||||||
|
file_put_contents(
|
||||||
|
'/home/nicolas/tmp/php_language-server_static.log',
|
||||||
|
sprintf("%d items found, %d checks, memory : %d bytes, %ss\n", sizeof($list->items), $checksCount, memory_get_usage(true), $duration),
|
||||||
|
FILE_APPEND
|
||||||
|
);
|
||||||
|
|
||||||
} elseif (
|
} elseif (
|
||||||
ParserHelpers\isConstantFetch($node)
|
ParserHelpers\isConstantFetch($node)
|
||||||
// Creation gets set in case of an instantiation (`new` expression)
|
// Creation gets set in case of an instantiation (`new` expression)
|
||||||
|
|
Loading…
Reference in New Issue