Tries to return autocompletion for the current entered text.


@return bool|array A list of guessed strings or true
@codeCoverageIgnore
967787
private function autocompleter()
    {
        $info = readline_info();
        $text = substr($info['line_buffer'], 0, $info['end']);

        if ($info['point'] !== $info['end']) {
            return true;
        }
        // task name?
        if (false === strpos($text, ' ') || !$text) {
            $commands = array_keys($this->application->all());
            $commands[] = 'quit';
            $commands[] = 'all';

            return $commands;
        }

        // options and arguments?
        try {
            $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
        } catch (\Exception $e) {
            return true;
        }

        $list = array('--help');
        foreach ($command->getDefinition()->getOptions() as $option) {
            $opt = '--'.$option->getName();
            if (!in_array($opt,$list)) {
                $list[] = $opt;
            }
        }

        return $list;
    }
163937
public function askInput($questionText, $default = null, array $autoCompleterValues = [], callable $validator = null)
    {
        if ($default !== null) {
            $questionText .= ' <question>[' . $default . ']</question>';
        }
        $questionText .= ': ';
        $question = new Question($questionText, $default);
        if (!empty($autoCompleterValues)) {
            $question->setAutocompleterValues($autoCompleterValues);
        }
        if ($validator !== null) {
            $question->setValidator($validator);
            $question->setMaxAttempts(5);
        }

        return $this->ask($this->input, $this->output, $question);
    }
37349
public function autocomplete_init()
    {
        static $init;

        if ($init) {
            return;
        }

        $init = 1;

        if (($threads = (int)$this->config->get('autocomplete_threads')) > 0) {
            $book_types = (array) $this->config->get('autocomplete_addressbooks', 'sql');
            if (count($book_types) > 1) {
                $this->output->set_env('autocomplete_threads', $threads);
                $this->output->set_env('autocomplete_sources', $book_types);
            }
        }

        $this->output->set_env('autocomplete_max', (int)$this->config->get('autocomplete_max', 15));
        $this->output->set_env('autocomplete_min_length', $this->config->get('autocomplete_min_length'));
        $this->output->add_label('autocompletechars', 'autocompletemore');
    }
919627
protected function consumeMatch()
    {

        //Make sure we don't consume matched newlines (We match for them sometimes)
        //We need the newLine tokens and don't want them consumed here.
        $match = $this->lastMatches[0] !== "\n" ? rtrim($this->lastMatches[0], "\n") : $this->lastMatches[0];

        return $this->consume($this->strlen($match));
    }
580393
protected function hasNextCharacter()
	{
		return key($this->characters) !== null 
			&& array_key_exists(key($this->characters) + 1, $this->characters);
	}
95578
protected function isRegexpLiteral()
    {
        if (strpos("\n{;(,=:[!&|?", $this->a) !== false) {
            return true;
        }
        if ($this->a === ' ') {
            $length = strlen($this->output);
            if ($length < 2) {
                return true;
            }
            if (preg_match('/(?:case|else|in|return|typeof)$/', $this->output, $m)) {
                if ($this->output === $m[0]) {
                    return true;
                }
                $charBeforeKeyword = substr($this->output, $length - strlen($m[0]) - 1, 1);
                if (!$this->isAlphaNum($charBeforeKeyword)) {
                    return true;
                }
            }
        }
        return false;
    }
608884
public function searchText()
    {
        $query = $this->newQuery();
        if (Request::get('admin_text_search')) {
            foreach ($this->adminFilters['text_search']['db_fields'] as $field) {
                $query->orWhere($field, 'LIKE', '%'.Request::get('admin_text_search').'%');
            }
        }

        return $query;
    }
657620
public function autocomplete($postcode)
    {
        $url = '/postcodes/' . rawurlencode($postcode) . '/autocomplete';
        $request = new Request('GET', $url);

        return $this->httpTransport($request);
    }
376303
protected function getInput()
	{
		// Initialize some field attributes.
		$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
		$maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
		$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
		$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
		$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
		$autofocus = ((string) $this->element['autofocus'] == 'true') ? ' autofocus' : '';
		$autocomplete = $this->element['autocomplete'] ? ' autocomplete="' . (string) $this->element['autocomplete'] . '"' : '';

		// Temporary workaround to make sure the placeholder can be set without coupling to joomla/language
		$placeholder = '';

		if ($this->element['placeholder'])
		{
			try
			{
				$placeholder = ' placeholder="' . $this->getText()->translate((string) $this->element['placeholder']) . '"';
			}
			catch (\RuntimeException $e)
			{
				$placeholder = ' placeholder="' . (string) $this->element['placeholder'] . '"';
			}
		}

		// Initialize JavaScript field attributes.
		$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

		return '<input type="' . strtolower($this->type) . '" name="' . $this->name . '" id="' . $this->id . '"'
			. ' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $size . $disabled
			. $readonly . $onchange . $maxLength . $placeholder . $autofocus . $autocomplete . '/>';
	}
