diff --git a/Completer.php b/Completer.php index f0808ac..9796b52 100644 --- a/Completer.php +++ b/Completer.php @@ -17,19 +17,10 @@ public function __construct(ClassNameCompleter $completer) } public function getEntries(Project $project, Context $context) { - list($type, $isThis, $types) = $context->getData(); - if (is_array($types)) { - $fqcn = array_pop($types); - if ($fqcn instanceof FQCN - && $fqcn->toString() === 'DI\\Container' - ) { - return array_map( - [$this, 'wrapEntry'], - $this->classNameCompleter->getEntries($project, $context) - ); - } - } - return []; + return array_map( + [$this, 'wrapEntry'], + $this->classNameCompleter->getEntries($project, $context) + ); } public function wrapEntry($entry) diff --git a/Plugin.php b/Plugin.php index 21344cf..48b9247 100644 --- a/Plugin.php +++ b/Plugin.php @@ -4,8 +4,9 @@ use Symfony\Component\EventDispatcher\EventDispatcher; use Complete\Resolver\NodeTypeResolver; -use Complete\Completer\CompleterFactory; +use Complete\CompleteEngine; use Parser\UseParser; +use Entity\FQCN; class Plugin { @@ -30,7 +31,7 @@ public function init() [$this->resolver, 'handleTypeResolveEvent'] ); $this->dispatcher->addListener( - CompleterFactory::CUSTOM_COMPLETER, + CompleteEngine::CUSTOM_COMPLETER, [$this, 'handleCompleteEvent'] ); } @@ -39,7 +40,14 @@ public function handleCompleteEvent($e) { $context = $e->context; if ($context->isMethodCall()) { - $e->completer = $this->completer; + list($type, $isThis, $types, $workingNode) = $context->getData(); + $fqcn = array_pop($types); + if ($fqcn instanceof FQCN + && $fqcn->toString() === 'DI\\Container' + && $workingNode->name === 'get' + ) { + $e->completer = $this->completer; + } } }