From 18f2f4c85c02edb9d2d5fd89642c53ef8e442959 Mon Sep 17 00:00:00 2001 From: Nicolas MURE Date: Sun, 6 Aug 2017 18:12:32 +0200 Subject: [PATCH] cleanup --- src/CompletionProvider.php | 55 +++++--------------------------------- 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/src/CompletionProvider.php b/src/CompletionProvider.php index 07602e4..4e313ad 100644 --- a/src/CompletionProvider.php +++ b/src/CompletionProvider.php @@ -201,18 +201,16 @@ class CompletionProvider $this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression) ); - $checksCount = 0; - $start = microtime(true); - // Add the object access operator to only get members of all parents + // The namespaces of the symbol and its parents (eg the implemented interfaces) $namespaces = []; foreach ($this->expandParentFqns($fqns) as $namespace) { $namespaces[] = $namespace; } - // Collect all definitions that match any of the prefixes + // Collect namespaces definitions foreach ($namespaces as $namespace) { foreach ($this->index->getDefinitionsForNamespace($namespace) as $fqn => $def) { - ++$checksCount; + // Add the object access operator to only get members of all parents $prefix = $namespace . '->'; if (substr($fqn, 0, strlen($prefix)) === $prefix && !$def->isMember) { $list->items[] = CompletionItem::fromDefinition($def); @@ -220,25 +218,6 @@ class CompletionProvider } } - // $prefixes = []; - // foreach ($this->expandParentFqns($fqns) as $prefix) { - // $prefixes[] = $prefix . '->'; - // } - // foreach ($this->index->getDefinitions() as $fqn => $def) { - // foreach ($prefixes as $prefix) { - // ++$checksCount; - // if (substr($fqn, 0, strlen($prefix)) === $prefix && !$def->isGlobal) { - // $list->items[] = CompletionItem::fromDefinition($def); - // } - // } - // } - $duration = microtime(true) - $start; - // file_put_contents( - // '/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), - // FILE_APPEND - // ); - } elseif ( ($scoped = $node->parent) instanceof Node\Expression\ScopedPropertyAccessExpression || ($scoped = $node) instanceof Node\Expression\ScopedPropertyAccessExpression @@ -252,23 +231,21 @@ class CompletionProvider // // TODO: $a::| - $checksCount = 0; - $start = microtime(true); // Resolve all possible types to FQNs $fqns = FqnUtilities\getFqnsFromType( $classType = $this->definitionResolver->resolveExpressionNodeToType($scoped->scopeResolutionQualifier) ); - // Append :: operator to only get static members of all parents + // The namespaces of the symbol and its parents (eg the implemented interfaces) $namespaces = []; foreach ($this->expandParentFqns($fqns) as $namespace) { $namespaces[] = $namespace; } - // Collect all definitions that match any of the prefixes + // Collect namespaces definitions foreach ($namespaces as $namespace) { foreach ($this->index->getDefinitionsForNamespace($namespace) as $fqn => $def) { - ++$checksCount; + // Append :: operator to only get static members of all parents $prefix = strtolower($namespace . '::'); if (substr(strtolower($fqn), 0, strlen($prefix)) === $prefix && !$def->isMember) { $list->items[] = CompletionItem::fromDefinition($def); @@ -276,26 +253,6 @@ class CompletionProvider } } - // $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 ( ParserHelpers\isConstantFetch($node) // Creation gets set in case of an instantiation (`new` expression)