Skip to content

Commit 14f840b

Browse files
committed
use correct terminology
1 parent e34d8e1 commit 14f840b

File tree

4 files changed

+44
-44
lines changed

4 files changed

+44
-44
lines changed

src/CompletionProvider.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ public function provideCompletion(PhpDocument $doc, Position $pos): CompletionLi
201201
$this->definitionResolver->resolveExpressionNodeToType($node->dereferencableExpression)
202202
);
203203

204-
// The namespaces of the symbol and its parents (eg the implemented interfaces)
205-
foreach ($this->expandParentFqns($fqns) as $namespace) {
206-
// Collect namespaces definitions
207-
foreach ($this->index->getDefinitionsForNamespace($namespace) as $fqn => $def) {
204+
// The FQNs of the symbol and its parents (eg the implemented interfaces)
205+
foreach ($this->expandParentFqns($fqns) as $parentFqn) {
206+
// Collect fqn definitions
207+
foreach ($this->index->getDefinitionsForFqn($parentFqn) as $fqn => $def) {
208208
// Add the object access operator to only get members of all parents
209-
$prefix = $namespace . '->';
209+
$prefix = $parentFqn . '->';
210210
if (substr($fqn, 0, strlen($prefix)) === $prefix && !$def->isMember) {
211211
$list->items[] = CompletionItem::fromDefinition($def);
212212
}
@@ -231,12 +231,12 @@ public function provideCompletion(PhpDocument $doc, Position $pos): CompletionLi
231231
$classType = $this->definitionResolver->resolveExpressionNodeToType($scoped->scopeResolutionQualifier)
232232
);
233233

234-
// The namespaces of the symbol and its parents (eg the implemented interfaces)
235-
foreach ($this->expandParentFqns($fqns) as $namespace) {
236-
// Collect namespaces definitions
237-
foreach ($this->index->getDefinitionsForNamespace($namespace) as $fqn => $def) {
234+
// The FQNs of the symbol and its parents (eg the implemented interfaces)
235+
foreach ($this->expandParentFqns($fqns) as $parentFqn) {
236+
// Collect fqn definitions
237+
foreach ($this->index->getDefinitionsForFqn($parentFqn) as $fqn => $def) {
238238
// Append :: operator to only get static members of all parents
239-
$prefix = strtolower($namespace . '::');
239+
$prefix = strtolower($parentFqn . '::');
240240
if (substr(strtolower($fqn), 0, strlen($prefix)) === $prefix && !$def->isMember) {
241241
$list->items[] = CompletionItem::fromDefinition($def);
242242
}

src/Index/AbstractAggregateIndex.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ public function getGlobalDefinitions(): \Generator
129129
}
130130

131131
/**
132-
* Returns a Generator providing the Definitions that are in the given namespace
132+
* Returns a Generator providing the Definitions that are in the given FQN
133133
*
134-
* @param string $namespace
134+
* @param string $fqn
135135
* @return \Generator providing Definitions[]
136136
*/
137-
public function getDefinitionsForNamespace(string $namespace): \Generator
137+
public function getDefinitionsForFqn(string $fqn): \Generator
138138
{
139139
foreach ($this->getIndexes() as $index) {
140-
foreach ($index->getDefinitionsForNamespace($namespace) as $fqn => $definition) {
141-
yield $fqn => $definition;
140+
foreach ($index->getDefinitionsForFqn($fqn) as $symbolFqn => $definition) {
141+
yield $symbolFqn => $definition;
142142
}
143143
}
144144
}

src/Index/Index.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Index implements ReadableIndex, \Serializable
1515
use EmitterTrait;
1616

1717
/**
18-
* An associative array that maps namespaces to
18+
* An associative array that maps fully qualified names to
1919
* an associative array that maps fully qualified symbol names
2020
* to global Definitions, e.g. :
2121
* [
@@ -27,7 +27,7 @@ class Index implements ReadableIndex, \Serializable
2727
*
2828
* @var array
2929
*/
30-
private $namespaceDefinitions = [];
30+
private $fqnDefinitions = [];
3131

3232
/**
3333
* An associative array that maps fully qualified symbol names
@@ -108,8 +108,8 @@ public function isStaticComplete(): bool
108108
*/
109109
public function getDefinitions(): \Generator
110110
{
111-
foreach ($this->namespaceDefinitions as $namespaceDefinition) {
112-
foreach ($namespaceDefinition as $fqn => $definition) {
111+
foreach ($this->fqnDefinitions as $fqnDefinition) {
112+
foreach ($fqnDefinition as $fqn => $definition) {
113113
yield $fqn => $definition;
114114
}
115115
}
@@ -129,15 +129,15 @@ public function getGlobalDefinitions(): \Generator
129129
}
130130

131131
/**
132-
* Returns a Generator providing the Definitions that are in the given namespace
132+
* Returns a Generator providing the Definitions that are in the given FQN
133133
*
134-
* @param string $namespace
134+
* @param string $fqn
135135
* @return \Generator providing Definitions[]
136136
*/
137-
public function getDefinitionsForNamespace(string $namespace): \Generator
137+
public function getDefinitionsForFqn(string $fqn): \Generator
138138
{
139-
foreach ($this->namespaceDefinitions[$namespace] ?? [] as $fqn => $definition) {
140-
yield $fqn => $definition;
139+
foreach ($this->fqnDefinitions[$fqn] ?? [] as $symbolFqn => $definition) {
140+
yield $symbolFqn => $definition;
141141
}
142142
}
143143

@@ -150,8 +150,8 @@ public function getDefinitionsForNamespace(string $namespace): \Generator
150150
*/
151151
public function getDefinition(string $fqn, bool $globalFallback = false)
152152
{
153-
$namespace = $this->extractNamespace($fqn);
154-
$definitions = $this->namespaceDefinitions[$namespace] ?? [];
153+
$namespacedFqn = $this->extractNamespacedFqn($fqn);
154+
$definitions = $this->fqnDefinitions[$namespacedFqn] ?? [];
155155

156156
if (isset($definitions[$fqn])) {
157157
return $definitions[$fqn];
@@ -173,12 +173,12 @@ public function getDefinition(string $fqn, bool $globalFallback = false)
173173
*/
174174
public function setDefinition(string $fqn, Definition $definition)
175175
{
176-
$namespace = $this->extractNamespace($fqn);
177-
if (!isset($this->namespaceDefinitions[$namespace])) {
178-
$this->namespaceDefinitions[$namespace] = [];
176+
$namespacedFqn = $this->extractNamespacedFqn($fqn);
177+
if (!isset($this->fqnDefinitions[$namespacedFqn])) {
178+
$this->fqnDefinitions[$namespacedFqn] = [];
179179
}
180180

181-
$this->namespaceDefinitions[$namespace][$fqn] = $definition;
181+
$this->fqnDefinitions[$namespacedFqn][$fqn] = $definition;
182182
$this->setGlobalDefinition($fqn, $definition);
183183
$this->emit('definition-added');
184184
}
@@ -192,12 +192,12 @@ public function setDefinition(string $fqn, Definition $definition)
192192
*/
193193
public function removeDefinition(string $fqn)
194194
{
195-
$namespace = $this->extractNamespace($fqn);
196-
if (isset($this->namespaceDefinitions[$namespace])) {
197-
unset($this->namespaceDefinitions[$namespace][$fqn]);
195+
$namespacedFqn = $this->extractNamespacedFqn($fqn);
196+
if (isset($this->fqnDefinitions[$namespacedFqn])) {
197+
unset($this->fqnDefinitions[$namespacedFqn][$fqn]);
198198

199-
if (empty($this->namespaceDefinitions[$namespace])) {
200-
unset($this->namespaceDefinitions[$namespace]);
199+
if (empty($this->fqnDefinitions[$namespacedFqn])) {
200+
unset($this->fqnDefinitions[$namespacedFqn]);
201201
}
202202
}
203203

@@ -277,8 +277,8 @@ public function unserialize($serialized)
277277
$this->$prop = $val;
278278
}
279279

280-
foreach ($this->namespaceDefinitions as $namespaceDefinition) {
281-
foreach ($namespaceDefinition as $fqn => $definition) {
280+
foreach ($this->fqnDefinitions as $fqnDefinition) {
281+
foreach ($fqnDefinition as $fqn => $definition) {
282282
$this->setGlobalDefinition($fqn, $definition);
283283
}
284284
}
@@ -291,7 +291,7 @@ public function unserialize($serialized)
291291
public function serialize()
292292
{
293293
return serialize([
294-
'namespaceDefinitions' => $this->namespaceDefinitions,
294+
'fqnDefinitions' => $this->fqnDefinitions,
295295
'references' => $this->references,
296296
'complete' => $this->complete,
297297
'staticComplete' => $this->staticComplete
@@ -313,10 +313,10 @@ private function setGlobalDefinition(string $fqn, Definition $definition)
313313
}
314314

315315
/**
316-
* @param string $fqn
317-
* @return string The namespace extracted from the given FQN
316+
* @param string $fqn The symbol FQN
317+
* @return string The namespaced FQN extracted from the given symbol FQN
318318
*/
319-
private function extractNamespace(string $fqn): string
319+
private function extractNamespacedFqn(string $fqn): string
320320
{
321321
foreach (['::', '->'] as $operator) {
322322
if (false !== ($pos = strpos($fqn, $operator))) {

src/Index/ReadableIndex.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public function getDefinitions(): \Generator;
4646
public function getGlobalDefinitions(): \Generator;
4747

4848
/**
49-
* Returns a Generator providing the Definitions that are in the given namespace
49+
* Returns a Generator providing the Definitions that are in the given FQN
5050
*
51-
* @param string $namespace
51+
* @param string $fqn
5252
* @return \Generator providing Definitions[]
5353
*/
54-
public function getDefinitionsForNamespace(string $namespace): \Generator;
54+
public function getDefinitionsForFqn(string $fqn): \Generator;
5555

5656
/**
5757
* Returns the Definition object by a specific FQN

0 commit comments

Comments
 (0)