From 2c4f0fca8d17229fbb63b8a539a7bb55d0682f78 Mon Sep 17 00:00:00 2001 From: Aleh Kashnikau Date: Fri, 8 May 2015 20:17:40 +0300 Subject: [PATCH] added fixes for vim client --- LICENSE | 4 ++-- src/Command/SaveCommand.php | 2 +- src/DI/config.php | 4 +++- src/Parser/Processor/ScopeProcessor.php | 12 ++++++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/LICENSE b/LICENSE index bfda420..c8409a0 100644 --- a/LICENSE +++ b/LICENSE @@ -5,10 +5,10 @@ distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/Command/SaveCommand.php b/src/Command/SaveCommand.php index a1bc8bc..8ed94d5 100644 --- a/src/Command/SaveCommand.php +++ b/src/Command/SaveCommand.php @@ -3,7 +3,7 @@ namespace Command; class SaveCommand extends AbstractCommand { - public function run(array $arguments){ + public function run(array $arguments = []){ $project = $arguments["project"]; /** @var \IO\Writer $writer */ $writer = $this->get('IO\Writer'); diff --git a/src/DI/config.php b/src/DI/config.php index cbc23c2..cf8bc24 100644 --- a/src/DI/config.php +++ b/src/DI/config.php @@ -6,7 +6,9 @@ Psr\Log\LoggerInterface::class => DI\factory(function () { $logger = new Logger('completer'); - $logger->pushHandler(new \Monolog\Handler\ErrorLogHandler()); + $logger->pushHandler(new \Monolog\Handler\StreamHandler( + "php://stdout" + )); return $logger; }), ]; diff --git a/src/Parser/Processor/ScopeProcessor.php b/src/Parser/Processor/ScopeProcessor.php index cdfae39..af3afd9 100644 --- a/src/Parser/Processor/ScopeProcessor.php +++ b/src/Parser/Processor/ScopeProcessor.php @@ -4,8 +4,9 @@ use Parser\UseParser; use Parser\CommentParser; -use Complete\Resolver\NodeTypeResolver; use Parser\ParamParser; +use Parser\NamespaceParser; +use Complete\Resolver\NodeTypeResolver; use Entity\FQCN; use Entity\Index; @@ -21,6 +22,7 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Stmt\Use_; use PhpParser\Node\Stmt\Class_; +use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Expr\Closure; @@ -29,13 +31,15 @@ public function __construct( UseParser $useParser, NodeTypeResolver $typeResolver, CommentParser $commentParser, - ParamParser $paramParser + ParamParser $paramParser, + NamespaceParser $namespaceParser ){ $this->resultNodes = []; $this->useParser = $useParser; $this->typeResolver = $typeResolver; $this->commentParser = $commentParser; $this->paramParser = $paramParser; + $this->namespaceParser = $namespaceParser; } public function setLine($line){ $this->line = $line; @@ -48,6 +52,9 @@ public function enterNode(Node $node){ if($node instanceof Class_){ $this->createScopeFromClass($node); } + elseif($node instanceof Namespace_){ + $this->namespaceParser->parse($node); + } elseif($node instanceof ClassMethod){ $this->createScopeFromMethod($node); } @@ -197,4 +204,5 @@ protected function createScope(){ private $commentParser; /** @property ParamParser */ private $paramParser; + private $namespaceParser; }