Enable aliases autocomplete by injecting aliases into Azure CLI tab completion list.
439958
def enable_aliases_autocomplete(_, **kwargs):
    
    external_completions = kwargs.get('external_completions', [])
    prefix = kwargs.get('cword_prefix', [])
    cur_commands = kwargs.get('comp_words', [])
    alias_table = get_alias_table()
    # Transform aliases if they are in current commands,
    # so parser can get the correct subparser when chaining aliases
    _transform_cur_commands(cur_commands, alias_table=alias_table)

    for alias, alias_command in filter_aliases(alias_table):
        if alias.startswith(prefix) and alias.strip() != prefix and _is_autocomplete_valid(cur_commands, alias_command):
            # Only autocomplete the first word because alias is space-delimited
            external_completions.append(alias)

    # Append spaces if necessary (https://github.com/kislyuk/argcomplete/blob/master/argcomplete/__init__.py#L552-L559)
    prequote = kwargs.get('cword_prequote', '')
    continuation_chars = "=/:"
    if len(external_completions) == 1 and external_completions[0][-1] not in continuation_chars and not prequote:
        external_completions[0] += ' '
938264
def toggle_codecompletion(self, checked):
        """"""
        self.shell.set_codecompletion_auto(checked)
        self.set_option('codecompletion/auto', checked)
391394
public function autocomplete($attachTo=NULL, $params=NULL) {
		return $this->addComponent(new Autocomplete($this->js), $attachTo, $params);
	}
1189375
def users_autocomplete(self, name=None, **kwargs):
        ""
        api_path = "/api/v2/users/autocomplete.json"
        api_query = {}
        if "query" in kwargs.keys():
            api_query.update(kwargs["query"])
            del kwargs["query"]
        if name:
            api_query.update({
                "name": name,
            })
        return self.call(api_path, query=api_query, **kwargs)
107021
def setup_completion(shell):
    """"""

    # Handle special case of importing pyreadline on Windows
    # See: http://stackoverflow.com/questions/6024952/readline-functionality-on-windows-with-python-2-7
    import glob
    try:
        import readline
    except ImportError:
        import pyreadline as readline

    def _complete(text, state):
        buf = readline.get_line_buffer()
        if buf.startswith('help ') or " " not in buf:
            return [x for x in shell.valid_identifiers() if x.startswith(text)][state]

        return (glob.glob(os.path.expanduser(text)+'*')+[None])[state]

    readline.set_completer_delims(' \t\n;')
    # Handle Mac OS X special libedit based readline
    # See: http://stackoverflow.com/questions/7116038/python-tab-completion-mac-osx-10-7-lion
    if readline.__doc__ is not None and 'libedit' in readline.__doc__:
        readline.parse_and_bind("bind ^I rl_complete")
    else:
        readline.parse_and_bind("tab: complete")

    readline.set_completer(_complete)
840444
def get_commands_aliases_and_macros_for_completion(self) -> List[str]:
        """"""
        visible_commands = set(self.get_visible_commands())
        alias_names = set(self.get_alias_names())
        macro_names = set(self.get_macro_names())
        return list(visible_commands | alias_names | macro_names)
890470
def autocomplete(input_list):
  
  # We are only interested if the last token starts with a single '$'
  # Double $$'s indicate that it is meant to be a '$', so we don't do anything.
  if input_list[-1].startswith('$') and not input_list[-1].startswith('$$'):
    # Omit the '$'
    partial_variable = input_list[-1][1:]
    commands = []

    for variable in uservariables:
      # No need to include variables that don't match...
      if variable.startswith(partial_variable):
        # Reconstruct the string
        tokens = input_list[:-1] + ['$'+variable]
        commands.append(' '.join(tokens))
    return commands
  return []
1222721
function _getSuggestions(prefix) {
        let scriptContainer = document.getElementById('ac__script');
        let newScript = document.createElement('script');
        newScript.src = 'http://completion.amazon.com/search/complete?search-alias=aps&client=amazon-search-ui&mkt=1&q='+prefix+'&callback=AmazonAutocomplete.AmazonJSONPCallbackHandler_'+this._id;
        scriptContainer.replaceChild(newScript, scriptContainer.firstChild);
    }
137257
def completedefault(self, text, line, begidx, endidx):
        """"""
        if self.argparser_completer and any((line.startswith(x) for x in self.argparse_names())):
            self.argparser_completer.rl_complete(line, 0)
            return [x[begidx:] for x in self.argparser_completer._rl_matches]
        else:
            return []
