nushell/tests/commands
Yehuda Katz 7efb31a4e4 Restructure and streamline token expansion (#1123)
Restructure and streamline token expansion

The purpose of this commit is to streamline the token expansion code, by
removing aspects of the code that are no longer relevant, removing
pointless duplication, and eliminating the need to pass the same
arguments to `expand_syntax`.

The first big-picture change in this commit is that instead of a handful
of `expand_` functions, which take a TokensIterator and ExpandContext, a
smaller number of methods on the `TokensIterator` do the same job.

The second big-picture change in this commit is fully eliminating the
coloring traits, making coloring a responsibility of the base expansion
implementations. This also means that the coloring tracer is merged into
the expansion tracer, so you can follow a single expansion and see how
the expansion process produced colored tokens.

One side effect of this change is that the expander itself is marginally
more error-correcting. The error correction works by switching from
structured expansion to `BackoffColoringMode` when an unexpected token
is found, which guarantees that all spans of the source are colored, but
may not be the most optimal error recovery strategy.

That said, because `BackoffColoringMode` only extends as far as a
closing delimiter (`)`, `]`, `}`) or pipe (`|`), it does result in
fairly granular correction strategy.

The current code still produces an `Err` (plus a complete list of
colored shapes) from the parsing process if any errors are encountered,
but this could easily be addressed now that the underlying expansion is
error-correcting.

This commit also colors any spans that are syntax errors in red, and
causes the parser to include some additional information about what
tokens were expected at any given point where an error was encountered,
so that completions and hinting could be more robust in the future.

Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
Co-authored-by: Andrés N. Robalino <andres@androbtech.com>
2020-01-21 17:45:03 -05:00
..
append.rs Get error message improvements. (#1185) 2020-01-10 10:44:24 -05:00
cd.rs More ununwraps (#1152) 2020-01-03 06:51:20 +13:00
compact.rs More renames 2019-12-18 07:54:39 +13:00
cp.rs More renames 2019-12-18 07:54:39 +13:00
default.rs More renames 2019-12-18 07:54:39 +13:00
edit.rs More renames 2019-12-18 07:54:39 +13:00
enter.rs More renames 2019-12-18 07:54:39 +13:00
first.rs More renames 2019-12-18 07:54:39 +13:00
format.rs More renames 2019-12-18 07:54:39 +13:00
get.rs Get error message improvements. (#1185) 2020-01-10 10:44:24 -05:00
group_by.rs More renames 2019-12-18 07:54:39 +13:00
histogram.rs More renames 2019-12-18 07:54:39 +13:00
insert.rs More renames 2019-12-18 07:54:39 +13:00
last.rs More renames 2019-12-18 07:54:39 +13:00
lines.rs More renames 2019-12-18 07:54:39 +13:00
ls.rs Add ctrl_c to RunnablePerItemContext. (#1239) 2020-01-19 15:25:07 +13:00
mkdir.rs More renames 2019-12-18 07:54:39 +13:00
mod.rs Get error message improvements. (#1185) 2020-01-10 10:44:24 -05:00
mv.rs More renames 2019-12-18 07:54:39 +13:00
nth.rs This commit is the continuing phase of extracting functionality to subcrates. We extract test helpers and begin to change Nu shell's test organization along with it. 2019-12-15 11:34:58 -05:00
open.rs Restructure and streamline token expansion (#1123) 2020-01-21 17:45:03 -05:00
parse.rs Get error message improvements. (#1185) 2020-01-10 10:44:24 -05:00
pick.rs Restructure and streamline token expansion (#1123) 2020-01-21 17:45:03 -05:00
prepend.rs Get error message improvements. (#1185) 2020-01-10 10:44:24 -05:00
range.rs More renames 2019-12-18 07:54:39 +13:00
reverse.rs More renames 2019-12-18 07:54:39 +13:00
rm.rs More renames 2019-12-18 07:54:39 +13:00
save.rs More renames 2019-12-18 07:54:39 +13:00
sort_by.rs Add support for primitive values to sort-by (#1241) 2020-01-20 08:08:36 +13:00
split_by.rs More renames 2019-12-18 07:54:39 +13:00
split_column.rs More renames 2019-12-18 07:54:39 +13:00
uniq.rs Allow ColumnPaths when picking tables. (#1191) 2020-01-11 01:45:09 -05:00
where_.rs Get error message improvements. (#1185) 2020-01-10 10:44:24 -05:00
wrap.rs More renames 2019-12-18 07:54:39 +13:00