Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete member selectivity #607

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2d91ee8
speedup autocomplete with ReadableIndex::getDefinitionsForNamespace
nicolasmure Aug 6, 2017
b7c7128
update tests
nicolasmure Aug 6, 2017
6d725a2
speedup static access autocomplete
nicolasmure Aug 6, 2017
18f2f4c
cleanup
nicolasmure Aug 6, 2017
17602aa
globalDefinitions cache to speedup autocomplete
nicolasmure Aug 6, 2017
6d30035
also remove empty namespace index
nicolasmure Aug 8, 2017
ca0caf1
store definitions under the namespaceDefinitions cache key directly
nicolasmure Aug 9, 2017
8768b69
use Generators to get definitions without wasting memory
nicolasmure Aug 9, 2017
8801edb
also yield URIs to save memory
nicolasmure Aug 9, 2017
6a41a7f
add example of indexed definitions
nicolasmure Aug 10, 2017
6a36828
avoid useless array
nicolasmure Aug 10, 2017
e34d8e1
use of null coalescing operator
nicolasmure Aug 10, 2017
14f840b
use correct terminology
nicolasmure Oct 5, 2017
e9fd572
consider the merge of #511
nicolasmure Nov 13, 2017
d1f85f1
use tree representation index
nicolasmure Nov 13, 2017
188a5df
fix definitions storage collision (member / non member)
nicolasmure Nov 14, 2017
cacde1e
use a single array to store definitions
nicolasmure Nov 14, 2017
e162d94
cleanup
nicolasmure Nov 14, 2017
7437d30
Fix formatting
felixfbecker Nov 15, 2017
b118c77
Correct some docblocks
felixfbecker Nov 15, 2017
b3f30f3
cache is backward compatible
nicolasmure Nov 15, 2017
7511e25
Merge branch 'master' into feature/autocomplete-speedup
felixfbecker Nov 15, 2017
fcdf791
use string concatenation instead of sprintf
nicolasmure Nov 16, 2017
3bda390
Merge branch 'master' into feature/autocomplete-speedup
felixfbecker Nov 19, 2017
b03950c
Cleanup
felixfbecker Nov 18, 2017
97ec127
fix definition removal
nicolasmure Nov 19, 2017
48bbbb5
differenciate member and non member definitions
nicolasmure Nov 19, 2017
67dd980
Merge branch 'master' into feature/autocomplete-speedup
felixfbecker Nov 19, 2017
91ca99a
Revert "differenciate member and non member definitions"
felixfbecker Nov 23, 2017
fa67f84
perf: get direct children
felixfbecker Nov 23, 2017
81c40f2
chore: add completion benchmark
felixfbecker Nov 23, 2017
8617948
Merge remote-tracking branch 'origin/master' into autocomplet-speedup
Declspeck Feb 3, 2018
439cebe
fix(tests): fix require in parsing.php benchmark after file move
Declspeck Feb 3, 2018
e589f9e
refactor(completion): make completion of global symbols use Index mor…
Declspeck Feb 3, 2018
6858bd3
tests(completion): add completion of new| ParameterBag to completion …
Declspeck Feb 3, 2018
d6b4e79
feat(completion): complete for used namespaces
Declspeck Feb 9, 2018
98ac9ff
Merge branch 'master' into autocomplet-speedup
Declspeck Feb 9, 2018
d1933b8
refactor(completion): rewrite global name completion with generators
Declspeck Feb 15, 2018
0bc5b81
fix(completion): Return type hint
Declspeck Feb 15, 2018
90cb77e
feat(completion): exclude non-matching members after ::prefix and ->p…
Declspeck Feb 24, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use Generators to get definitions without wasting memory
  • Loading branch information
nicolasmure committed Nov 13, 2017
commit 8768b698d5ce011f67b930355b31c5c75a69ecbb
30 changes: 14 additions & 16 deletions src/Index/AbstractAggregateIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,42 +107,40 @@ public function isStaticComplete(): bool
public function getDefinitions(): \Generator
{
foreach ($this->getIndexes() as $index) {
yield $index->getDefinitions();
foreach ($index->getDefinitions() as $fqn => $definitions) {
yield $fqn => $definition;
}
}
}