458984
public function check()
	{
		$this->checked	= TRUE;
		$this->methods	= array();
		$matches		= array();
		$content		= FS_File_Reader::load( $this->fileName );
		if( preg_match( "@class @i", $content ) )
			if( preg_match_all( "@\tfunction (& *)?([a-z][a-z0-9]+)@i", $content, $matches ) )
				foreach( $matches[2] as $match )
					$this->methods[]	= $match;
		return empty( $this->methods );
	}
1285490
def _click_autocomplete(root, text):
    """"""
    try:
        parts = shlex.split(text)
    except ValueError:
        raise StopIteration

    location, incomplete = _click_resolve_command(root, parts)

    if not text.endswith(' ') and not incomplete and text:
        raise StopIteration

    if incomplete and not incomplete[0:2].isalnum():
        for param in location.params:
            if not isinstance(param, click.Option):
                continue
            for opt in itertools.chain(param.opts, param.secondary_opts):
                if opt.startswith(incomplete):
                    yield completion.Completion(opt, -len(incomplete), display_meta=param.help)

    elif isinstance(location, (click.MultiCommand, click.core.Group)):
        ctx = click.Context(location)
        commands = location.list_commands(ctx)
        for command in commands:
            if command.startswith(incomplete):
                cmd = location.get_command(ctx, command)
                yield completion.Completion(command, -len(incomplete), display_meta=cmd.short_help)
597621
public function render(Autocomplete $autocomplete)
    {
        $attributes = [
            'id'           => $autocomplete->getHtmlId(),
            'type'         => 'text',
            'autocomplete' => 'off',
        ];

        if ($autocomplete->hasValue()) {
            $attributes['value'] = $autocomplete->getValue();
        }

        return $this->getTagRenderer()->render('input', null, array_merge(
            $attributes,
            $autocomplete->getInputAttributes()
        ));
    }
278722
public function getAutocompleteKey()
    {
        if (false === $this->isAutocomplete()) {
            return null;
        }
        return $this->getFilter(self::FILTER_AUTOCOMPLETE)[self::FILTER_AUTOCOMPLETE_KEY];
    }
1149788
private function checkInput()
    {
        $actions = $this->getAllowedActions();
        $pendingActionName = 'check' . $actions[$this->options['action']].'Input';
        if (method_exists($this, $pendingActionName)) {
            return $this->$pendingActionName();
        }
    }
651905
public function AutoComplete() {
      $this->DeliveryType(DELIVERY_TYPE_NONE);
      $Q = GetIncomingValue('q');
      $UserModel = new UserModel();
      $Data = $UserModel->GetLike(array('u.Name' => $Q), 'u.Name', 'asc', 10, 0);
      foreach ($Data->Result() as $User) {
         echo htmlspecialchars($User->Name).'|'.Gdn_Format::Text($User->UserID)."\n";
      }
      $this->Render();
   }
1016354
protected function matchText()
    {
        return ReplyRuleKeyword::find()
            ->keyword($this->message['Content'])
            ->wechatRule($this->getWechat()->id)
            ->limitTime(TIMESTAMP)
            ->all();
    }
775692
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        $parser->setDescription(
            'Used by shells like bash to autocomplete command name, options and arguments'
        )->addSubcommand('commands', [
            'help' => 'Output a list of available commands',
            'parser' => [
                'description' => 'List all available',
            ]
        ])->addSubcommand('subcommands', [
            'help' => 'Output a list of available subcommands',
            'parser' => [
                'description' => 'List subcommands for a command',
                'arguments' => [
                    'command' => [
                        'help' => 'The command name',
                        'required' => false,
                    ]
                ]
            ]
        ])->addSubcommand('options', [
            'help' => 'Output a list of available options',
            'parser' => [
                'description' => 'List options',
                'arguments' => [
                    'command' => [
                        'help' => 'The command name',
                        'required' => false,
                    ],
                    'subcommand' => [
                        'help' => 'The subcommand name',
                        'required' => false,
                    ]
                ]
            ]
        ])->addSubcommand('fuzzy', [
            'help' => 'Guess autocomplete'
        ])->setEpilog([
            'This command is not intended to be called manually',
        ]);

        return $parser;
    }