json serialize_decl(name const & short_name, name const & long_name, environment const & env, options const & o) { declaration const & d = env.get(long_name); type_context_old tc(env); auto fmter = mk_pretty_formatter_factory()(env, o, tc); expr type = d.get_type(); if (LEAN_COMPLETE_CONSUME_IMPLICIT) { while (true) { if (!is_pi(type)) break; if (!binding_info(type).is_implicit() && !binding_info(type).is_inst_implicit()) break; std::string q("?"); q += binding_name(type).to_string(); expr m = mk_constant(name(q.c_str())); type = instantiate(binding_body(type), m); } } json completion; completion["text"] = short_name.to_string(); interactive_report_type(env, o, type, completion); add_source_info(env, long_name, completion); if (auto doc = get_doc_string(env, long_name)) completion["doc"] = *doc; return completion; }
std::string find_file(search_path const & paths, std::string const & base, optional<unsigned> const & rel, name const & fname, std::initializer_list<char const *> const & extensions) { if (!rel) { return find_file(paths, fname.to_string(get_dir_sep()), extensions); } else { auto path = base; for (unsigned i = 0; i < *rel; i++) { path += get_dir_sep(); path += ".."; } for (auto ext : extensions) { if (auto r = check_file(path, fname.to_string(get_dir_sep()), ext)) return *r; } throw lean_file_not_found_exception(fname.to_string()); } }
std::string find_file(std::string const & base, optional<unsigned> const & rel, name const & fname, std::initializer_list<char const *> const & extensions) { if (!rel) { return find_file(fname.to_string(g_sep_str.c_str()), extensions); } else { auto path = base; for (unsigned i = 0; i < *rel; i++) { path += g_sep; path += ".."; } for (auto ext : extensions) { if (auto r = check_file(path, fname.to_string(g_sep_str.c_str()), ext)) return *r; } throw exception(sstream() << "file '" << fname << "' not found at '" << path << "'"); } }
static unsigned get_precedence(environment const & env, buffer<token_entry> const & new_tokens, name const & token) { std::string token_str = token.to_string(); for (auto const & e : new_tokens) { if (e.m_token == token_str) return e.m_prec; } auto prec = get_expr_precedence(get_token_table(env), token_str.c_str()); if (prec) return *prec; else return 0; }
virtual void report(io_state_stream const & ios, json & record) const override { record["full-id"] = m_full_id.to_string(); add_source_info(ios.get_environment(), m_full_id, record); if (auto doc = get_doc_string(ios.get_environment(), m_full_id)) record["doc"] = *doc; }
std::string find_file(search_path const & paths, name const & fname, std::initializer_list<char const *> const & exts) { return find_file(paths, fname.to_string(get_dir_sep()), exts); }
std::string find_file(search_path const & paths, name const & fname) { return find_file(paths, fname.to_string(get_dir_sep())); }
std::string name_to_file(name const & fname) { return fname.to_string(get_dir_sep()); }
std::string find_file(name const & fname, std::initializer_list<char const *> const & exts) { return find_file(fname.to_string(g_sep_str), exts); }
std::string find_file(name const & fname) { return find_file(fname.to_string(g_sep_str)); }
std::string name_to_file(name const & fname) { return fname.to_string(g_sep_str); }