/**
* Returns an associative array [string => Definition] that maps fully qualified symbol names
* to global Definitions
* Returns a Generator providing an associative array [string => Definition]
* that maps fully qualified symbol names to global Definitions
*
* @return Definition[]
* @return \Generator providing Definitions[]
*/
public function getGlobalDefinitions(): array
public function getGlobalDefinitions(): \Generator
{
$defs = [];
foreach ($this->getIndexes() as $index) {
foreach ($index->getGlobalDefinitions() as $fqn => $def) {
$defs[$fqn] = $def;
foreach ($index->getGlobalDefinitions() as $fqn => $definition) {
yield $fqn => $definition;
}
}
return $defs;
}

/**
* Returns the Definitions that are in the given namespace
* Returns a Generator providing the Definitions that are in the given namespace
*
* @param string $namespace
* @return Definitions[]
* @return \Generator providing Definitions[]
*/
public function getDefinitionsForNamespace(string $namespace): array
public function getDefinitionsForNamespace(string $namespace): \Generator
{
$defs = [];
foreach ($this->getIndexes() as $index) {
foreach ($index->getDefinitionsForNamespace($namespace) as $fqn => $def) {
$defs[$fqn] = $def;
foreach ($index->getDefinitionsForNamespace($namespace) as $fqn => $definition) {
yield $fqn => $definition;
}
}
return $defs;
}

/**
Expand Down
41 changes: 28 additions & 13 deletions src/Index/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,29 @@ public function getDefinitions(): \Generator
}

/**
* Returns an associative array [string => Definition] that maps fully qualified symbol names
* to global Definitions
* Returns a Generator providing an associative array [string => Definition]
* that maps fully qualified symbol names to global Definitions
*
* @return Definition[]
* @return \Generator providing Definitions[]
*/
public function getGlobalDefinitions(): array
public function getGlobalDefinitions(): \Generator
{
return $this->globalDefinitions;
foreach ($this->globalDefinitions as $fqn => $definition) {
yield $fqn => $definition;
}
}

/**
* Returns the Definitions that are in the given namespace
* Returns a Generator providing the Definitions that are in the given namespace
*
* @param string $namespace
* @return Definitions[]
* @return \Generator providing Definitions[]
*/
public function getDefinitionsForNamespace(string $namespace): array
public function getDefinitionsForNamespace(string $namespace): \Generator
{
return isset($this->namespaceDefinitions[$namespace])
? $this->namespaceDefinitions[$namespace]
: []
;
foreach ($this->doGetDefinitionsForNamespace($namespace) as $fqn => $definition) {
yield $fqn => $definition;
}
}

/**
Expand All @@ -141,7 +142,7 @@ public function getDefinitionsForNamespace(string $namespace): array
public function getDefinition(string $fqn, bool $globalFallback = false)
{
$namespace = $this->extractNamespace($fqn);
$definitions = $this->getDefinitionsForNamespace($namespace);
$definitions = $this->doGetDefinitionsForNamespace($namespace);

if (isset($definitions[$fqn])) {
return $definitions[$fqn];
Expand Down Expand Up @@ -314,4 +315,18 @@ private function extractNamespace(string $fqn): string

return $fqn;
}

/**
* Returns the Definitions that are in the given namespace
*
* @param string $namespace
* @return Definition[]
*/
private function doGetDefinitionsForNamespace(string $namespace): array
{
return isset($this->namespaceDefinitions[$namespace])
? $this->namespaceDefinitions[$namespace]
: []
;
}
}
14 changes: 7 additions & 7 deletions src/Index/ReadableIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ public function isStaticComplete(): bool;
public function getDefinitions(): \Generator;

/**
* Returns an associative array [string => Definition] that maps fully qualified symbol names
* to global Definitions
* Returns a Generator providing an associative array [string => Definition]
* that maps fully qualified symbol names to global Definitions
*
* @return Definitions[]
* @return \Generator providing Definitions[]
*/
public function getGlobalDefinitions(): array;
public function getGlobalDefinitions(): \Generator;

/**
* Returns the Definitions that are in the given namespace
* Returns a Generator providing the Definitions that are in the given namespace
*
* @param string $namespace
* @return Definitions[]
* @return \Generator providing Definitions[]
*/
public function getDefinitionsForNamespace(string $namespace): array;
public function getDefinitionsForNamespace(string $namespace): \Generator;

/**
* Returns the Definition object by a specific FQN
Expand Down