Chris@0: getAutoCompleter(); Chris@0: foreach ($matchers as $matcher) { Chris@0: if ($matcher instanceof ContextAware) { Chris@0: $matcher->setContext($context); Chris@0: } Chris@0: $tabCompletion->addMatcher($matcher); Chris@0: } Chris@0: Chris@0: $context->setAll(array('foo' => 12, 'bar' => new \DOMDocument())); Chris@0: Chris@0: $code = $tabCompletion->processCallback('', 0, array( Chris@0: 'line_buffer' => $line, Chris@0: 'point' => 0, Chris@0: 'end' => strlen($line), Chris@0: )); Chris@0: Chris@0: foreach ($mustContain as $mc) { Chris@0: $this->assertContains($mc, $code); Chris@0: } Chris@0: Chris@0: foreach ($mustNotContain as $mnc) { Chris@0: $this->assertNotContains($mnc, $code); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * TODO Chris@0: * ==== Chris@0: * draft, open to modifications Chris@0: * - [ ] if the variable is an array, return the square bracket for completion Chris@0: * - [ ] if the variable is a constructor or method, reflect to complete as a function call Chris@0: * - [ ] if the preceding token is a variable, call operators or keywords compatible for completion Chris@0: * - [X] a command always should be the second token after php_open_tag Chris@0: * - [X] keywords are never consecutive Chris@0: * - [X] namespacing completion should work just fine Chris@0: * - [X] after a new keyword, should always be a class constructor, never a function call or keyword, constant, Chris@0: * or variable that does not contain a existing class name. Chris@0: * - [X] on a namespaced constructor the completion must show the classes related, not constants. Chris@0: * Chris@0: * @return array Chris@0: */ Chris@0: public function classesInput() Chris@0: { Chris@0: return array( Chris@0: // input, must had, must not had Chris@0: array('T_OPE', array('T_OPEN_TAG'), array()), Chris@0: array('st', array('stdClass'), array()), Chris@0: array('stdCla', array('stdClass'), array()), Chris@0: array('new s', array('stdClass'), array()), Chris@0: array( Chris@0: 'new ', Chris@0: array('stdClass', 'Psy\\Context', 'Psy\\Configuration'), Chris@0: array('require', 'array_search', 'T_OPEN_TAG', '$foo'), Chris@0: ), Chris@0: array('new Psy\\C', array('Context'), array('CASE_LOWER')), Chris@0: array('\s', array('stdClass'), array()), Chris@0: array('array_', array('array_search', 'array_map', 'array_merge'), array()), Chris@0: array('$bar->', array('load'), array()), Chris@0: array('$b', array('bar'), array()), Chris@0: array('6 + $b', array('bar'), array()), Chris@0: array('$f', array('foo'), array()), Chris@0: array('l', array('ls'), array()), Chris@0: array('ls ', array(), array('ls')), Chris@0: array('sho', array('show'), array()), Chris@0: array('12 + clone $', array('foo'), array()), Chris@0: // array( Chris@0: // '$foo ', Chris@0: // array('+', 'clone'), Chris@0: // array('$foo', 'DOMDocument', 'array_map') Chris@0: // ), requires a operator matcher? Chris@0: array('$', array('foo', 'bar'), array('require', 'array_search', 'T_OPEN_TAG', 'Psy')), Chris@0: array( Chris@0: 'Psy\\', Chris@0: array('Context', 'TabCompletion\\Matcher\\AbstractMatcher'), Chris@0: array('require', 'array_search'), Chris@0: ), Chris@0: array( Chris@0: 'Psy\Test\TabCompletion\StaticSample::CO', Chris@0: array('Psy\Test\TabCompletion\StaticSample::CONSTANT_VALUE'), Chris@0: array(), Chris@0: ), Chris@0: array( Chris@0: 'Psy\Test\TabCompletion\StaticSample::', Chris@0: array('Psy\Test\TabCompletion\StaticSample::$staticVariable'), Chris@0: array(), Chris@0: ), Chris@0: array( Chris@0: 'Psy\Test\TabCompletion\StaticSample::', Chris@0: array('Psy\Test\TabCompletion\StaticSample::staticFunction'), Chris@0: array(), Chris@0: ), Chris@0: ); Chris@0: } Chris@0: }