1
0
Fork 0

Make FqnUtilities a module of functions, not a static class

pull/357/head
Rob Lourens 2017-06-07 16:44:14 -07:00
parent 0a15afc130
commit cfc8cc7815
4 changed files with 28 additions and 28 deletions

View File

@ -53,7 +53,8 @@
"LanguageServer\\": "src/" "LanguageServer\\": "src/"
}, },
"files" : [ "files" : [
"src/utils.php" "src/utils.php",
"src/FqnUtilities.php"
] ]
}, },
"autoload-dev": { "autoload-dev": {

View File

@ -179,7 +179,7 @@ class CompletionProvider
$a->c# $a->c#
$a-># */ $a-># */
elseif ($node instanceof Node\Expression\MemberAccessExpression) { elseif ($node instanceof Node\Expression\MemberAccessExpression) {
$prefixes = FqnUtilities::getFqnsFromType( $prefixes = FqnUtilities\getFqnsFromType(
$this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression) $this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression)
); );
$prefixes = $this->expandParentFqns($prefixes); $prefixes = $this->expandParentFqns($prefixes);
@ -209,7 +209,7 @@ class CompletionProvider
($scoped = $node->parent) instanceof Node\Expression\ScopedPropertyAccessExpression || ($scoped = $node->parent) instanceof Node\Expression\ScopedPropertyAccessExpression ||
($scoped = $node) instanceof Node\Expression\ScopedPropertyAccessExpression ($scoped = $node) instanceof Node\Expression\ScopedPropertyAccessExpression
) { ) {
$prefixes = FqnUtilities::getFqnsFromType( $prefixes = FqnUtilities\getFqnsFromType(
$classType = $this->definitionResolver->resolveExpressionNodeToType($scoped->scopeResolutionQualifier) $classType = $this->definitionResolver->resolveExpressionNodeToType($scoped->scopeResolutionQualifier)
); );

View File

@ -1,20 +1,20 @@
<?php <?php
namespace LanguageServer; namespace LanguageServer\FqnUtilities;
use phpDocumentor\Reflection\{Type, Types}; use phpDocumentor\Reflection\{Type, Types};
use Microsoft\PhpParser; use Microsoft\PhpParser;
class FqnUtilities echo "FQN_UTILIIES" . PHP_EOL;
{
/** /**
* Returns all possible FQNs in a type * Returns all possible FQNs in a type
* *
* @param Type|null $type * @param Type|null $type
* @return string[] * @return string[]
*/ */
public static function getFqnsFromType($type): array function getFqnsFromType($type): array
{ {
$fqns = []; $fqns = [];
if ($type instanceof Types\Object_) { if ($type instanceof Types\Object_) {
$fqsen = $type->getFqsen(); $fqsen = $type->getFqsen();
@ -24,11 +24,10 @@ class FqnUtilities
} }
if ($type instanceof Types\Compound) { if ($type instanceof Types\Compound) {
for ($i = 0; $t = $type->get($i); $i++) { for ($i = 0; $t = $type->get($i); $i++) {
foreach (self::getFqnsFromType($type) as $fqn) { foreach (getFqnsFromType($type) as $fqn) {
$fqns[] = $fqn; $fqns[] = $fqn;
} }
} }
} }
return $fqns; return $fqns;
}
} }

View File

@ -4,7 +4,7 @@ declare(strict_types = 1);
namespace LanguageServer\Server; namespace LanguageServer\Server;
use LanguageServer\{ use LanguageServer\{
CompletionProvider, FqnUtilities, LanguageClient, PhpDocument, PhpDocumentLoader, DefinitionResolver CompletionProvider, LanguageClient, PhpDocument, PhpDocumentLoader, DefinitionResolver
}; };
use LanguageServer\Index\ReadableIndex; use LanguageServer\Index\ReadableIndex;
use LanguageServer\Protocol\{ use LanguageServer\Protocol\{