47303
def execute(self, argv=None):
        
        if self.completion:
            self.autocomplete()
        parser = self.get_parser()
        namespace = parser.parse_args(argv)
        if hasattr(namespace, 'func'):
            self.run_command(namespace)
1190602
def find_completions_at_cursor(ast_tree, filename, line, col, root_env=gcl.default_env):
  
  q = gcl.SourceQuery(filename, line, col - 1)
  rootpath = ast_tree.find_tokens(q)

  if is_identifier_position(rootpath):
    return find_inherited_key_completions(rootpath, root_env)

  try:
    ret = find_deref_completions(rootpath, root_env) or enumerate_scope(rootpath, root_env=root_env)
    assert isinstance(ret, dict)
    return ret
  except gcl.EvaluationError:
    # Probably an unbound value or something--just return an empty list
    return {}
1306143
private void addAliasDefinition(AliasDefinition aliasDef) {
        // Prerequisites:
        assert aliasDef != null;
        assert !m_aliasDefMap.containsKey(aliasDef.getName());
        assert aliasDef.getTableName().equals(this.getTableName());
        
        m_aliasDefMap.put(aliasDef.getName(), aliasDef);
    }
1042653
protected function _applyAutocompleteOptions(&$input, $param)
    {
        if ($param instanceof AutocompleteParameter) {
            $input['data-url'] = $param->autocompleteUrl();
            $input['class'] = 'autocomplete';
            $input['data-name'] = $param->config('name');
        }

        return $input;
    }
521402
public List<CompletionProposal> complete(CompletionContext context) {

		String prefix = context.upToCursor();

		List<CompletionProposal> candidates = new ArrayList<>();
		candidates.addAll(commandsStartingWith(prefix));

		String best = findLongestCommand(prefix);
		if (best != null) {
			CompletionContext argsContext = context.drop(best.split(" ").length);
			// Try to complete arguments
			MethodTarget methodTarget = methodTargets.get(best);
			Method method = methodTarget.getMethod();

			List<MethodParameter> parameters = Utils.createMethodParameters(method).collect(Collectors.toList());
			for (ParameterResolver resolver : parameterResolvers) {
				for (int index = 0; index < parameters.size(); index++) {
					MethodParameter parameter = parameters.get(index);
					if (resolver.supports(parameter)) {
						resolver.complete(parameter, argsContext).stream().forEach(candidates::add);
					}
				}
			}
		}
		return candidates;
	}
153323
function Alias () {

  var home = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'],
      aliasFile = path.resolve(home + '/.pa/aliases.json');

  var writeAliases = function (aliases) {
    fs.writeFileSync(aliasFile, JSON.stringify(aliases, null, 2));
  };

  this.init = function () {
    if (!fs.existsSync(aliasFile)) {
      this.install();
    }
    this.aliases = require(aliasFile);
    return this;
  };

  this.install = function () {
    if (!fs.existsSync(path.resolve(home + '/.pa/'))) {
      fs.mkdirSync(path.resolve(home + '/.pa/'));
    }
    writeAliases(defaultAliases);
  };

  this.list = function () {
    var tmp, list = '';
    for (tmp in this.aliases) {
      list += '\n' + tmp + '=' + this.aliases[tmp];
    }
    return list.substr(1).green;
  };

  this.get = function (key) {
    var tmp;
    for (tmp in this.aliases) {
      if (this.aliases[tmp] === key) {
        return tmp.green;
      }
    }
    return ("no alias for '" + key + "'").red;
  };

  this.set = function (key, value) {
    this.aliases[key] = value;
    writeAliases(this.aliases);
    return ("set alias '" + key + "' for '" + value + "'").green;
  };

  this.trigger = function (argv) {
    if (typeof argv.alias !== 'string') {
      return this.list();
    }
    return argv._[0] ? this.set(argv._[0], argv.alias) : this.get(argv.alias);
  };

}
182636
public void setAutocomplete(java.lang.String autocomplete) {
        getStateHelper().put(PropertyKeys.autocomplete, autocomplete);
    }
117686
function linkAutoComplete() {
    return listFiles('autocomplete')
        .then(filter(endsWith('.js')) & map(path.join('autocomplete', _)))
        .tap(files => all(files.map(file => fs.readFileAsync(file)
            .then(ensureNoImports(file)))));
}