mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
Shell: Mark And and Or nodes as execute nodes
This commit is contained in:
parent
3a37e8c56f
commit
d2bdbc3e77
Notes:
sideshowbarker
2024-07-19 05:09:02 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/d2bdbc3e775 Pull-request: https://github.com/SerenityOS/serenity/pull/2542 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/bugaevc
3 changed files with 9 additions and 3 deletions
|
@ -688,6 +688,9 @@ RefPtr<Value> Execute::run(RefPtr<Shell> shell)
|
|||
{
|
||||
RefPtr<Job> job;
|
||||
|
||||
if (m_command->would_execute())
|
||||
return m_command->run(shell);
|
||||
|
||||
auto initial_commands = m_command->run(shell)->resolve_as_commands(shell);
|
||||
decltype(initial_commands) commands;
|
||||
|
||||
|
|
|
@ -330,6 +330,7 @@ public:
|
|||
virtual bool is_syntax_error() const { return m_is_syntax_error; }
|
||||
|
||||
virtual bool is_list() const { return false; }
|
||||
virtual bool would_execute() const { return false; }
|
||||
|
||||
const Position& position() const { return m_position; }
|
||||
void set_is_syntax_error() { m_is_syntax_error = true; }
|
||||
|
@ -365,6 +366,7 @@ private:
|
|||
virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override;
|
||||
virtual HitTestResult hit_test_position(size_t) override;
|
||||
virtual String class_name() const override { return "And"; }
|
||||
virtual bool would_execute() const override { return true; }
|
||||
|
||||
RefPtr<Node> m_left;
|
||||
RefPtr<Node> m_right;
|
||||
|
@ -585,6 +587,7 @@ private:
|
|||
virtual Vector<Line::CompletionSuggestion> complete_for_editor(Shell&, size_t, RefPtr<Node> matching_node) override;
|
||||
virtual String class_name() const override { return "Execute"; }
|
||||
virtual bool is_execute() const override { return true; }
|
||||
virtual bool would_execute() const override { return true; }
|
||||
|
||||
RefPtr<Node> m_command;
|
||||
bool m_capture_stdout { false };
|
||||
|
@ -619,7 +622,7 @@ private:
|
|||
virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override;
|
||||
virtual HitTestResult hit_test_position(size_t) override;
|
||||
virtual String class_name() const override { return "Or"; }
|
||||
virtual bool is_list() const override { return true; }
|
||||
virtual bool would_execute() const override { return true; }
|
||||
|
||||
RefPtr<Node> m_left;
|
||||
RefPtr<Node> m_right;
|
||||
|
|
|
@ -161,7 +161,7 @@ RefPtr<AST::Node> Parser::parse_sequence()
|
|||
if (peek() == '&') {
|
||||
consume();
|
||||
if (auto expr = parse_sequence()) {
|
||||
return create<AST::And>(move(execute_pipe_seq), move(expr)); // And
|
||||
return create<AST::And>(move(execute_pipe_seq), create<AST::Execute>(move(expr))); // And
|
||||
}
|
||||
return execute_pipe_seq;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ RefPtr<AST::Node> Parser::parse_sequence()
|
|||
}
|
||||
consume();
|
||||
if (auto expr = parse_sequence()) {
|
||||
return create<AST::Or>(move(execute_pipe_seq), move(expr)); // Or
|
||||
return create<AST::Or>(move(execute_pipe_seq), create<AST::Execute>(move(expr))); // Or
|
||||
}
|
||||
putback();
|
||||
return execute_pipe_seq;
|
||||
|
|
Loading…
Add table
Reference in a new issue