1
0
Fork 0

use correct terminology

pull/451/head
Nicolas MURE 2017-10-05 20:45:57 +02:00
parent e34d8e15dd
commit 14f840bd2f
No known key found for this signature in database
GPG Key ID: E5B036F9145C4CAA
4 changed files with 44 additions and 44 deletions

View File

@ -201,12 +201,12 @@ class CompletionProvider
$this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression) $this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression)
); );
// The namespaces of the symbol and its parents (eg the implemented interfaces) // The FQNs of the symbol and its parents (eg the implemented interfaces)
foreach ($this->expandParentFqns($fqns) as $namespace) { foreach ($this->expandParentFqns($fqns) as $parentFqn) {
// Collect namespaces definitions // Collect fqn definitions
foreach ($this->index->getDefinitionsForNamespace($namespace) as $fqn => $def) { foreach ($this->index->getDefinitionsForFqn($parentFqn) as $fqn => $def) {
// Add the object access operator to only get members of all parents // Add the object access operator to only get members of all parents
$prefix = $namespace . '->'; $prefix = $parentFqn . '->';
if (substr($fqn, 0, strlen($prefix)) === $prefix && !$def->isMember) { if (substr($fqn, 0, strlen($prefix)) === $prefix && !$def->isMember) {
$list->items[] = CompletionItem::fromDefinition($def); $list->items[] = CompletionItem::fromDefinition($def);
} }
@ -231,12 +231,12 @@ class CompletionProvider
$classType = $this->definitionResolver->resolveExpressionNodeToType($scoped->scopeResolutionQualifier) $classType = $this->definitionResolver->resolveExpressionNodeToType($scoped->scopeResolutionQualifier)
); );
// The namespaces of the symbol and its parents (eg the implemented interfaces) // The FQNs of the symbol and its parents (eg the implemented interfaces)
foreach ($this->expandParentFqns($fqns) as $namespace) { foreach ($this->expandParentFqns($fqns) as $parentFqn) {
// Collect namespaces definitions // Collect fqn definitions
foreach ($this->index->getDefinitionsForNamespace($namespace) as $fqn => $def) { foreach ($this->index->getDefinitionsForFqn($parentFqn) as $fqn => $def) {
// Append :: operator to only get static members of all parents // Append :: operator to only get static members of all parents
$prefix = strtolower($namespace . '::'); $prefix = strtolower($parentFqn . '::');
if (substr(strtolower($fqn), 0, strlen($prefix)) === $prefix && !$def->isMember) { if (substr(strtolower($fqn), 0, strlen($prefix)) === $prefix && !$def->isMember) {
$list->items[] = CompletionItem::fromDefinition($def); $list->items[] = CompletionItem::fromDefinition($def);
} }

View File

@ -129,16 +129,16 @@ abstract class AbstractAggregateIndex implements ReadableIndex
} }
/** /**
* Returns a Generator providing the Definitions that are in the given namespace * Returns a Generator providing the Definitions that are in the given FQN
* *
* @param string $namespace * @param string $fqn
* @return \Generator providing Definitions[] * @return \Generator providing Definitions[]
*/ */
public function getDefinitionsForNamespace(string $namespace): \Generator public function getDefinitionsForFqn(string $fqn): \Generator
{ {
foreach ($this->getIndexes() as $index) { foreach ($this->getIndexes() as $index) {
foreach ($index->getDefinitionsForNamespace($namespace) as $fqn => $definition) { foreach ($index->getDefinitionsForFqn($fqn) as $symbolFqn => $definition) {
yield $fqn => $definition; yield $symbolFqn => $definition;
} }
} }
} }

View File

@ -15,7 +15,7 @@ class Index implements ReadableIndex, \Serializable
use EmitterTrait; use EmitterTrait;
/** /**
* An associative array that maps namespaces to * An associative array that maps fully qualified names to
* an associative array that maps fully qualified symbol names * an associative array that maps fully qualified symbol names
* to global Definitions, e.g. : * to global Definitions, e.g. :
* [ * [
@ -27,7 +27,7 @@ class Index implements ReadableIndex, \Serializable
* *
* @var array * @var array
*/ */
private $namespaceDefinitions = []; private $fqnDefinitions = [];
/** /**
* An associative array that maps fully qualified symbol names * An associative array that maps fully qualified symbol names
@ -108,8 +108,8 @@ class Index implements ReadableIndex, \Serializable
*/ */
public function getDefinitions(): \Generator public function getDefinitions(): \Generator
{ {
foreach ($this->namespaceDefinitions as $namespaceDefinition) { foreach ($this->fqnDefinitions as $fqnDefinition) {
foreach ($namespaceDefinition as $fqn => $definition) { foreach ($fqnDefinition as $fqn => $definition) {
yield $fqn => $definition; yield $fqn => $definition;
} }
} }
@ -129,15 +129,15 @@ class Index implements ReadableIndex, \Serializable
} }
/** /**
* Returns a Generator providing the Definitions that are in the given namespace * Returns a Generator providing the Definitions that are in the given FQN
* *
* @param string $namespace * @param string $fqn
* @return \Generator providing Definitions[] * @return \Generator providing Definitions[]
*/ */
public function getDefinitionsForNamespace(string $namespace): \Generator public function getDefinitionsForFqn(string $fqn): \Generator
{ {
foreach ($this->namespaceDefinitions[$namespace] ?? [] as $fqn => $definition) { foreach ($this->fqnDefinitions[$fqn] ?? [] as $symbolFqn => $definition) {
yield $fqn => $definition; yield $symbolFqn => $definition;
} }
} }
@ -150,8 +150,8 @@ class Index implements ReadableIndex, \Serializable
*/ */
public function getDefinition(string $fqn, bool $globalFallback = false) public function getDefinition(string $fqn, bool $globalFallback = false)
{ {
$namespace = $this->extractNamespace($fqn); $namespacedFqn = $this->extractNamespacedFqn($fqn);
$definitions = $this->namespaceDefinitions[$namespace] ?? []; $definitions = $this->fqnDefinitions[$namespacedFqn] ?? [];
if (isset($definitions[$fqn])) { if (isset($definitions[$fqn])) {
return $definitions[$fqn]; return $definitions[$fqn];
@ -173,12 +173,12 @@ class Index implements ReadableIndex, \Serializable
*/ */
public function setDefinition(string $fqn, Definition $definition) public function setDefinition(string $fqn, Definition $definition)
{ {
$namespace = $this->extractNamespace($fqn); $namespacedFqn = $this->extractNamespacedFqn($fqn);
if (!isset($this->namespaceDefinitions[$namespace])) { if (!isset($this->fqnDefinitions[$namespacedFqn])) {
$this->namespaceDefinitions[$namespace] = []; $this->fqnDefinitions[$namespacedFqn] = [];
} }
$this->namespaceDefinitions[$namespace][$fqn] = $definition; $this->fqnDefinitions[$namespacedFqn][$fqn] = $definition;
$this->setGlobalDefinition($fqn, $definition); $this->setGlobalDefinition($fqn, $definition);
$this->emit('definition-added'); $this->emit('definition-added');
} }
@ -192,12 +192,12 @@ class Index implements ReadableIndex, \Serializable
*/ */
public function removeDefinition(string $fqn) public function removeDefinition(string $fqn)
{ {
$namespace = $this->extractNamespace($fqn); $namespacedFqn = $this->extractNamespacedFqn($fqn);
if (isset($this->namespaceDefinitions[$namespace])) { if (isset($this->fqnDefinitions[$namespacedFqn])) {
unset($this->namespaceDefinitions[$namespace][$fqn]); unset($this->fqnDefinitions[$namespacedFqn][$fqn]);
if (empty($this->namespaceDefinitions[$namespace])) { if (empty($this->fqnDefinitions[$namespacedFqn])) {
unset($this->namespaceDefinitions[$namespace]); unset($this->fqnDefinitions[$namespacedFqn]);
} }
} }
@ -277,8 +277,8 @@ class Index implements ReadableIndex, \Serializable
$this->$prop = $val; $this->$prop = $val;
} }
foreach ($this->namespaceDefinitions as $namespaceDefinition) { foreach ($this->fqnDefinitions as $fqnDefinition) {
foreach ($namespaceDefinition as $fqn => $definition) { foreach ($fqnDefinition as $fqn => $definition) {
$this->setGlobalDefinition($fqn, $definition); $this->setGlobalDefinition($fqn, $definition);
} }
} }
@ -291,7 +291,7 @@ class Index implements ReadableIndex, \Serializable
public function serialize() public function serialize()
{ {
return serialize([ return serialize([
'namespaceDefinitions' => $this->namespaceDefinitions, 'fqnDefinitions' => $this->fqnDefinitions,
'references' => $this->references, 'references' => $this->references,
'complete' => $this->complete, 'complete' => $this->complete,
'staticComplete' => $this->staticComplete 'staticComplete' => $this->staticComplete
@ -313,10 +313,10 @@ class Index implements ReadableIndex, \Serializable
} }
/** /**
* @param string $fqn * @param string $fqn The symbol FQN
* @return string The namespace extracted from the given FQN * @return string The namespaced FQN extracted from the given symbol FQN
*/ */
private function extractNamespace(string $fqn): string private function extractNamespacedFqn(string $fqn): string
{ {
foreach (['::', '->'] as $operator) { foreach (['::', '->'] as $operator) {
if (false !== ($pos = strpos($fqn, $operator))) { if (false !== ($pos = strpos($fqn, $operator))) {

View File

@ -46,12 +46,12 @@ interface ReadableIndex extends EmitterInterface
public function getGlobalDefinitions(): \Generator; public function getGlobalDefinitions(): \Generator;
/** /**
* Returns a Generator providing the Definitions that are in the given namespace * Returns a Generator providing the Definitions that are in the given FQN
* *
* @param string $namespace * @param string $fqn
* @return \Generator providing Definitions[] * @return \Generator providing Definitions[]
*/ */
public function getDefinitionsForNamespace(string $namespace): \Generator; public function getDefinitionsForFqn(string $fqn): \Generator;
/** /**
* Returns the Definition object by a specific FQN * Returns the Definition object by a specific FQN