Skip to content

Commit 8ac93f7

Browse files
committed
fixed complete services structure
1 parent ef2086c commit 8ac93f7

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

src/Command/CompleteCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44

55
class CompleteCommand extends AbstractCommand {
66

7+
/**
8+
* Runs command
9+
*
10+
* @return array
11+
*/
712
public function run(array $arguments = []){
813
$project = $arguments["project"];
9-
$contentManager = $this->get("Complete\ContentManager");
14+
$completeEngine = $this->get("Complete\CompleteEngine");
1015
$column = $arguments['column'];
1116
$file = $arguments['filepath'];
1217
$line = $arguments['line'];
1318
$content = $arguments['contents'];
14-
$completion = $contentManager->createCompletion(
19+
$completion = $completeEngine->createCompletion(
1520
$project,
1621
$content,
1722
$line,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Parser\Processor\ScopeProcessor;
1616
use Psr\Log\LoggerInterface;
1717

18-
class ContentManager {
18+
class CompleteEngine {
1919
public function __construct(
2020
Parser $parser,
2121
IndexGenerator $generator,

src/Complete/Resolver/ContextResolver.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
use Entity\Completion\Token;
66
use Entity\Completion\Context;
7+
use Parser\ErrorFreePhpParser;
78

89
class ContextResolver{
10+
public function __construct(ErrorFreePhpParser $parser){
11+
$this->parser = $parser;
12+
}
913
public function getContext($badLine){
1014
if(empty($badLine)){
1115
throw new \Exception("Could not define empty line context");
1216
}
13-
printf("\nBad line: %s\n", $badLine);
17+
1418
$token = $this->getCompletionToken($badLine);
1519
$context = new Context($token, $token->symbol);
1620
return $this->defineContextType($context, $token);
@@ -129,4 +133,6 @@ private function isBreakSymbol($symbol){
129133
T_EXTENDS => self::S_EXTENDS,
130134
T_IMPLEMENTS => self::S_IMPLEMENTS
131135
];
136+
137+
private $parser;
132138
}

src/Parser/ErrorFreePhpParser.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Parser;
4+
5+
use PhpParser\Parser as ASTGenerator;
6+
7+
class ErrorFreePhpParser extends ASTGenerator{
8+
public function parse($content){
9+
try {
10+
return parent::parse($content);
11+
}
12+
catch(\Exception $e){
13+
return $this->semValue;
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)