lean4-htt/src/shell/completion.h
Leonardo de Moura c52be7e8c5 feat(frontends/lean,shell): autocompletion for ^.
@kha, I added autocompletion for ^. I try to elaborate the expression
before ^. using the local context provided by the parser.

The autocompletion only works if the type for the expression before ^. can be
inferred. This is a big limitation because this information cannot be
obtained in many cases. Here are examples that do not work:

  meta def proof_for (e : expr) : smt_tactic expr :=
  do cc ← to_cc_state, cc^.proof_for e
                         --^ does not work here

If we annotate cc with its type, it works:

  meta def proof_for (e : expr) : smt_tactic expr :=
  do cc : cc_state ← to_cc_state, cc^.proof_for e
                                    --^ works

We don't have typing information on the equation lhs at
autocompletion time. So, the following will not work

   private meta def mk_smt_goals_for (cfg : smt_config)
        : list expr → list smt_goal → list expr → tactic (list smt_goal × list expr)
   | []        sr tr := return (sr^.reverse, tr^.reverse)
                                  --^ does not work since
   | (tg::tgs) sr tr := ...
2017-01-17 19:27:59 -08:00

25 lines
1.3 KiB
C++

/*
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner, Leonardo de Moura, Sebastian Ullrich
*/
#pragma once
#include <string>
#include <vector>
#include "kernel/environment.h"
#include "util/sexpr/options.h"
#include "frontends/lean/json.h"
namespace lean {
std::vector<json> get_decl_completions(std::string const & pattern, environment const & env, options const & o);
std::vector<json> get_field_completions(name const & s, std::string const & pattern, environment const & env, options const & o);
std::vector<json> get_option_completions(std::string const & pattern, options const & opts);
pair<optional<unsigned>, std::string> parse_import(std::string s);
std::vector<json> get_import_completions(std::string const & pattern, std::string const & curr_dir,
options const & opts);
std::vector<json> get_interactive_tactic_completions(std::string const & pattern, name const & tac_class,
environment const & env, options const & opts);
std::vector<json> get_attribute_completions(std::string const & pattern, environment const & env, options const & opts);
std::vector<json> get_namespace_completions(std::string const & pattern, environment const & env, options const & opts);
}