mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-03 16:48:45 +00:00
Make function_add take the filename directly instead of a parser
This commit is contained in:
parent
b51edcfcac
commit
6d7a66592b
4 changed files with 5 additions and 6 deletions
|
@ -273,7 +273,7 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
|
||||||
d.props = props;
|
d.props = props;
|
||||||
d.events = std::move(opts.events);
|
d.events = std::move(opts.events);
|
||||||
|
|
||||||
function_add(std::move(d), parser);
|
function_add(std::move(d), parser.libdata().current_filename);
|
||||||
|
|
||||||
// Handle wrap targets by creating the appropriate completions.
|
// Handle wrap targets by creating the appropriate completions.
|
||||||
for (const wcstring &wt : opts.wrap_targets) complete_add_wrapper(function_name, wt);
|
for (const wcstring &wt : opts.wrap_targets) complete_add_wrapper(function_name, wt);
|
||||||
|
|
|
@ -2716,7 +2716,7 @@ static void test_complete() {
|
||||||
// body_node.
|
// body_node.
|
||||||
struct function_data_t func_data = {};
|
struct function_data_t func_data = {};
|
||||||
func_data.name = L"scuttlebutt";
|
func_data.name = L"scuttlebutt";
|
||||||
function_add(func_data, parser_t::principal_parser());
|
function_add(func_data, nullptr);
|
||||||
|
|
||||||
// Complete a function name.
|
// Complete a function name.
|
||||||
completions.clear();
|
completions.clear();
|
||||||
|
@ -2830,7 +2830,7 @@ static void test_complete() {
|
||||||
auto &pvars = parser_t::principal_parser().vars();
|
auto &pvars = parser_t::principal_parser().vars();
|
||||||
function_data_t fd;
|
function_data_t fd;
|
||||||
fd.name = L"testabbrsonetwothreefour";
|
fd.name = L"testabbrsonetwothreefour";
|
||||||
function_add(fd, parser_t::principal_parser());
|
function_add(fd, nullptr);
|
||||||
int ret = pvars.set_one(L"_fish_abbr_testabbrsonetwothreezero", ENV_LOCAL, L"expansion");
|
int ret = pvars.set_one(L"_fish_abbr_testabbrsonetwothreezero", ENV_LOCAL, L"expansion");
|
||||||
complete(L"testabbrsonetwothree", &completions, {}, pvars, parser);
|
complete(L"testabbrsonetwothree", &completions, {}, pvars, parser);
|
||||||
do_test(ret == 0);
|
do_test(ret == 0);
|
||||||
|
|
|
@ -148,7 +148,7 @@ function_info_t::function_info_t(function_properties_ref_t props, wcstring desc,
|
||||||
definition_file(intern(def_file)),
|
definition_file(intern(def_file)),
|
||||||
is_autoload(autoload) {}
|
is_autoload(autoload) {}
|
||||||
|
|
||||||
void function_add(const function_data_t &data, const parser_t &parser) {
|
void function_add(const function_data_t &data, const wchar_t *filename) {
|
||||||
ASSERT_IS_MAIN_THREAD();
|
ASSERT_IS_MAIN_THREAD();
|
||||||
auto funcset = function_set.acquire();
|
auto funcset = function_set.acquire();
|
||||||
|
|
||||||
|
@ -164,7 +164,6 @@ void function_add(const function_data_t &data, const parser_t &parser) {
|
||||||
bool is_autoload = funcset->autoloader.autoload_in_progress(data.name);
|
bool is_autoload = funcset->autoloader.autoload_in_progress(data.name);
|
||||||
|
|
||||||
// Create and store a new function.
|
// Create and store a new function.
|
||||||
const wchar_t *filename = parser.libdata().current_filename;
|
|
||||||
auto ins = funcset->funcs.emplace(
|
auto ins = funcset->funcs.emplace(
|
||||||
data.name, function_info_t(data.props, data.description, filename, is_autoload));
|
data.name, function_info_t(data.props, data.description, filename, is_autoload));
|
||||||
assert(ins.second && "Function should not already be present in the table");
|
assert(ins.second && "Function should not already be present in the table");
|
||||||
|
|
|
@ -51,7 +51,7 @@ struct function_data_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Add a function.
|
/// Add a function.
|
||||||
void function_add(const function_data_t &data, const parser_t &parser);
|
void function_add(const function_data_t &data, const wchar_t *filename);
|
||||||
|
|
||||||
/// Remove the function with the specified name.
|
/// Remove the function with the specified name.
|
||||||
void function_remove(const wcstring &name);
|
void function_remove(const wcstring &name);
|
||||||
|
|
Loading…
Reference in a new issue