From 68a0e4f8d52c0705861b876c0f6189d09c905e19 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 2 May 2021 14:49:46 +0200 Subject: [PATCH] LibGUI+HackStudio: Remove editing specific hacks from GUI::Command Use is to check for specific types of command in HackStudio instead of cluttering up GUI::Command with specialized getters. --- Userland/DevTools/HackStudio/Editor.cpp | 8 ++++---- Userland/Libraries/LibGUI/Command.h | 3 --- Userland/Libraries/LibGUI/TextDocument.h | 2 -- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index cd144ded1e..10c56ea5d8 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -493,8 +493,8 @@ void Editor::on_edit_action(const GUI::Command& command) if (!m_language_client) return; - if (command.is_insert_text()) { - const GUI::InsertTextCommand& insert_command = static_cast(command); + if (is(command)) { + auto const& insert_command = static_cast(command); m_language_client->insert_text( code_document().file_path(), insert_command.text(), @@ -503,8 +503,8 @@ void Editor::on_edit_action(const GUI::Command& command) return; } - if (command.is_remove_text()) { - const GUI::RemoveTextCommand& remove_command = static_cast(command); + if (is(command)) { + auto const& remove_command = static_cast(command); m_language_client->remove_text( code_document().file_path(), remove_command.range().start().line(), diff --git a/Userland/Libraries/LibGUI/Command.h b/Userland/Libraries/LibGUI/Command.h index 0e4e025757..10d4a65cff 100644 --- a/Userland/Libraries/LibGUI/Command.h +++ b/Userland/Libraries/LibGUI/Command.h @@ -19,9 +19,6 @@ public: String action_text() const { return m_action_text; } - virtual bool is_insert_text() const { return false; } - virtual bool is_remove_text() const { return false; } - protected: Command() { } void set_action_text(const String& text) { m_action_text = text; } diff --git a/Userland/Libraries/LibGUI/TextDocument.h b/Userland/Libraries/LibGUI/TextDocument.h index d73f505799..0b11739244 100644 --- a/Userland/Libraries/LibGUI/TextDocument.h +++ b/Userland/Libraries/LibGUI/TextDocument.h @@ -206,7 +206,6 @@ public: virtual void perform_formatting(const TextDocument::Client&) override; virtual void undo() override; virtual void redo() override; - virtual bool is_insert_text() const override { return true; } const String& text() const { return m_text; } const TextRange& range() const { return m_range; } @@ -220,7 +219,6 @@ public: RemoveTextCommand(TextDocument&, const String&, const TextRange&); virtual void undo() override; virtual void redo() override; - virtual bool is_remove_text() const override { return true; } const TextRange& range() const { return m_range; } private: