File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55class 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 ,
Original file line number Diff line number Diff line change 1515use Parser \Processor \ScopeProcessor ;
1616use Psr \Log \LoggerInterface ;
1717
18- class ContentManager {
18+ class CompleteEngine {
1919 public function __construct (
2020 Parser $ parser ,
2121 IndexGenerator $ generator ,
Original file line number Diff line number Diff line change 44
55use Entity \Completion \Token ;
66use Entity \Completion \Context ;
7+ use Parser \ErrorFreePhpParser ;
78
89class 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 ( "\n Bad 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}
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments