Teach decoration_for_plain_statement about tnode, rename it get_decoration

This commit is contained in:
ridiculousfish
2018-01-13 16:43:12 -08:00
parent 84dcb24682
commit f0f56a6910
9 changed files with 29 additions and 41 deletions

View File

@@ -582,21 +582,17 @@ bool reader_expand_abbreviation_in_command(const wcstring &cmdline, size_t curso
// Look for plain statements where the cursor is at the end of the command.
using namespace grammar;
tnode_t<tok_string> matching_cmd_node;
const size_t len = parse_tree.size();
for (size_t i = 0; i < len; i++) {
const parse_node_t &node = parse_tree.at(i);
for (const parse_node_t &node : parse_tree) {
// Only interested in plain statements with source.
if (node.type != symbol_plain_statement || !node.has_source()) continue;
// Skip decorated statements.
if (parse_tree.decoration_for_plain_statement(node) != parse_statement_decoration_none)
continue;
// Get the command node. Skip it if we can't or it has no source.
tnode_t<plain_statement> statement(&parse_tree, &node);
tnode_t<tok_string> cmd_node = statement.child<0>();
// Skip decorated statements.
if (get_decoration(statement) != parse_statement_decoration_none) continue;
auto msource = cmd_node.source_range();
if (!msource) continue;