mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 23:47:25 +00:00
Eliminate parser_type_t
It was never fully implemented and wasn't used for anything
This commit is contained in:
parent
584cca59bf
commit
cbd3fa6b01
4 changed files with 19 additions and 38 deletions
|
@ -986,17 +986,22 @@ void completer_t::complete_from_args(const wcstring &str,
|
|||
complete_flags_t flags)
|
||||
{
|
||||
bool is_autosuggest = (this->type() == COMPLETE_AUTOSUGGEST);
|
||||
parser_t parser(is_autosuggest ? PARSER_TYPE_COMPLETIONS_ONLY : PARSER_TYPE_GENERAL, false /* don't show errors */);
|
||||
parser_t parser(false /* don't show errors */);
|
||||
|
||||
/* If type is COMPLETE_AUTOSUGGEST, it means we're on a background thread, so don't call proc_push_interactive */
|
||||
if (! is_autosuggest)
|
||||
{
|
||||
proc_push_interactive(0);
|
||||
}
|
||||
|
||||
expand_flags_t eflags = is_autosuggest ? EXPAND_SKIP_CMDSUBST : 0;
|
||||
std::vector<completion_t> possible_comp;
|
||||
parser.expand_argument_list(args, &possible_comp);
|
||||
parser.expand_argument_list(args, eflags, &possible_comp);
|
||||
|
||||
if (! is_autosuggest)
|
||||
{
|
||||
proc_pop_interactive();
|
||||
}
|
||||
|
||||
this->complete_strings(escape_string(str, ESCAPE_ALL), desc.c_str(), 0, possible_comp, flags);
|
||||
}
|
||||
|
|
|
@ -593,7 +593,7 @@ static void test_parser()
|
|||
{
|
||||
say(L"Testing parser");
|
||||
|
||||
parser_t parser(PARSER_TYPE_GENERAL, true);
|
||||
parser_t parser(true);
|
||||
|
||||
say(L"Testing block nesting");
|
||||
if (!parse_util_detect_errors(L"if; end"))
|
||||
|
@ -776,7 +776,7 @@ static void test_parser()
|
|||
|
||||
say(L"Testing eval_args");
|
||||
completion_list_t comps;
|
||||
parser_t::principal_parser().expand_argument_list(L"alpha 'beta gamma' delta", &comps);
|
||||
parser_t::principal_parser().expand_argument_list(L"alpha 'beta gamma' delta", 0, &comps);
|
||||
do_test(comps.size() == 3);
|
||||
do_test(comps.at(0).completion == L"alpha");
|
||||
do_test(comps.at(1).completion == L"beta gamma");
|
||||
|
@ -1954,7 +1954,7 @@ static void test_is_potential_path()
|
|||
int builtin_test(parser_t &parser, io_streams_t &streams, wchar_t **argv);
|
||||
static bool run_one_test_test(int expected, wcstring_list_t &lst, bool bracket)
|
||||
{
|
||||
parser_t parser(PARSER_TYPE_GENERAL, true);
|
||||
parser_t parser(true);
|
||||
size_t i, count = lst.size();
|
||||
wchar_t **argv = new wchar_t *[count+3];
|
||||
argv[0] = (wchar_t *)(bracket ? L"[" : L"test");
|
||||
|
@ -1993,7 +1993,7 @@ static bool run_test_test(int expected, const wcstring &str)
|
|||
static void test_test_brackets()
|
||||
{
|
||||
// Ensure [ knows it needs a ]
|
||||
parser_t parser(PARSER_TYPE_GENERAL, true);
|
||||
parser_t parser(true);
|
||||
io_streams_t streams;
|
||||
|
||||
const wchar_t *argv1[] = {L"[", L"foo", NULL};
|
||||
|
@ -4116,7 +4116,7 @@ static void test_wcstring_tok(void)
|
|||
int builtin_string(parser_t &parser, io_streams_t &streams, wchar_t **argv);
|
||||
static void run_one_string_test(const wchar_t **argv, int expected_rc, const wchar_t *expected_out)
|
||||
{
|
||||
parser_t parser(PARSER_TYPE_GENERAL, true);
|
||||
parser_t parser(true);
|
||||
io_streams_t streams;
|
||||
streams.stdin_is_directly_redirected = false; // read from argv instead of stdin
|
||||
int rc = builtin_string(parser, streams, const_cast<wchar_t**>(argv));
|
||||
|
|
|
@ -162,8 +162,7 @@ static wcstring user_presentable_path(const wcstring &path)
|
|||
}
|
||||
|
||||
|
||||
parser_t::parser_t(enum parser_type_t type, bool errors) :
|
||||
parser_type(type),
|
||||
parser_t::parser_t(bool errors) :
|
||||
show_errors(errors),
|
||||
cancellation_requested(false),
|
||||
is_within_fish_initialization(false)
|
||||
|
@ -177,7 +176,7 @@ parser_t &parser_t::principal_parser(void)
|
|||
{
|
||||
ASSERT_IS_NOT_FORKED_CHILD();
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
static parser_t parser(PARSER_TYPE_GENERAL, true);
|
||||
static parser_t parser(true);
|
||||
if (! s_principal_parser)
|
||||
{
|
||||
s_principal_parser = &parser;
|
||||
|
@ -467,20 +466,11 @@ void parser_t::emit_profiling(const char *path) const
|
|||
}
|
||||
}
|
||||
|
||||
void parser_t::expand_argument_list(const wcstring &arg_list_src, std::vector<completion_t> *output_arg_list)
|
||||
void parser_t::expand_argument_list(const wcstring &arg_list_src, expand_flags_t eflags, std::vector<completion_t> *output_arg_list)
|
||||
{
|
||||
assert(output_arg_list != NULL);
|
||||
expand_flags_t eflags = 0;
|
||||
if (! show_errors)
|
||||
eflags |= EXPAND_NO_DESCRIPTIONS;
|
||||
if (this->parser_type != PARSER_TYPE_GENERAL)
|
||||
eflags |= EXPAND_SKIP_CMDSUBST;
|
||||
|
||||
/* Suppress calling proc_push_interactive off of the main thread. */
|
||||
if (this->parser_type == PARSER_TYPE_GENERAL)
|
||||
{
|
||||
proc_push_interactive(0);
|
||||
}
|
||||
|
||||
/* Parse the string as an argument list */
|
||||
parse_node_tree_t tree;
|
||||
|
@ -509,11 +499,6 @@ void parser_t::expand_argument_list(const wcstring &arg_list_src, std::vector<co
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this->parser_type == PARSER_TYPE_GENERAL)
|
||||
{
|
||||
proc_pop_interactive();
|
||||
}
|
||||
}
|
||||
|
||||
wcstring parser_t::stack_trace() const
|
||||
|
|
17
src/parser.h
17
src/parser.h
|
@ -14,6 +14,7 @@
|
|||
#include "parse_tree.h"
|
||||
#include "io.h"
|
||||
#include "parse_constants.h"
|
||||
#include "expand.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -202,15 +203,6 @@ enum parser_error
|
|||
CMDSUBST_ERROR,
|
||||
};
|
||||
|
||||
enum parser_type_t
|
||||
{
|
||||
PARSER_TYPE_NONE,
|
||||
PARSER_TYPE_GENERAL,
|
||||
PARSER_TYPE_FUNCTIONS_ONLY,
|
||||
PARSER_TYPE_COMPLETIONS_ONLY,
|
||||
PARSER_TYPE_ERRORS_ONLY
|
||||
};
|
||||
|
||||
struct profile_item_t
|
||||
{
|
||||
/** Time spent executing the specified command, including parse time for nested blocks. */
|
||||
|
@ -236,8 +228,6 @@ class parser_t
|
|||
{
|
||||
friend class parse_execution_context_t;
|
||||
private:
|
||||
enum parser_type_t parser_type;
|
||||
|
||||
/** Whether or not we output errors */
|
||||
const bool show_errors;
|
||||
|
||||
|
@ -294,7 +284,7 @@ public:
|
|||
static void skip_all_blocks();
|
||||
|
||||
/** Create a parser of the given type */
|
||||
parser_t(enum parser_type_t type, bool show_errors);
|
||||
parser_t(bool show_errors);
|
||||
|
||||
/** Global event blocks */
|
||||
event_blockage_list_t global_event_blocks;
|
||||
|
@ -319,9 +309,10 @@ public:
|
|||
Errors are ignored.
|
||||
|
||||
\param arg_src String to evaluate as an argument list
|
||||
\param flags Some expand flags to use
|
||||
\param output List to insert output into
|
||||
*/
|
||||
void expand_argument_list(const wcstring &arg_src, std::vector<completion_t> *output);
|
||||
void expand_argument_list(const wcstring &arg_src, expand_flags_t flags, std::vector<completion_t> *output);
|
||||
|
||||
/**
|
||||
Returns a string describing the current parser pisition in the format 'FILENAME (line LINE_NUMBER): LINE'.
|
||||
|
|
Loading…
Reference in a new issue