From afc10970235589007449fb8400ad9e58916de683 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Tue, 2 Mar 2021 09:35:04 +0330 Subject: [PATCH] Shell: Make Node::hit_test_position() const --- Userland/Shell/AST.cpp | 52 +++++++++++++++++++-------------------- Userland/Shell/AST.h | 56 +++++++++++++++++++++--------------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index 376c3c7f6fe..9627453134e 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -303,7 +303,7 @@ void And::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetad m_right->highlight_in_editor(editor, shell, metadata); } -HitTestResult And::hit_test_position(size_t offset) +HitTestResult And::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -409,7 +409,7 @@ void ListConcatenate::highlight_in_editor(Line::Editor& editor, Shell& shell, Hi } } -HitTestResult ListConcatenate::hit_test_position(size_t offset) +HitTestResult ListConcatenate::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -471,7 +471,7 @@ void Background::highlight_in_editor(Line::Editor& editor, Shell& shell, Highlig m_command->highlight_in_editor(editor, shell, metadata); } -HitTestResult Background::hit_test_position(size_t offset) +HitTestResult Background::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -566,7 +566,7 @@ RefPtr BraceExpansion::run(RefPtr shell) return create(move(values)); } -HitTestResult BraceExpansion::hit_test_position(size_t offset) +HitTestResult BraceExpansion::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -631,7 +631,7 @@ void CastToCommand::highlight_in_editor(Line::Editor& editor, Shell& shell, High m_inner->highlight_in_editor(editor, shell, metadata); } -HitTestResult CastToCommand::hit_test_position(size_t offset) +HitTestResult CastToCommand::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -713,7 +713,7 @@ void CastToList::highlight_in_editor(Line::Editor& editor, Shell& shell, Highlig m_inner->highlight_in_editor(editor, shell, metadata); } -HitTestResult CastToList::hit_test_position(size_t offset) +HitTestResult CastToList::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -867,7 +867,7 @@ void DoubleQuotedString::highlight_in_editor(Line::Editor& editor, Shell& shell, m_inner->highlight_in_editor(editor, shell, metadata); } -HitTestResult DoubleQuotedString::hit_test_position(size_t offset) +HitTestResult DoubleQuotedString::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -915,7 +915,7 @@ void DynamicEvaluate::highlight_in_editor(Line::Editor& editor, Shell& shell, Hi m_inner->highlight_in_editor(editor, shell, metadata); } -HitTestResult DynamicEvaluate::hit_test_position(size_t offset) +HitTestResult DynamicEvaluate::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -1003,7 +1003,7 @@ void FunctionDeclaration::highlight_in_editor(Line::Editor& editor, Shell& shell m_block->highlight_in_editor(editor, shell, metadata); } -HitTestResult FunctionDeclaration::hit_test_position(size_t offset) +HitTestResult FunctionDeclaration::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -1155,7 +1155,7 @@ void ForLoop::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightM m_block->highlight_in_editor(editor, shell, metadata); } -HitTestResult ForLoop::hit_test_position(size_t offset) +HitTestResult ForLoop::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -1554,7 +1554,7 @@ void Execute::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightM m_command->highlight_in_editor(editor, shell, metadata); } -HitTestResult Execute::hit_test_position(size_t offset) +HitTestResult Execute::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -1648,7 +1648,7 @@ void IfCond::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMe m_false_branch->highlight_in_editor(editor, shell, metadata); } -HitTestResult IfCond::hit_test_position(size_t offset) +HitTestResult IfCond::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -1729,7 +1729,7 @@ void Join::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMeta m_right->highlight_in_editor(editor, shell, metadata); } -HitTestResult Join::hit_test_position(size_t offset) +HitTestResult Join::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -1891,7 +1891,7 @@ void MatchExpr::highlight_in_editor(Line::Editor& editor, Shell& shell, Highligh } } -HitTestResult MatchExpr::hit_test_position(size_t offset) +HitTestResult MatchExpr::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -1956,7 +1956,7 @@ void Or::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetada m_right->highlight_in_editor(editor, shell, metadata); } -HitTestResult Or::hit_test_position(size_t offset) +HitTestResult Or::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2035,7 +2035,7 @@ void Pipe::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMeta m_right->highlight_in_editor(editor, shell, metadata); } -HitTestResult Pipe::hit_test_position(size_t offset) +HitTestResult Pipe::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2094,7 +2094,7 @@ void PathRedirectionNode::highlight_in_editor(Line::Editor& editor, Shell& shell } } -HitTestResult PathRedirectionNode::hit_test_position(size_t offset) +HitTestResult PathRedirectionNode::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2209,7 +2209,7 @@ void Range::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMet m_end->highlight_in_editor(editor, shell, metadata); } -HitTestResult Range::hit_test_position(size_t offset) +HitTestResult Range::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2332,7 +2332,7 @@ void Sequence::highlight_in_editor(Line::Editor& editor, Shell& shell, Highlight entry.highlight_in_editor(editor, shell, metadata); } -HitTestResult Sequence::hit_test_position(size_t offset) +HitTestResult Sequence::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2388,7 +2388,7 @@ void Subshell::highlight_in_editor(Line::Editor& editor, Shell& shell, Highlight m_block->highlight_in_editor(editor, shell, metadata); } -HitTestResult Subshell::hit_test_position(size_t offset) +HitTestResult Subshell::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2430,7 +2430,7 @@ void SimpleVariable::highlight_in_editor(Line::Editor& editor, Shell&, Highlight editor.stylize({ m_position.start_offset, m_position.end_offset }, move(style)); } -HitTestResult SimpleVariable::hit_test_position(size_t offset) +HitTestResult SimpleVariable::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2486,7 +2486,7 @@ Vector SpecialVariable::complete_for_editor(Shell&, return {}; } -HitTestResult SpecialVariable::hit_test_position(size_t offset) +HitTestResult SpecialVariable::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2602,7 +2602,7 @@ Vector Juxtaposition::complete_for_editor(Shell& she return Node::complete_for_editor(shell, offset, hit_test_result); } -HitTestResult Juxtaposition::hit_test_position(size_t offset) +HitTestResult Juxtaposition::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2691,7 +2691,7 @@ void StringPartCompose::highlight_in_editor(Line::Editor& editor, Shell& shell, m_right->highlight_in_editor(editor, shell, metadata); } -HitTestResult StringPartCompose::hit_test_position(size_t offset) +HitTestResult StringPartCompose::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2769,7 +2769,7 @@ void Tilde::highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata) { } -HitTestResult Tilde::hit_test_position(size_t offset) +HitTestResult Tilde::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; @@ -2900,7 +2900,7 @@ void VariableDeclarations::highlight_in_editor(Line::Editor& editor, Shell& shel } } -HitTestResult VariableDeclarations::hit_test_position(size_t offset) +HitTestResult VariableDeclarations::hit_test_position(size_t offset) const { if (!position().contains(offset)) return {}; diff --git a/Userland/Shell/AST.h b/Userland/Shell/AST.h index 1497f258d27..c5919b846ec 100644 --- a/Userland/Shell/AST.h +++ b/Userland/Shell/AST.h @@ -408,7 +408,7 @@ public: virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) = 0; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&); Vector complete_for_editor(Shell& shell, size_t offset); - virtual HitTestResult hit_test_position(size_t offset) + virtual HitTestResult hit_test_position(size_t offset) const { if (m_position.contains(offset)) return { this, nullptr, nullptr }; @@ -513,7 +513,7 @@ public: virtual ~PathRedirectionNode(); virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&) override; - virtual HitTestResult hit_test_position(size_t offset) override; + virtual HitTestResult hit_test_position(size_t offset) const override; virtual bool is_command() const override { return true; } virtual bool is_list() const override { return true; } virtual void visit(NodeVisitor& visitor) override { visitor.visit(this); } @@ -541,7 +541,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; NonnullRefPtr m_left; NonnullRefPtr m_right; @@ -561,7 +561,7 @@ private: virtual void for_each_entry(RefPtr shell, Function)> callback) override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_list() const override { return true; } virtual RefPtr leftmost_trivial_literal() const override; @@ -581,7 +581,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; NonnullRefPtr m_command; }; @@ -618,7 +618,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; NonnullRefPtrVector m_entries; }; @@ -636,7 +636,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&) override; virtual bool is_command() const override { return true; } virtual bool is_list() const override { return true; } @@ -659,7 +659,7 @@ private: virtual RefPtr run(RefPtr) override; virtual void for_each_entry(RefPtr shell, Function)> callback) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_list() const override { return true; } virtual RefPtr leftmost_trivial_literal() const override; @@ -759,7 +759,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_bareword() const override { return m_inner->is_bareword(); } virtual bool is_command() const override { return is_list(); } @@ -786,7 +786,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; RefPtr m_inner; }; @@ -830,7 +830,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&) override; virtual bool would_execute() const override { return true; } virtual bool should_override_execution_in_current_process() const override { return true; } @@ -856,7 +856,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool would_execute() const override { return true; } virtual bool should_override_execution_in_current_process() const override { return true; } @@ -959,7 +959,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&) override; virtual bool is_execute() const override { return true; } virtual bool would_execute() const override { return true; } @@ -984,7 +984,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool should_override_execution_in_current_process() const override { return true; } NonnullRefPtr m_condition; @@ -1008,7 +1008,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_command() const override { return true; } virtual bool is_list() const override { return true; } virtual RefPtr leftmost_trivial_literal() const override; @@ -1041,7 +1041,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool would_execute() const override { return true; } virtual bool should_override_execution_in_current_process() const override { return true; } @@ -1066,7 +1066,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; NonnullRefPtr m_left; NonnullRefPtr m_right; @@ -1087,7 +1087,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_command() const override { return true; } NonnullRefPtr m_left; @@ -1108,7 +1108,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; NonnullRefPtr m_start; NonnullRefPtr m_end; @@ -1153,7 +1153,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_list() const override { return true; } virtual bool should_override_execution_in_current_process() const override { return true; } @@ -1174,7 +1174,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool would_execute() const override { return false; } virtual bool should_override_execution_in_current_process() const override { return true; } @@ -1195,7 +1195,7 @@ private: virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_simple_variable() const override { return true; } String m_name; @@ -1215,7 +1215,7 @@ private: virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; char m_name { -1 }; }; @@ -1234,7 +1234,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&) override; NonnullRefPtr m_left; @@ -1273,7 +1273,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; NonnullRefPtr m_left; NonnullRefPtr m_right; @@ -1293,7 +1293,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override { return { nullptr, nullptr, nullptr }; } + virtual HitTestResult hit_test_position(size_t) const override { return { nullptr, nullptr, nullptr }; } virtual bool is_syntax_error() const override { return true; } virtual const SyntaxError& syntax_error_node() const override; @@ -1315,7 +1315,7 @@ private: virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual Vector complete_for_editor(Shell&, size_t, const HitTestResult&) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_tilde() const override { return true; } String m_username; @@ -1338,7 +1338,7 @@ private: virtual void dump(int level) const override; virtual RefPtr run(RefPtr) override; virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; - virtual HitTestResult hit_test_position(size_t) override; + virtual HitTestResult hit_test_position(size_t) const override; virtual bool is_variable_decls() const override { return true; } Vector m_variables;