diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-04-01 20:58:27 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-04-01 21:24:45 +0100 |
commit | 086969277e74d8ba065bf8145d3aeb0dec0bfee5 (patch) | |
tree | 02b3699a66735ef806d9b46353491f18f8e4e7b4 /Userland/DevTools | |
parent | 0376c127f6e98e03607700d0b3f5154b7014b2f8 (diff) | |
download | serenity-086969277e74d8ba065bf8145d3aeb0dec0bfee5.zip |
Everywhere: Run clang-format
Diffstat (limited to 'Userland/DevTools')
92 files changed, 480 insertions, 480 deletions
diff --git a/Userland/DevTools/HackStudio/ClassViewWidget.cpp b/Userland/DevTools/HackStudio/ClassViewWidget.cpp index d620897308..ac1d9c1a32 100644 --- a/Userland/DevTools/HackStudio/ClassViewWidget.cpp +++ b/Userland/DevTools/HackStudio/ClassViewWidget.cpp @@ -46,7 +46,7 @@ int ClassViewModel::row_count(const GUI::ModelIndex& index) const GUI::Variant ClassViewModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const { - auto* node = static_cast<const ClassViewNode*>(index.internal_data()); + auto* node = static_cast<ClassViewNode const*>(index.internal_data()); switch (role) { case GUI::ModelRole::Display: { return node->name; @@ -68,7 +68,7 @@ GUI::ModelIndex ClassViewModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto* child = static_cast<const ClassViewNode*>(index.internal_data()); + auto* child = static_cast<ClassViewNode const*>(index.internal_data()); auto* parent = child->parent; if (parent == nullptr) return {}; @@ -92,7 +92,7 @@ GUI::ModelIndex ClassViewModel::index(int row, int column, const GUI::ModelIndex { if (!parent_index.is_valid()) return create_index(row, column, &m_root_scope[row]); - auto* parent = static_cast<const ClassViewNode*>(parent_index.internal_data()); + auto* parent = static_cast<ClassViewNode const*>(parent_index.internal_data()); auto* child = &parent->children[row]; return create_index(row, column, child); } diff --git a/Userland/DevTools/HackStudio/CodeDocument.cpp b/Userland/DevTools/HackStudio/CodeDocument.cpp index a8605c24a0..0ba3f46fd6 100644 --- a/Userland/DevTools/HackStudio/CodeDocument.cpp +++ b/Userland/DevTools/HackStudio/CodeDocument.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -NonnullRefPtr<CodeDocument> CodeDocument::create(const String& file_path, Client* client) +NonnullRefPtr<CodeDocument> CodeDocument::create(String const& file_path, Client* client) { return adopt_ref(*new CodeDocument(file_path, client)); } @@ -19,7 +19,7 @@ NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client) return adopt_ref(*new CodeDocument(client)); } -CodeDocument::CodeDocument(const String& file_path, Client* client) +CodeDocument::CodeDocument(String const& file_path, Client* client) : TextDocument(client) , m_file_path(file_path) { diff --git a/Userland/DevTools/HackStudio/CodeDocument.h b/Userland/DevTools/HackStudio/CodeDocument.h index 70a066f4b4..e496a9fa61 100644 --- a/Userland/DevTools/HackStudio/CodeDocument.h +++ b/Userland/DevTools/HackStudio/CodeDocument.h @@ -16,22 +16,22 @@ namespace HackStudio { class CodeDocument final : public GUI::TextDocument { public: virtual ~CodeDocument() override = default; - static NonnullRefPtr<CodeDocument> create(const String& file_path, Client* client = nullptr); + static NonnullRefPtr<CodeDocument> create(String const& file_path, Client* client = nullptr); static NonnullRefPtr<CodeDocument> create(Client* client = nullptr); - const Vector<size_t>& breakpoint_lines() const { return m_breakpoint_lines; } + Vector<size_t> const& breakpoint_lines() const { return m_breakpoint_lines; } Vector<size_t>& breakpoint_lines() { return m_breakpoint_lines; } Optional<size_t> execution_position() const { return m_execution_position; } void set_execution_position(size_t line) { m_execution_position = line; } void clear_execution_position() { m_execution_position.clear(); } - const String& file_path() const { return m_file_path; } - const String& language_name() const { return m_language_name; }; + String const& file_path() const { return m_file_path; } + String const& language_name() const { return m_language_name; }; Language language() const { return m_language; } virtual bool is_code_document() const override final { return true; } private: - explicit CodeDocument(const String& file_path, Client* client = nullptr); + explicit CodeDocument(String const& file_path, Client* client = nullptr); explicit CodeDocument(Client* client = nullptr); String m_file_path; diff --git a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp index 0ae6152e44..432dfbab1e 100644 --- a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp @@ -10,7 +10,7 @@ namespace HackStudio { -NonnullRefPtr<BacktraceModel> BacktraceModel::create(Debug::ProcessInspector const& inspector, const PtraceRegisters& regs) +NonnullRefPtr<BacktraceModel> BacktraceModel::create(Debug::ProcessInspector const& inspector, PtraceRegisters const& regs) { return adopt_ref(*new BacktraceModel(create_backtrace(inspector, regs))); } diff --git a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h index 4eefb54a89..74aedfc412 100644 --- a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h +++ b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h @@ -43,7 +43,7 @@ public: Optional<Debug::DebugInfo::SourcePosition> m_source_position; }; - const Vector<FrameInfo>& frames() const { return m_frames; } + Vector<FrameInfo> const& frames() const { return m_frames; } private: explicit BacktraceModel(Vector<FrameInfo>&& frames) diff --git a/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h b/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h index 45a3207c08..98d7b30edc 100644 --- a/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h +++ b/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h @@ -17,5 +17,5 @@ enum class BreakpointChange { Removed, }; -using BreakpointChangeCallback = Function<void(const String& file, size_t line, BreakpointChange)>; +using BreakpointChangeCallback = Function<void(String const& file, size_t line, BreakpointChange)>; } diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp index 997b8a91b2..4ff7c4148c 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -89,7 +89,7 @@ DebugInfoWidget::DebugInfoWidget() }; } -bool DebugInfoWidget::does_variable_support_writing(const Debug::DebugInfo::VariableInfo* variable) +bool DebugInfoWidget::does_variable_support_writing(Debug::DebugInfo::VariableInfo const* variable) { if (variable->location_type != Debug::DebugInfo::VariableInfo::LocationType::Address) return false; @@ -102,7 +102,7 @@ RefPtr<GUI::Menu> DebugInfoWidget::get_context_menu_for_variable(const GUI::Mode return nullptr; auto context_menu = GUI::Menu::construct(); - auto* variable = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto* variable = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); if (does_variable_support_writing(variable)) { context_menu->add_action(GUI::Action::create("Change value", [&](auto&) { String value; @@ -155,7 +155,7 @@ NonnullRefPtr<GUI::Widget> DebugInfoWidget::build_registers_tab() return registers_widget; } -void DebugInfoWidget::update_state(Debug::ProcessInspector& inspector, const PtraceRegisters& regs) +void DebugInfoWidget::update_state(Debug::ProcessInspector& inspector, PtraceRegisters const& regs) { m_variables_view->set_model(VariablesModel::create(inspector, regs)); m_backtrace_view->set_model(BacktraceModel::create(inspector, regs)); diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.h b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.h index 0cf30d5648..2f72f4c285 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.h +++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.h @@ -38,7 +38,7 @@ private: NonnullRefPtr<GUI::Widget> build_variables_tab(); NonnullRefPtr<GUI::Widget> build_registers_tab(); - bool does_variable_support_writing(const Debug::DebugInfo::VariableInfo*); + bool does_variable_support_writing(Debug::DebugInfo::VariableInfo const*); RefPtr<GUI::Menu> get_context_menu_for_variable(const GUI::ModelIndex&); RefPtr<GUI::TreeView> m_variables_view; diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp index 9a02d5962a..71d8bf39b7 100644 --- a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp +++ b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp @@ -19,7 +19,7 @@ Debugger& Debugger::the() void Debugger::initialize( String source_root, - Function<HasControlPassedToUser(const PtraceRegisters&)> on_stop_callback, + Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback, Function<void()> on_continue_callback, Function<void()> on_exit_callback) { @@ -33,7 +33,7 @@ bool Debugger::is_initialized() Debugger::Debugger( String source_root, - Function<HasControlPassedToUser(const PtraceRegisters&)> on_stop_callback, + Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback, Function<void()> on_continue_callback, Function<void()> on_exit_callback) : m_source_root(source_root) @@ -45,14 +45,14 @@ Debugger::Debugger( pthread_cond_init(&m_ui_action_cond, nullptr); } -void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointChange change_type) +void Debugger::on_breakpoint_change(String const& file, size_t line, BreakpointChange change_type) { auto position = create_source_position(file, line); if (change_type == BreakpointChange::Added) { m_breakpoints.append(position); } else { - m_breakpoints.remove_all_matching([&](const Debug::DebugInfo::SourcePosition& val) { return val == position; }); + m_breakpoints.remove_all_matching([&](Debug::DebugInfo::SourcePosition const& val) { return val == position; }); } auto session = Debugger::the().session(); @@ -77,7 +77,7 @@ void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointC } } -bool Debugger::set_execution_position(const String& file, size_t line) +bool Debugger::set_execution_position(String const& file, size_t line) { auto position = create_source_position(file, line); auto session = Debugger::the().session(); @@ -92,7 +92,7 @@ bool Debugger::set_execution_position(const String& file, size_t line) return true; } -Debug::DebugInfo::SourcePosition Debugger::create_source_position(const String& file, size_t line) +Debug::DebugInfo::SourcePosition Debugger::create_source_position(String const& file, size_t line) { if (file.starts_with("/")) return { file, line + 1 }; @@ -121,7 +121,7 @@ void Debugger::start() m_debug_session = Debug::DebugSession::exec_and_attach(m_executable_path, m_source_root, move(child_setup_callback)); VERIFY(!!m_debug_session); - for (const auto& breakpoint : m_breakpoints) { + for (auto const& breakpoint : m_breakpoints) { dbgln("inserting breakpoint at: {}:{}", breakpoint.file_path, breakpoint.line_number); auto address = m_debug_session->get_address_from_source_position(breakpoint.file_path, breakpoint.line_number); if (address.has_value()) { @@ -218,7 +218,7 @@ void Debugger::DebuggingState::set_single_stepping(Debug::DebugInfo::SourcePosit m_original_source_position = original_source_position; } -bool Debugger::DebuggingState::should_stop_single_stepping(const Debug::DebugInfo::SourcePosition& current_source_position) const +bool Debugger::DebuggingState::should_stop_single_stepping(Debug::DebugInfo::SourcePosition const& current_source_position) const { VERIFY(m_state == State::SingleStepping); return m_original_source_position.value() != current_source_position; @@ -243,7 +243,7 @@ void Debugger::DebuggingState::add_temporary_breakpoint(FlatPtr address) m_addresses_of_temporary_breakpoints.append(address); } -void Debugger::do_step_out(const PtraceRegisters& regs) +void Debugger::do_step_out(PtraceRegisters const& regs) { // To step out, we simply insert a temporary breakpoint at the // instruction the current function returns to, and continue @@ -251,7 +251,7 @@ void Debugger::do_step_out(const PtraceRegisters& regs) insert_temporary_breakpoint_at_return_address(regs); } -void Debugger::do_step_over(const PtraceRegisters& regs) +void Debugger::do_step_over(PtraceRegisters const& regs) { // To step over, we insert a temporary breakpoint at each line in the current function, // as well as at the current function's return point, and continue execution. @@ -265,13 +265,13 @@ void Debugger::do_step_over(const PtraceRegisters& regs) } VERIFY(current_function.has_value()); auto lines_in_current_function = lib->debug_info->source_lines_in_scope(current_function.value()); - for (const auto& line : lines_in_current_function) { + for (auto const& line : lines_in_current_function) { insert_temporary_breakpoint(line.address_of_first_statement.value() + lib->base_address); } insert_temporary_breakpoint_at_return_address(regs); } -void Debugger::insert_temporary_breakpoint_at_return_address(const PtraceRegisters& regs) +void Debugger::insert_temporary_breakpoint_at_return_address(PtraceRegisters const& regs) { auto frame_info = Debug::StackFrameUtils::get_info(*m_debug_session, regs.bp()); VERIFY(frame_info.has_value()); diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.h b/Userland/DevTools/HackStudio/Debugger/Debugger.h index eca9d30b76..eaf14e5a5c 100644 --- a/Userland/DevTools/HackStudio/Debugger/Debugger.h +++ b/Userland/DevTools/HackStudio/Debugger/Debugger.h @@ -27,17 +27,17 @@ public: static void initialize( String source_root, - Function<HasControlPassedToUser(const PtraceRegisters&)> on_stop_callback, + Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback, Function<void()> on_continue_callback, Function<void()> on_exit_callback); static bool is_initialized(); - void on_breakpoint_change(const String& file, size_t line, BreakpointChange change_type); - bool set_execution_position(const String& file, size_t line); + void on_breakpoint_change(String const& file, size_t line, BreakpointChange change_type); + bool set_execution_position(String const& file, size_t line); - void set_executable_path(const String& path) { m_executable_path = path; } - void set_source_root(const String& source_root) { m_source_root = source_root; } + void set_executable_path(String const& path) { m_executable_path = path; } + void set_source_root(String const& source_root) { m_source_root = source_root; } Debug::DebugSession* session() { return m_debug_session.ptr(); } @@ -78,10 +78,10 @@ private: void set_stepping_out() { m_state = State::SteppingOut; } void set_stepping_over() { m_state = State::SteppingOver; } - bool should_stop_single_stepping(const Debug::DebugInfo::SourcePosition& current_source_position) const; + bool should_stop_single_stepping(Debug::DebugInfo::SourcePosition const& current_source_position) const; void clear_temporary_breakpoints(); void add_temporary_breakpoint(FlatPtr address); - const Vector<FlatPtr>& temporary_breakpoints() const { return m_addresses_of_temporary_breakpoints; } + Vector<FlatPtr> const& temporary_breakpoints() const { return m_addresses_of_temporary_breakpoints; } private: State m_state { Normal }; @@ -91,20 +91,20 @@ private: explicit Debugger( String source_root, - Function<HasControlPassedToUser(const PtraceRegisters&)> on_stop_callback, + Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback, Function<void()> on_continue_callback, Function<void()> on_exit_callback); - Debug::DebugInfo::SourcePosition create_source_position(const String& file, size_t line); + Debug::DebugInfo::SourcePosition create_source_position(String const& file, size_t line); void start(); int debugger_loop(); void remove_temporary_breakpoints(); - void do_step_out(const PtraceRegisters&); - void do_step_over(const PtraceRegisters&); + void do_step_out(PtraceRegisters const&); + void do_step_over(PtraceRegisters const&); void insert_temporary_breakpoint(FlatPtr address); - void insert_temporary_breakpoint_at_return_address(const PtraceRegisters&); + void insert_temporary_breakpoint_at_return_address(PtraceRegisters const&); OwnPtr<Debug::DebugSession> m_debug_session; String m_source_root; @@ -118,7 +118,7 @@ private: String m_executable_path; - Function<HasControlPassedToUser(const PtraceRegisters&)> m_on_stopped_callback; + Function<HasControlPassedToUser(PtraceRegisters const&)> m_on_stopped_callback; Function<void()> m_on_continue_callback; Function<void()> m_on_exit_callback; Function<ErrorOr<void>()> m_child_setup_callback; diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp index 90e8abe82e..70822d9299 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp @@ -58,7 +58,7 @@ JS::ThrowCompletionOr<bool> DebuggerGlobalJSObject::internal_set(JS::PropertyKey return vm().throw_completion<JS::TypeError>(const_cast<DebuggerGlobalJSObject&>(*this), move(error_string)); } -Optional<JS::Value> DebuggerGlobalJSObject::debugger_to_js(const Debug::DebugInfo::VariableInfo& variable) const +Optional<JS::Value> DebuggerGlobalJSObject::debugger_to_js(Debug::DebugInfo::VariableInfo const& variable) const { if (variable.location_type != Debug::DebugInfo::VariableInfo::LocationType::Address) return {}; @@ -94,7 +94,7 @@ Optional<JS::Value> DebuggerGlobalJSObject::debugger_to_js(const Debug::DebugInf return JS::Value(object); } -Optional<u32> DebuggerGlobalJSObject::js_to_debugger(JS::Value value, const Debug::DebugInfo::VariableInfo& variable) const +Optional<u32> DebuggerGlobalJSObject::js_to_debugger(JS::Value value, Debug::DebugInfo::VariableInfo const& variable) const { if (value.is_string() && variable.type_name == "char") { auto string = value.as_string().string(); diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h index cb1560ab28..a1f3b09e01 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h @@ -24,8 +24,8 @@ public: virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver) const override; virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override; - Optional<JS::Value> debugger_to_js(const Debug::DebugInfo::VariableInfo&) const; - Optional<u32> js_to_debugger(JS::Value value, const Debug::DebugInfo::VariableInfo&) const; + Optional<JS::Value> debugger_to_js(Debug::DebugInfo::VariableInfo const&) const; + Optional<u32> js_to_debugger(JS::Value value, Debug::DebugInfo::VariableInfo const&) const; private: NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables; diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp index 063f1fd4cb..97db4eeffe 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp @@ -15,12 +15,12 @@ namespace HackStudio { -DebuggerVariableJSObject* DebuggerVariableJSObject::create(DebuggerGlobalJSObject& global_object, const Debug::DebugInfo::VariableInfo& variable_info) +DebuggerVariableJSObject* DebuggerVariableJSObject::create(DebuggerGlobalJSObject& global_object, Debug::DebugInfo::VariableInfo const& variable_info) { return global_object.heap().allocate<DebuggerVariableJSObject>(global_object, variable_info, *global_object.object_prototype()); } -DebuggerVariableJSObject::DebuggerVariableJSObject(const Debug::DebugInfo::VariableInfo& variable_info, JS::Object& prototype) +DebuggerVariableJSObject::DebuggerVariableJSObject(Debug::DebugInfo::VariableInfo const& variable_info, JS::Object& prototype) : JS::Object(prototype) , m_variable_info(variable_info) { diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h index c44c0e907d..195e978225 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h @@ -20,9 +20,9 @@ class DebuggerVariableJSObject final : public JS::Object { using Base = JS::Object; public: - static DebuggerVariableJSObject* create(DebuggerGlobalJSObject&, const Debug::DebugInfo::VariableInfo& variable_info); + static DebuggerVariableJSObject* create(DebuggerGlobalJSObject&, Debug::DebugInfo::VariableInfo const& variable_info); - DebuggerVariableJSObject(const Debug::DebugInfo::VariableInfo& variable_info, JS::Object& prototype); + DebuggerVariableJSObject(Debug::DebugInfo::VariableInfo const& variable_info, JS::Object& prototype); virtual ~DebuggerVariableJSObject() override = default; virtual StringView class_name() const override { return m_variable_info.type_name; } @@ -32,7 +32,7 @@ public: private: DebuggerGlobalJSObject& debugger_object() const; - const Debug::DebugInfo::VariableInfo& m_variable_info; + Debug::DebugInfo::VariableInfo const& m_variable_info; }; } diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp index 22d99180fd..3861ae7626 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp @@ -17,7 +17,7 @@ namespace HackStudio { -DisassemblyModel::DisassemblyModel(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) +DisassemblyModel::DisassemblyModel(Debug::DebugSession const& debug_session, PtraceRegisters const& regs) { auto lib = debug_session.library_at(regs.ip()); if (!lib) @@ -51,7 +51,7 @@ DisassemblyModel::DisassemblyModel(const Debug::DebugSession& debug_session, con auto view = symbol.value().raw_data(); X86::ELFSymbolProvider symbol_provider(*elf); - X86::SimpleInstructionStream stream((const u8*)view.characters_without_null_termination(), view.length()); + X86::SimpleInstructionStream stream((u8 const*)view.characters_without_null_termination(), view.length()); X86::Disassembler disassembler(stream); size_t offset_into_symbol = 0; diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h index 6daaea3cc2..10efc05af4 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h @@ -29,7 +29,7 @@ struct InstructionData { class DisassemblyModel final : public GUI::Model { public: - static NonnullRefPtr<DisassemblyModel> create(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) + static NonnullRefPtr<DisassemblyModel> create(Debug::DebugSession const& debug_session, PtraceRegisters const& regs) { return adopt_ref(*new DisassemblyModel(debug_session, regs)); } @@ -49,7 +49,7 @@ public: virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; private: - DisassemblyModel(const Debug::DebugSession&, const PtraceRegisters&); + DisassemblyModel(Debug::DebugSession const&, PtraceRegisters const&); Vector<InstructionData> m_instructions; }; diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp index ff49fdf897..f2cfe33ae1 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp @@ -39,7 +39,7 @@ DisassemblyWidget::DisassemblyWidget() hide_disassembly("Program isn't running"); } -void DisassemblyWidget::update_state(const Debug::DebugSession& debug_session, const PtraceRegisters& regs) +void DisassemblyWidget::update_state(Debug::DebugSession const& debug_session, PtraceRegisters const& regs) { m_disassembly_view->set_model(DisassemblyModel::create(debug_session, regs)); @@ -73,7 +73,7 @@ void DisassemblyWidget::show_disassembly() m_unavailable_disassembly_widget->set_visible(false); } -void DisassemblyWidget::hide_disassembly(const String& reason) +void DisassemblyWidget::hide_disassembly(String const& reason) { m_top_container->set_visible(false); m_disassembly_view->set_visible(false); diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h index 09254737f7..5805c722ad 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h @@ -21,11 +21,11 @@ class UnavailableDisassemblyWidget final : public GUI::Frame { public: virtual ~UnavailableDisassemblyWidget() override { } - const String& reason() const { return m_reason; } - void set_reason(const String& text) { m_reason = text; } + String const& reason() const { return m_reason; } + void set_reason(String const& text) { m_reason = text; } private: - UnavailableDisassemblyWidget(const String& reason) + UnavailableDisassemblyWidget(String const& reason) : m_reason(reason) { } @@ -40,14 +40,14 @@ class DisassemblyWidget final : public GUI::Widget { public: virtual ~DisassemblyWidget() override { } - void update_state(const Debug::DebugSession&, const PtraceRegisters&); + void update_state(Debug::DebugSession const&, PtraceRegisters const&); void program_stopped(); private: DisassemblyWidget(); void show_disassembly(); - void hide_disassembly(const String&); + void hide_disassembly(String const&); RefPtr<GUI::Widget> m_top_container; RefPtr<GUI::TableView> m_disassembly_view; diff --git a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp index d31f8ae12e..c1fc9a7058 100644 --- a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp +++ b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.cpp @@ -103,7 +103,7 @@ void EvaluateExpressionDialog::build(Window* parent_window) m_text_editor->set_focus(true); } -void EvaluateExpressionDialog::handle_evaluation(const String& expression) +void EvaluateExpressionDialog::handle_evaluation(String const& expression) { m_output_container->remove_all_children(); m_output_view->update(); diff --git a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.h b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.h index d33873c3bb..201c3c8190 100644 --- a/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.h +++ b/Userland/DevTools/HackStudio/Debugger/EvaluateExpressionDialog.h @@ -18,7 +18,7 @@ private: explicit EvaluateExpressionDialog(Window* parent_window); void build(Window* parent_window); - void handle_evaluation(const String& expression); + void handle_evaluation(String const& expression); void set_output(StringView html); NonnullOwnPtr<JS::Interpreter> m_interpreter; diff --git a/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp b/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp index 3bac9fce93..949b6202e6 100644 --- a/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -RegistersModel::RegistersModel(const PtraceRegisters& regs) +RegistersModel::RegistersModel(PtraceRegisters const& regs) : m_raw_registers(regs) { #if ARCH(I386) @@ -52,7 +52,7 @@ RegistersModel::RegistersModel(const PtraceRegisters& regs) m_registers.append({ "gs", regs.gs }); } -RegistersModel::RegistersModel(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs) +RegistersModel::RegistersModel(PtraceRegisters const& current_regs, PtraceRegisters const& previous_regs) : m_raw_registers(current_regs) { #if ARCH(I386) diff --git a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h index 91651e798a..a0e86c1915 100644 --- a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h +++ b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h @@ -21,12 +21,12 @@ struct RegisterData { class RegistersModel final : public GUI::Model { public: - static RefPtr<RegistersModel> create(const PtraceRegisters& regs) + static RefPtr<RegistersModel> create(PtraceRegisters const& regs) { return adopt_ref(*new RegistersModel(regs)); } - static RefPtr<RegistersModel> create(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs) + static RefPtr<RegistersModel> create(PtraceRegisters const& current_regs, PtraceRegisters const& previous_regs) { return adopt_ref(*new RegistersModel(current_regs, previous_regs)); } @@ -44,11 +44,11 @@ public: virtual String column_name(int) const override; virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; - const PtraceRegisters& raw_registers() const { return m_raw_registers; } + PtraceRegisters const& raw_registers() const { return m_raw_registers; } private: - explicit RegistersModel(const PtraceRegisters& regs); - RegistersModel(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs); + explicit RegistersModel(PtraceRegisters const& regs); + RegistersModel(PtraceRegisters const& current_regs, PtraceRegisters const& previous_regs); PtraceRegisters m_raw_registers; Vector<RegisterData> m_registers; diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp index 02f57c81d6..5e014b63c1 100644 --- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp @@ -17,7 +17,7 @@ GUI::ModelIndex VariablesModel::index(int row, int column, const GUI::ModelIndex return {}; return create_index(row, column, &m_variables[row]); } - auto* parent = static_cast<const Debug::DebugInfo::VariableInfo*>(parent_index.internal_data()); + auto* parent = static_cast<Debug::DebugInfo::VariableInfo const*>(parent_index.internal_data()); if (static_cast<size_t>(row) >= parent->members.size()) return {}; auto* child = &parent->members[row]; @@ -28,7 +28,7 @@ GUI::ModelIndex VariablesModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto* child = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto* child = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); auto* parent = child->parent; if (parent == nullptr) return {}; @@ -51,11 +51,11 @@ int VariablesModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return m_variables.size(); - auto* node = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto* node = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); return node->members.size(); } -static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& variable) +static String variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable) { if (variable.location_type != Debug::DebugInfo::VariableInfo::LocationType::Address) return "N/A"; @@ -65,7 +65,7 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var if (variable.is_enum_type()) { auto value = Debugger::the().session()->peek(variable_address); VERIFY(value.has_value()); - auto it = variable.type->members.find_if([&enumerator_value = value.value()](const auto& enumerator) { + auto it = variable.type->members.find_if([&enumerator_value = value.value()](auto const& enumerator) { return enumerator->constant_data.as_u32 == enumerator_value; }); if (it.is_end()) @@ -94,7 +94,7 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var return String::formatted("type: {} @ {:p}, ", variable.type_name, variable_address); } -static Optional<u32> string_to_variable_value(StringView string_value, const Debug::DebugInfo::VariableInfo& variable) +static Optional<u32> string_to_variable_value(StringView string_value, Debug::DebugInfo::VariableInfo const& variable) { if (variable.is_enum_type()) { auto prefix_string = String::formatted("{}::", variable.type_name); @@ -102,7 +102,7 @@ static Optional<u32> string_to_variable_value(StringView string_value, const Deb if (string_value.starts_with(prefix_string)) string_to_use = string_value.substring_view(prefix_string.length(), string_value.length() - prefix_string.length()); - auto it = variable.type->members.find_if([string_to_use](const auto& enumerator) { + auto it = variable.type->members.find_if([string_to_use](auto const& enumerator) { return enumerator->name == string_to_use; }); @@ -131,7 +131,7 @@ static Optional<u32> string_to_variable_value(StringView string_value, const Deb void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView string_value, GUI::Window* parent_window) { - auto variable = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto variable = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); auto value = string_to_variable_value(string_value, *variable); @@ -150,7 +150,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const { - auto* variable = static_cast<const Debug::DebugInfo::VariableInfo*>(index.internal_data()); + auto* variable = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data()); switch (role) { case GUI::ModelRole::Display: { auto value_as_string = variable_value_as_string(*variable); diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.h b/Userland/DevTools/HackStudio/Debugger/VariablesModel.h index a46a7641ed..c32019bb31 100644 --- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.h +++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.h @@ -28,7 +28,7 @@ public: Debug::ProcessInspector& inspector() { return m_inspector; } private: - explicit VariablesModel(Debug::ProcessInspector& inspector, NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo>&& variables, const PtraceRegisters& regs) + explicit VariablesModel(Debug::ProcessInspector& inspector, NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo>&& variables, PtraceRegisters const& regs) : m_variables(move(variables)) , m_regs(regs) , m_inspector(inspector) diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp index 36d67f5e8f..e33d7ba9fe 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp @@ -25,7 +25,7 @@ namespace HackStudio { -static const Regex<PosixExtended> s_project_name_validity_regex("^([A-Za-z0-9_-])*$"); +static Regex<PosixExtended> const s_project_name_validity_regex("^([A-Za-z0-9_-])*$"); int NewProjectDialog::show(GUI::Window* parent_window) { diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index f452428e5b..d50d92247b 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -101,9 +101,9 @@ EditorWrapper& Editor::wrapper() { return static_cast<EditorWrapper&>(*parent()); } -const EditorWrapper& Editor::wrapper() const +EditorWrapper const& Editor::wrapper() const { - return static_cast<const EditorWrapper&>(*parent()); + return static_cast<EditorWrapper const&>(*parent()); } void Editor::focusin_event(GUI::FocusEvent& event) @@ -147,11 +147,11 @@ void Editor::paint_event(GUI::PaintEvent& event) if (line < first_visible_line || line > last_visible_line) { continue; } - const auto& icon = breakpoint_icon_bitmap(); + auto const& icon = breakpoint_icon_bitmap(); painter.blit(gutter_icon_rect(line).top_left(), icon, icon.rect()); } if (execution_position().has_value()) { - const auto& icon = current_position_icon_bitmap(); + auto const& icon = current_position_icon_bitmap(); painter.blit(gutter_icon_rect(execution_position().value()).top_left(), icon, icon.rect()); } @@ -198,7 +198,7 @@ static HashMap<String, String>& man_paths() return paths; } -void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Gfx::IntPoint& screen_location) +void Editor::show_documentation_tooltip_if_available(String const& hovered_token, Gfx::IntPoint const& screen_location) { auto it = man_paths().find(hovered_token); if (it == man_paths().end()) { @@ -438,28 +438,28 @@ void Editor::clear_execution_position() update(gutter_icon_rect(previous_position)); } -const Gfx::Bitmap& Editor::breakpoint_icon_bitmap() +Gfx::Bitmap const& Editor::breakpoint_icon_bitmap() { static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/breakpoint.png").release_value_but_fixme_should_propagate_errors(); return *bitmap; } -const Gfx::Bitmap& Editor::current_position_icon_bitmap() +Gfx::Bitmap const& Editor::current_position_icon_bitmap() { static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(); return *bitmap; } -const CodeDocument& Editor::code_document() const +CodeDocument const& Editor::code_document() const { - const auto& doc = document(); + auto const& doc = document(); VERIFY(doc.is_code_document()); - return static_cast<const CodeDocument&>(doc); + return static_cast<CodeDocument const&>(doc); } CodeDocument& Editor::code_document() { - return const_cast<CodeDocument&>(static_cast<const Editor&>(*this).code_document()); + return const_cast<CodeDocument&>(static_cast<Editor const&>(*this).code_document()); } void Editor::set_document(GUI::TextDocument& doc) @@ -585,7 +585,7 @@ void Editor::on_identifier_click(const GUI::TextDocumentSpan& span) if (!m_language_client) return; - m_language_client->on_declaration_found = [](const String& file, size_t line, size_t column) { + m_language_client->on_declaration_found = [](String const& file, size_t line, size_t column) { HackStudio::open_file(file, line, column); }; m_language_client->search_declaration(code_document().file_path(), span.range.start().line(), span.range.start().column()); @@ -596,7 +596,7 @@ void Editor::set_cursor(const GUI::TextPosition& a_position) TextEditor::set_cursor(a_position); } -void Editor::set_syntax_highlighter_for(const CodeDocument& document) +void Editor::set_syntax_highlighter_for(CodeDocument const& document) { switch (document.language()) { case Language::Cpp: @@ -650,7 +650,7 @@ void Editor::set_autocomplete_provider_for(CodeDocument const& document) } } -void Editor::set_language_client_for(const CodeDocument& document) +void Editor::set_language_client_for(CodeDocument const& document) { if (m_language_client && m_language_client->language() == document.language()) return; diff --git a/Userland/DevTools/HackStudio/Editor.h b/Userland/DevTools/HackStudio/Editor.h index 75755e0f8e..e1bc6206d5 100644 --- a/Userland/DevTools/HackStudio/Editor.h +++ b/Userland/DevTools/HackStudio/Editor.h @@ -32,9 +32,9 @@ public: Function<void(String)> on_open; EditorWrapper& wrapper(); - const EditorWrapper& wrapper() const; + EditorWrapper const& wrapper() const; - const Vector<size_t>& breakpoint_lines() const { return code_document().breakpoint_lines(); } + Vector<size_t> const& breakpoint_lines() const { return code_document().breakpoint_lines(); } Vector<size_t>& breakpoint_lines() { return code_document().breakpoint_lines(); } Optional<size_t> execution_position() const { return code_document().execution_position(); } bool is_program_running() const { return execution_position().has_value(); } @@ -42,7 +42,7 @@ public: void clear_execution_position(); void set_debug_mode(bool); - const CodeDocument& code_document() const; + CodeDocument const& code_document() const; CodeDocument& code_document(); virtual void set_document(GUI::TextDocument&) override; @@ -70,14 +70,14 @@ private: virtual void leave_event(Core::Event&) override; virtual void keydown_event(GUI::KeyEvent&) override; - void show_documentation_tooltip_if_available(const String&, const Gfx::IntPoint& screen_location); + void show_documentation_tooltip_if_available(String const&, Gfx::IntPoint const& screen_location); void navigate_to_include_if_available(String); void on_navigatable_link_click(const GUI::TextDocumentSpan&); void on_identifier_click(const GUI::TextDocumentSpan&); Gfx::IntRect gutter_icon_rect(size_t line_number) const; - static const Gfx::Bitmap& breakpoint_icon_bitmap(); - static const Gfx::Bitmap& current_position_icon_bitmap(); + static Gfx::Bitmap const& breakpoint_icon_bitmap(); + static Gfx::Bitmap const& current_position_icon_bitmap(); struct AutoCompleteRequestData { GUI::TextPosition position; @@ -99,8 +99,8 @@ private: Optional<AutoCompleteRequestData> get_autocomplete_request_data(); void flush_file_content_to_langauge_server(); - void set_syntax_highlighter_for(const CodeDocument&); - void set_language_client_for(const CodeDocument&); + void set_syntax_highlighter_for(CodeDocument const&); + void set_language_client_for(CodeDocument const&); void set_autocomplete_provider_for(CodeDocument const&); void handle_function_parameters_hint_request(); void on_token_info_timer_tick(); diff --git a/Userland/DevTools/HackStudio/EditorWrapper.cpp b/Userland/DevTools/HackStudio/EditorWrapper.cpp index b3eda59f42..c532a1f7c6 100644 --- a/Userland/DevTools/HackStudio/EditorWrapper.cpp +++ b/Userland/DevTools/HackStudio/EditorWrapper.cpp @@ -62,7 +62,7 @@ void EditorWrapper::set_mode_non_displayable() editor().document().set_text("The contents of this file could not be displayed. Is it a binary file?"); } -void EditorWrapper::set_filename(const String& filename) +void EditorWrapper::set_filename(String const& filename) { m_filename = filename; update_title(); diff --git a/Userland/DevTools/HackStudio/EditorWrapper.h b/Userland/DevTools/HackStudio/EditorWrapper.h index 62c5121d4d..abbc756738 100644 --- a/Userland/DevTools/HackStudio/EditorWrapper.h +++ b/Userland/DevTools/HackStudio/EditorWrapper.h @@ -29,7 +29,7 @@ public: virtual ~EditorWrapper() override = default; Editor& editor() { return *m_editor; } - const Editor& editor() const { return *m_editor; } + Editor const& editor() const { return *m_editor; } void save(); @@ -38,8 +38,8 @@ public: void set_mode_displayable(); void set_mode_non_displayable(); void set_debug_mode(bool); - void set_filename(const String&); - const String& filename() const { return m_filename; } + void set_filename(String const&); + String const& filename() const { return m_filename; } String const& filename_title() const { return m_filename_title; } Optional<String> const& project_root() const { return m_project_root; } diff --git a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp index 28e95f5fc7..5b9e99355f 100644 --- a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp @@ -31,7 +31,7 @@ public: __Count }; - explicit SearchResultsModel(const Vector<Match>&& matches) + explicit SearchResultsModel(Vector<Match> const&& matches) : m_matches(move(matches)) { } diff --git a/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp b/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp index e2f07af251..054d2ddd20 100644 --- a/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp +++ b/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp @@ -27,7 +27,7 @@ void GMLPreviewWidget::load_gml(String const& gml) return; } - load_from_gml(gml, [](const String& name) -> RefPtr<Core::Object> { + load_from_gml(gml, [](String const& name) -> RefPtr<Core::Object> { return GUI::Label::construct(String::formatted("{} is not registered as a GML element!", name)); }); diff --git a/Userland/DevTools/HackStudio/Git/DiffViewer.cpp b/Userland/DevTools/HackStudio/Git/DiffViewer.cpp index 049fbd5978..cf85972dcd 100644 --- a/Userland/DevTools/HackStudio/Git/DiffViewer.cpp +++ b/Userland/DevTools/HackStudio/Git/DiffViewer.cpp @@ -35,7 +35,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event) size_t y_offset = 10; size_t current_original_line_index = 0; - for (const auto& hunk : m_hunks) { + for (auto const& hunk : m_hunks) { for (size_t i = current_original_line_index; i < hunk.original_start_line; ++i) { draw_line(painter, m_original_lines[i], y_offset, LinePosition::Both, LineType::Normal); y_offset += line_height(); @@ -43,7 +43,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event) current_original_line_index = hunk.original_start_line + hunk.removed_lines.size(); size_t left_y_offset = y_offset; - for (const auto& removed_line : hunk.removed_lines) { + for (auto const& removed_line : hunk.removed_lines) { draw_line(painter, removed_line, left_y_offset, LinePosition::Left, LineType::Diff); left_y_offset += line_height(); } @@ -53,7 +53,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event) } size_t right_y_offset = y_offset; - for (const auto& added_line : hunk.added_lines) { + for (auto const& added_line : hunk.added_lines) { draw_line(painter, added_line, right_y_offset, LinePosition::Right, LineType::Diff); right_y_offset += line_height(); } @@ -71,7 +71,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event) } } -void DiffViewer::draw_line(GUI::Painter& painter, const String& line, size_t y_offset, LinePosition line_position, LineType line_type) +void DiffViewer::draw_line(GUI::Painter& painter, String const& line, size_t y_offset, LinePosition line_position, LineType line_type) { size_t line_width = font().width(line); @@ -131,7 +131,7 @@ Gfx::IntRect DiffViewer::separator_rect() const frame_inner_rect().height() }; } -void DiffViewer::set_content(const String& original, const String& diff) +void DiffViewer::set_content(String const& original, String const& diff) { m_original_lines = split_to_lines(original); m_hunks = Diff::parse_hunks(diff); @@ -147,7 +147,7 @@ DiffViewer::DiffViewer() setup_properties(); } -DiffViewer::DiffViewer(const String& original, const String& diff) +DiffViewer::DiffViewer(String const& original, String const& diff) : m_original_lines(split_to_lines(original)) , m_hunks(Diff::parse_hunks(diff)) { @@ -161,7 +161,7 @@ void DiffViewer::setup_properties() set_foreground_role(ColorRole::BaseText); } -Vector<String> DiffViewer::split_to_lines(const String& text) +Vector<String> DiffViewer::split_to_lines(String const& text) { // NOTE: This is slightly different than text.split('\n') Vector<String> lines; @@ -204,7 +204,7 @@ void DiffViewer::update_content_size() size_t num_lines = 0; size_t current_original_line_index = 0; - for (const auto& hunk : m_hunks) { + for (auto const& hunk : m_hunks) { num_lines += ((int)hunk.original_start_line - (int)current_original_line_index); num_lines += hunk.removed_lines.size(); diff --git a/Userland/DevTools/HackStudio/Git/DiffViewer.h b/Userland/DevTools/HackStudio/Git/DiffViewer.h index 38b27bf0df..a700809a4f 100644 --- a/Userland/DevTools/HackStudio/Git/DiffViewer.h +++ b/Userland/DevTools/HackStudio/Git/DiffViewer.h @@ -18,10 +18,10 @@ class DiffViewer final : public GUI::AbstractScrollableWidget { public: virtual ~DiffViewer() override = default; - void set_content(const String& original, const String& diff); + void set_content(String const& original, String const& diff); private: - DiffViewer(const String& original, const String& diff); + DiffViewer(String const& original, String const& diff); DiffViewer(); void setup_properties(); @@ -43,9 +43,9 @@ private: Missing, }; - void draw_line(GUI::Painter&, const String& line, size_t y_offset, LinePosition, LineType); + void draw_line(GUI::Painter&, String const& line, size_t y_offset, LinePosition, LineType); - static Vector<String> split_to_lines(const String& text); + static Vector<String> split_to_lines(String const& text); static Gfx::Color red_background(); static Gfx::Color green_background(); diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index 92238f7293..a6e6e0465a 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -167,8 +167,8 @@ void GitWidget::show_diff(String const& file_path) m_view_diff_callback("", Diff::generate_only_additions(content_string)); return; } - const auto& original_content = m_git_repo->original_file_content(file_path); - const auto& diff = m_git_repo->unstaged_diff(file_path); + auto const& original_content = m_git_repo->original_file_content(file_path); + auto const& diff = m_git_repo->unstaged_diff(file_path); VERIFY(original_content.has_value() && diff.has_value()); m_view_diff_callback(original_content.value(), diff.value()); } diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.h b/Userland/DevTools/HackStudio/Git/GitWidget.h index 87f7c1bd2f..a0ff4ac209 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.h +++ b/Userland/DevTools/HackStudio/Git/GitWidget.h @@ -14,7 +14,7 @@ namespace HackStudio { -using ViewDiffCallback = Function<void(const String& original_content, const String& diff)>; +using ViewDiffCallback = Function<void(String const& original_content, String const& diff)>; class GitWidget final : public GUI::Widget { C_OBJECT(GitWidget) diff --git a/Userland/DevTools/HackStudio/HackStudio.h b/Userland/DevTools/HackStudio/HackStudio.h index 68924f5523..3458b7c116 100644 --- a/Userland/DevTools/HackStudio/HackStudio.h +++ b/Userland/DevTools/HackStudio/HackStudio.h @@ -15,9 +15,9 @@ namespace HackStudio { GUI::TextEditor& current_editor(); -void open_file(const String&); +void open_file(String const&); RefPtr<EditorWrapper> current_editor_wrapper(); -void open_file(const String&, size_t line, size_t column); +void open_file(String const&, size_t line, size_t column); Project& project(); String currently_open_file(); void set_current_editor_wrapper(RefPtr<EditorWrapper>); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index df1b66220b..b741203914 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -233,7 +233,7 @@ Vector<String> HackStudioWidget::read_recent_projects() return paths; } -void HackStudioWidget::open_project(const String& root_path) +void HackStudioWidget::open_project(String const& root_path) { if (warn_unsaved_changes("There are unsaved changes, do you want to save before closing current project?") == ContinueDecision::No) return; @@ -300,7 +300,7 @@ Vector<String> HackStudioWidget::selected_file_paths() const return files; } -bool HackStudioWidget::open_file(const String& full_filename, size_t line, size_t column) +bool HackStudioWidget::open_file(String const& full_filename, size_t line, size_t column) { String filename = full_filename; if (full_filename.starts_with(project().root_path())) { @@ -972,7 +972,7 @@ void HackStudioWidget::initialize_debugger() { Debugger::initialize( m_project->root_path(), - [this](const PtraceRegisters& regs) { + [this](PtraceRegisters const& regs) { VERIFY(Debugger::the().session()); const auto& debug_session = *Debugger::the().session(); auto source_position = debug_session.get_source_position(regs.ip()); @@ -1025,7 +1025,7 @@ void HackStudioWidget::initialize_debugger() }); } -String HackStudioWidget::get_full_path_of_serenity_source(const String& file) +String HackStudioWidget::get_full_path_of_serenity_source(String const& file) { auto path_parts = LexicalPath(file).parts(); while (!path_parts.is_empty() && path_parts[0] == "..") { @@ -1038,7 +1038,7 @@ String HackStudioWidget::get_full_path_of_serenity_source(const String& file) return String::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string()); } -String HackStudioWidget::get_absolute_path(const String& path) const +String HackStudioWidget::get_absolute_path(String const& path) const { // TODO: We can probably do a more specific condition here, something like // "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))" @@ -1048,7 +1048,7 @@ String HackStudioWidget::get_absolute_path(const String& path) const return m_project->to_absolute_path(path); } -RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(const String& filename) +RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(String const& filename) { String file_path = filename; @@ -1261,7 +1261,7 @@ void HackStudioWidget::create_action_tab(GUI::Widget& parent) m_disassembly_widget = m_action_tab_widget->add_tab<DisassemblyWidget>("Disassembly"); m_git_widget = m_action_tab_widget->add_tab<GitWidget>("Git", m_project->root_path()); - m_git_widget->set_view_diff_callback([this](const auto& original_content, const auto& diff) { + m_git_widget->set_view_diff_callback([this](auto const& original_content, auto const& diff) { m_diff_viewer->set_content(original_content, diff); set_edit_mode(EditMode::Diff); }); @@ -1497,7 +1497,7 @@ void HackStudioWidget::update_statusbar() m_statusbar->set_text(2, String::formatted("Ln {}, Col {}", current_editor().cursor().line() + 1, current_editor().cursor().column())); } -void HackStudioWidget::handle_external_file_deletion(const String& filepath) +void HackStudioWidget::handle_external_file_deletion(String const& filepath) { close_file_in_all_editors(filepath); } @@ -1534,7 +1534,7 @@ HackStudioWidget::~HackStudioWidget() stop_debugger_if_running(); } -HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(const String& prompt) +HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(String const& prompt) { if (!any_document_is_dirty()) return ContinueDecision::Yes; diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index 29f76a148c..b8305e5f75 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -53,7 +53,7 @@ public: GUI::TabWidget& current_editor_tab_widget(); GUI::TabWidget const& current_editor_tab_widget() const; - const String& active_file() const { return m_current_editor_wrapper->filename(); } + String const& active_file() const { return m_current_editor_wrapper->filename(); } void initialize_menubar(GUI::Window&); Locator& locator() @@ -66,7 +66,7 @@ public: No, Yes }; - ContinueDecision warn_unsaved_changes(const String& prompt); + ContinueDecision warn_unsaved_changes(String const& prompt); enum class Mode { Code, @@ -82,12 +82,12 @@ public: private: static constexpr size_t recent_projects_history_size = 15; - static String get_full_path_of_serenity_source(const String& file); + static String get_full_path_of_serenity_source(String const& file); String get_absolute_path(String const&) const; Vector<String> selected_file_paths() const; HackStudioWidget(String path_to_project); - void open_project(const String& root_path); + void open_project(String const& root_path); enum class EditMode { Text, @@ -124,7 +124,7 @@ private: void add_new_editor_tab_widget(GUI::Widget& parent); void add_new_editor(GUI::TabWidget& parent); - RefPtr<EditorWrapper> get_editor_of_file(const String& filename); + RefPtr<EditorWrapper> get_editor_of_file(String const& filename); String get_project_executable_path() const; void on_action_tab_change(); @@ -132,7 +132,7 @@ private: void initialize_debugger(); void update_statusbar(); - void handle_external_file_deletion(const String& filepath); + void handle_external_file_deletion(String const& filepath); void stop_debugger_if_running(); void close_current_project(); diff --git a/Userland/DevTools/HackStudio/Language.cpp b/Userland/DevTools/HackStudio/Language.cpp index f00c5bfc27..bc6fc82f34 100644 --- a/Userland/DevTools/HackStudio/Language.cpp +++ b/Userland/DevTools/HackStudio/Language.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -Language language_from_file(const LexicalPath& file) +Language language_from_file(LexicalPath const& file) { if (file.title() == "COMMIT_EDITMSG") return Language::GitCommit; @@ -37,7 +37,7 @@ Language language_from_file(const LexicalPath& file) return Language::Unknown; } -Language language_from_name(const String& name) +Language language_from_name(String const& name) { if (name == "Cpp") return Language::Cpp; @@ -51,7 +51,7 @@ Language language_from_name(const String& name) return Language::Unknown; } -String language_name_from_file(const LexicalPath& file) +String language_name_from_file(LexicalPath const& file) { if (file.title() == "COMMIT_EDITMSG") return "GitCommit"; diff --git a/Userland/DevTools/HackStudio/Language.h b/Userland/DevTools/HackStudio/Language.h index 2ace198813..16a70d1d17 100644 --- a/Userland/DevTools/HackStudio/Language.h +++ b/Userland/DevTools/HackStudio/Language.h @@ -23,8 +23,8 @@ enum class Language { SQL, }; -Language language_from_file(const LexicalPath&); -Language language_from_name(const String&); -String language_name_from_file(const LexicalPath&); +Language language_from_file(LexicalPath const&); +Language language_from_name(String const&); +String language_name_from_file(LexicalPath const&); } diff --git a/Userland/DevTools/HackStudio/LanguageClient.cpp b/Userland/DevTools/HackStudio/LanguageClient.cpp index 75833bbc2d..42aa25e3a9 100644 --- a/Userland/DevTools/HackStudio/LanguageClient.cpp +++ b/Userland/DevTools/HackStudio/LanguageClient.cpp @@ -14,7 +14,7 @@ namespace HackStudio { -void ConnectionToServer::auto_complete_suggestions(const Vector<GUI::AutocompleteProvider::Entry>& suggestions) +void ConnectionToServer::auto_complete_suggestions(Vector<GUI::AutocompleteProvider::Entry> const& suggestions) { if (!m_current_language_client) { dbgln("Language Server connection has no attached language client"); @@ -60,35 +60,35 @@ void ConnectionToServer::die() m_wrapper->on_crash(); } -void LanguageClient::open_file(const String& path, int fd) +void LanguageClient::open_file(String const& path, int fd) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_file_opened(path, fd); } -void LanguageClient::set_file_content(const String& path, const String& content) +void LanguageClient::set_file_content(String const& path, String const& content) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_set_file_content(path, content); } -void LanguageClient::insert_text(const String& path, const String& text, size_t line, size_t column) +void LanguageClient::insert_text(String const& path, String const& text, size_t line, size_t column) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_file_edit_insert_text(path, text, line, column); } -void LanguageClient::remove_text(const String& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column) +void LanguageClient::remove_text(String const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_file_edit_remove_text(path, from_line, from_column, to_line, to_column); } -void LanguageClient::request_autocomplete(const String& path, size_t cursor_line, size_t cursor_column) +void LanguageClient::request_autocomplete(String const& path, size_t cursor_line, size_t cursor_column) { if (!m_connection_wrapper.connection()) return; @@ -96,7 +96,7 @@ void LanguageClient::request_autocomplete(const String& path, size_t cursor_line m_connection_wrapper.connection()->async_auto_complete_suggestions(GUI::AutocompleteProvider::ProjectLocation { path, cursor_line, cursor_column }); } -void LanguageClient::provide_autocomplete_suggestions(const Vector<GUI::AutocompleteProvider::Entry>& suggestions) const +void LanguageClient::provide_autocomplete_suggestions(Vector<GUI::AutocompleteProvider::Entry> const& suggestions) const { if (on_autocomplete_suggestions) on_autocomplete_suggestions(suggestions); @@ -120,7 +120,7 @@ bool LanguageClient::is_active_client() const HashMap<String, NonnullOwnPtr<ConnectionToServerWrapper>> ConnectionToServerInstances::s_instance_for_language; -void ConnectionToServer::declarations_in_document(const String& filename, const Vector<GUI::AutocompleteProvider::Declaration>& declarations) +void ConnectionToServer::declarations_in_document(String const& filename, Vector<GUI::AutocompleteProvider::Declaration> const& declarations) { ProjectDeclarations::the().set_declared_symbols(filename, declarations); } @@ -130,7 +130,7 @@ void ConnectionToServer::todo_entries_in_document(String const& filename, Vector ToDoEntries::the().set_entries(filename, move(todo_entries)); } -void LanguageClient::search_declaration(const String& path, size_t line, size_t column) +void LanguageClient::search_declaration(String const& path, size_t line, size_t column) { if (!m_connection_wrapper.connection()) return; @@ -138,7 +138,7 @@ void LanguageClient::search_declaration(const String& path, size_t line, size_t m_connection_wrapper.connection()->async_find_declaration(GUI::AutocompleteProvider::ProjectLocation { path, line, column }); } -void LanguageClient::get_parameters_hint(const String& path, size_t line, size_t column) +void LanguageClient::get_parameters_hint(String const& path, size_t line, size_t column) { if (!m_connection_wrapper.connection()) return; @@ -146,7 +146,7 @@ void LanguageClient::get_parameters_hint(const String& path, size_t line, size_t m_connection_wrapper.connection()->async_get_parameters_hint(GUI::AutocompleteProvider::ProjectLocation { path, line, column }); } -void LanguageClient::get_tokens_info(const String& filename) +void LanguageClient::get_tokens_info(String const& filename) { if (!m_connection_wrapper.connection()) return; @@ -154,7 +154,7 @@ void LanguageClient::get_tokens_info(const String& filename) m_connection_wrapper.connection()->async_get_tokens_info(filename); } -void LanguageClient::declaration_found(const String& file, size_t line, size_t column) const +void LanguageClient::declaration_found(String const& file, size_t line, size_t column) const { if (!on_declaration_found) { dbgln("on_declaration_found callback is not set"); @@ -172,17 +172,17 @@ void LanguageClient::parameters_hint_result(Vector<String> const& params, size_t on_function_parameters_hint_result(params, argument_index); } -void ConnectionToServerInstances::set_instance_for_language(const String& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper) +void ConnectionToServerInstances::set_instance_for_language(String const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper) { s_instance_for_language.set(language_name, move(connection_wrapper)); } -void ConnectionToServerInstances::remove_instance_for_language(const String& language_name) +void ConnectionToServerInstances::remove_instance_for_language(String const& language_name) { s_instance_for_language.remove(language_name); } -ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(const String& language_name) +ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(String const& language_name) { if (auto instance = s_instance_for_language.get(language_name); instance.has_value()) { return const_cast<ConnectionToServerWrapper*>(instance.value()); @@ -223,7 +223,7 @@ void ConnectionToServerWrapper::show_crash_notification() const notification->show(); } -ConnectionToServerWrapper::ConnectionToServerWrapper(const String& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator) +ConnectionToServerWrapper::ConnectionToServerWrapper(String const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator) : m_language(language_from_name(language_name)) , m_connection_creator(move(connection_creator)) { @@ -267,7 +267,7 @@ void ConnectionToServerWrapper::try_respawn_connection() // After respawning the language-server, we have to send the content of open project files // so the server's FileDB will be up-to-date. - for_each_open_file([this](const ProjectFile& file) { + for_each_open_file([this](ProjectFile const& file) { if (file.code_document().language() != m_language) return; m_connection->async_set_file_content(file.code_document().file_path(), file.document().text()); diff --git a/Userland/DevTools/HackStudio/LanguageClient.h b/Userland/DevTools/HackStudio/LanguageClient.h index e8a6600c73..9c9a6083ad 100644 --- a/Userland/DevTools/HackStudio/LanguageClient.h +++ b/Userland/DevTools/HackStudio/LanguageClient.h @@ -31,7 +31,7 @@ class ConnectionToServer friend class ConnectionToServerWrapper; public: - ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, const String& project_path) + ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, String const& project_path) : IPC::ConnectionToServer<LanguageClientEndpoint, LanguageServerEndpoint>(*this, move(socket)) { m_project_path = project_path; @@ -39,11 +39,11 @@ public: } WeakPtr<LanguageClient> language_client() { return m_current_language_client; } - const String& project_path() const { return m_project_path; } + String const& project_path() const { return m_project_path; } virtual void die() override; - const LanguageClient* active_client() const { return !m_current_language_client ? nullptr : m_current_language_client.ptr(); } + LanguageClient const* active_client() const { return !m_current_language_client ? nullptr : m_current_language_client.ptr(); } protected: virtual void auto_complete_suggestions(Vector<GUI::AutocompleteProvider::Entry> const&) override; @@ -63,11 +63,11 @@ class ConnectionToServerWrapper { AK_MAKE_NONCOPYABLE(ConnectionToServerWrapper); public: - explicit ConnectionToServerWrapper(const String& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator); + explicit ConnectionToServerWrapper(String const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator); ~ConnectionToServerWrapper() = default; template<typename LanguageServerType> - static ConnectionToServerWrapper& get_or_create(const String& project_path); + static ConnectionToServerWrapper& get_or_create(String const& project_path); Language language() const { return m_language; } ConnectionToServer* connection(); @@ -93,10 +93,10 @@ private: class ConnectionToServerInstances { public: - static void set_instance_for_language(const String& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper); - static void remove_instance_for_language(const String& language_name); + static void set_instance_for_language(String const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper); + static void remove_instance_for_language(String const& language_name); - static ConnectionToServerWrapper* get_instance_wrapper(const String& language_name); + static ConnectionToServerWrapper* get_instance_wrapper(String const& language_name); private: static HashMap<String, NonnullOwnPtr<ConnectionToServerWrapper>> s_instance_for_language; @@ -128,22 +128,22 @@ public: Language language() const { return m_connection_wrapper.language(); } void set_active_client(); bool is_active_client() const; - virtual void open_file(const String& path, int fd); - virtual void set_file_content(const String& path, const String& content); - virtual void insert_text(const String& path, const String& text, size_t line, size_t column); - virtual void remove_text(const String& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column); - virtual void request_autocomplete(const String& path, size_t cursor_line, size_t cursor_column); - virtual void search_declaration(const String& path, size_t line, size_t column); - virtual void get_parameters_hint(const String& path, size_t line, size_t column); - virtual void get_tokens_info(const String& filename); - - void provide_autocomplete_suggestions(const Vector<GUI::AutocompleteProvider::Entry>&) const; - void declaration_found(const String& file, size_t line, size_t column) const; + virtual void open_file(String const& path, int fd); + virtual void set_file_content(String const& path, String const& content); + virtual void insert_text(String const& path, String const& text, size_t line, size_t column); + virtual void remove_text(String const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column); + virtual void request_autocomplete(String const& path, size_t cursor_line, size_t cursor_column); + virtual void search_declaration(String const& path, size_t line, size_t column); + virtual void get_parameters_hint(String const& path, size_t line, size_t column); + virtual void get_tokens_info(String const& filename); + + void provide_autocomplete_suggestions(Vector<GUI::AutocompleteProvider::Entry> const&) const; + void declaration_found(String const& file, size_t line, size_t column) const; void parameters_hint_result(Vector<String> const& params, size_t argument_index) const; // Callbacks that get called when the result of a language server query is ready Function<void(Vector<GUI::AutocompleteProvider::Entry>)> on_autocomplete_suggestions; - Function<void(const String&, size_t, size_t)> on_declaration_found; + Function<void(String const&, size_t, size_t)> on_declaration_found; Function<void(Vector<String> const&, size_t)> on_function_parameters_hint_result; Function<void(Vector<GUI::AutocompleteProvider::TokenInfo> const&)> on_tokens_info_result; @@ -153,13 +153,13 @@ private: }; template<typename ConnectionToServerT> -static inline NonnullOwnPtr<LanguageClient> get_language_client(const String& project_path) +static inline NonnullOwnPtr<LanguageClient> get_language_client(String const& project_path) { return make<LanguageClient>(ConnectionToServerWrapper::get_or_create<ConnectionToServerT>(project_path)); } template<typename LanguageServerType> -ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(const String& project_path) +ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(String const& project_path) { auto* wrapper = ConnectionToServerInstances::get_instance_wrapper(LanguageServerType::language_name()); if (wrapper) diff --git a/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h b/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h index ad430f6eca..97a642410e 100644 --- a/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h +++ b/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h @@ -17,10 +17,10 @@ class ConnectionToServer final : public HackStudio::ConnectionToServer { \ IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/portal/language/" #socket_name) \ public: \ - static const char* language_name() { return #language_name_; } \ + static char const* language_name() { return #language_name_; } \ \ private: \ - ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, const String& project_path) \ + ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, String const& project_path) \ : HackStudio::ConnectionToServer(move(socket), project_path) \ { \ } \ diff --git a/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.cpp index 044aae97ab..381a918b59 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.cpp @@ -9,13 +9,13 @@ namespace LanguageServers { -CodeComprehensionEngine::CodeComprehensionEngine(const FileDB& filedb, bool should_store_all_declarations) +CodeComprehensionEngine::CodeComprehensionEngine(FileDB const& filedb, bool should_store_all_declarations) : m_filedb(filedb) , m_store_all_declarations(should_store_all_declarations) { } -void CodeComprehensionEngine::set_declarations_of_document(const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) +void CodeComprehensionEngine::set_declarations_of_document(String const& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { // Callback may not be configured if we're running tests if (!set_declarations_of_document_callback) diff --git a/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.h b/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.h index 7a9f0db06d..ddca934520 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.h +++ b/Userland/DevTools/HackStudio/LanguageServers/CodeComprehensionEngine.h @@ -18,38 +18,38 @@ class ConnectionFromClient; class CodeComprehensionEngine { public: - CodeComprehensionEngine(const FileDB& filedb, bool store_all_declarations = false); + CodeComprehensionEngine(FileDB const& filedb, bool store_all_declarations = false); virtual ~CodeComprehensionEngine() = default; - virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) = 0; + virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(String const& file, const GUI::TextPosition& autocomplete_position) = 0; // TODO: In the future we can pass the range that was edited and only re-parse what we have to. - virtual void on_edit([[maybe_unused]] const String& file) {}; - virtual void file_opened([[maybe_unused]] const String& file) {}; + virtual void on_edit([[maybe_unused]] String const& file) {}; + virtual void file_opened([[maybe_unused]] String const& file) {}; - virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String&, const GUI::TextPosition&) { return {}; } + virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(String const&, const GUI::TextPosition&) { return {}; } struct FunctionParamsHint { Vector<String> params; size_t current_index { 0 }; }; - virtual Optional<FunctionParamsHint> get_function_params_hint(const String&, const GUI::TextPosition&) { return {}; } + virtual Optional<FunctionParamsHint> get_function_params_hint(String const&, const GUI::TextPosition&) { return {}; } - virtual Vector<GUI::AutocompleteProvider::TokenInfo> get_tokens_info(const String&) { return {}; } + virtual Vector<GUI::AutocompleteProvider::TokenInfo> get_tokens_info(String const&) { return {}; } public: - Function<void(const String&, Vector<GUI::AutocompleteProvider::Declaration>&&)> set_declarations_of_document_callback; + Function<void(String const&, Vector<GUI::AutocompleteProvider::Declaration>&&)> set_declarations_of_document_callback; Function<void(String const&, Vector<Cpp::Parser::TodoEntry>&&)> set_todo_entries_of_document_callback; protected: - const FileDB& filedb() const { return m_filedb; } - void set_declarations_of_document(const String&, Vector<GUI::AutocompleteProvider::Declaration>&&); + FileDB const& filedb() const { return m_filedb; } + void set_declarations_of_document(String const&, Vector<GUI::AutocompleteProvider::Declaration>&&); void set_todo_entries_of_document(String const&, Vector<Cpp::Parser::TodoEntry>&&); - const HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>>& all_declarations() const { return m_all_declarations; } + HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>> const& all_declarations() const { return m_all_declarations; } private: HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>> m_all_declarations; - const FileDB& m_filedb; + FileDB const& m_filedb; bool m_store_all_declarations { false }; }; } diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h index 91a34958f2..ff5744c369 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h @@ -19,7 +19,7 @@ private: : LanguageServers::ConnectionFromClient(move(socket)) { m_autocomplete_engine = make<CppComprehensionEngine>(m_filedb); - m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { + m_autocomplete_engine->set_declarations_of_document_callback = [this](String const& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { async_declarations_in_document(filename, move(declarations)); }; m_autocomplete_engine->set_todo_entries_of_document_callback = [this](String const& filename, Vector<Cpp::Parser::TodoEntry>&& todo_entries) { diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp index 4485f2b3c1..4abfdc7861 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp @@ -20,12 +20,12 @@ namespace LanguageServers::Cpp { -CppComprehensionEngine::CppComprehensionEngine(const FileDB& filedb) +CppComprehensionEngine::CppComprehensionEngine(FileDB const& filedb) : CodeComprehensionEngine(filedb, true) { } -const CppComprehensionEngine::DocumentData* CppComprehensionEngine::get_or_create_document_data(const String& file) +CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_create_document_data(String const& file) { auto absolute_path = filedb().to_absolute_path(file); if (!m_documents.contains(absolute_path)) { @@ -34,7 +34,7 @@ const CppComprehensionEngine::DocumentData* CppComprehensionEngine::get_or_creat return get_document_data(absolute_path); } -const CppComprehensionEngine::DocumentData* CppComprehensionEngine::get_document_data(const String& file) const +CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document_data(String const& file) const { auto absolute_path = filedb().to_absolute_path(file); auto document_data = m_documents.get(absolute_path); @@ -43,7 +43,7 @@ const CppComprehensionEngine::DocumentData* CppComprehensionEngine::get_document return document_data.value(); } -OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data_for(const String& file) +OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data_for(String const& file) { if (m_unfinished_documents.contains(file)) { return {}; @@ -56,22 +56,22 @@ OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_docu return create_document_data(document->text(), file); } -void CppComprehensionEngine::set_document_data(const String& file, OwnPtr<DocumentData>&& data) +void CppComprehensionEngine::set_document_data(String const& file, OwnPtr<DocumentData>&& data) { m_documents.set(filedb().to_absolute_path(file), move(data)); } -Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) +Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::get_suggestions(String const& file, const GUI::TextPosition& autocomplete_position) { Cpp::Position position { autocomplete_position.line(), autocomplete_position.column() > 0 ? autocomplete_position.column() - 1 : 0 }; dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "CppComprehensionEngine position {}:{}", position.line, position.column); - const auto* document_ptr = get_or_create_document_data(file); + auto const* document_ptr = get_or_create_document_data(file); if (!document_ptr) return {}; - const auto& document = *document_ptr; + auto const& document = *document_ptr; auto containing_token = document.parser().token_at(position); if (containing_token.has_value() && containing_token->type() == Token::Type::IncludePath) { @@ -102,7 +102,7 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::get_suggestions return {}; } -Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_name(const DocumentData& document, const ASTNode& node, Optional<Token> containing_token) const +Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_name(DocumentData const& document, ASTNode const& node, Optional<Token> containing_token) const { auto partial_text = String::empty(); if (containing_token.has_value() && containing_token.value().type() != Token::Type::ColonColon) { @@ -111,7 +111,7 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a return autocomplete_name(document, node, partial_text); } -Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_property(const DocumentData& document, const ASTNode& node, Optional<Token> containing_token) const +Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_property(DocumentData const& document, ASTNode const& node, Optional<Token> containing_token) const { if (!containing_token.has_value()) return {}; @@ -119,7 +119,7 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a if (!node.parent()->is_member_expression()) return {}; - const auto& parent = static_cast<const MemberExpression&>(*node.parent()); + auto const& parent = static_cast<MemberExpression const&>(*node.parent()); auto partial_text = String::empty(); if (containing_token.value().type() != Token::Type::Dot) { @@ -131,12 +131,12 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a return autocomplete_property(document, parent, partial_text); } -Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_name(const DocumentData& document, const ASTNode& node, const String& partial_text) const +Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_name(DocumentData const& document, ASTNode const& node, String const& partial_text) const { auto reference_scope = scope_of_reference_to_symbol(node); auto current_scope = scope_of_node(node); - auto symbol_matches = [&](const Symbol& symbol) { + auto symbol_matches = [&](Symbol const& symbol) { if (!is_symbol_available(symbol, current_scope, reference_scope)) { return false; } @@ -156,7 +156,7 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_na Vector<Symbol> matches; - for_each_available_symbol(document, [&](const Symbol& symbol) { + for_each_available_symbol(document, [&](Symbol const& symbol) { if (symbol_matches(symbol)) { matches.append(symbol); } @@ -179,17 +179,17 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_na return suggestions; } -Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(const ASTNode& node) const +Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(ASTNode const& node) const { - const Name* name = nullptr; + Name const* name = nullptr; if (node.is_name()) { // FIXME It looks like this code path is never taken - name = reinterpret_cast<const Name*>(&node); + name = reinterpret_cast<Name const*>(&node); } else if (node.is_identifier()) { auto* parent = node.parent(); if (!(parent && parent->is_name())) return {}; - name = reinterpret_cast<const Name*>(parent); + name = reinterpret_cast<Name const*>(parent); } else { return {}; } @@ -206,7 +206,7 @@ Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(const AS return scope_parts; } -Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_property(const DocumentData& document, const MemberExpression& parent, const String partial_text) const +Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, const String partial_text) const { VERIFY(parent.object()); auto type = type_of(document, *parent.object()); @@ -224,7 +224,7 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_pr return suggestions; } -bool CppComprehensionEngine::is_property(const ASTNode& node) const +bool CppComprehensionEngine::is_property(ASTNode const& node) const { if (!node.parent()->is_member_expression()) return false; @@ -233,7 +233,7 @@ bool CppComprehensionEngine::is_property(const ASTNode& node) const return parent.property() == &node; } -String CppComprehensionEngine::type_of_property(const DocumentData& document, const Identifier& identifier) const +String CppComprehensionEngine::type_of_property(DocumentData const& document, Identifier const& identifier) const { auto& parent = verify_cast<MemberExpression>(*identifier.parent()); VERIFY(parent.object()); @@ -241,7 +241,7 @@ String CppComprehensionEngine::type_of_property(const DocumentData& document, co for (auto& prop : properties) { if (prop.name.name != identifier.name()) continue; - const Type* type { nullptr }; + Type const* type { nullptr }; if (prop.declaration->is_variable_declaration()) { type = verify_cast<VariableDeclaration>(*prop.declaration).type(); } @@ -258,9 +258,9 @@ String CppComprehensionEngine::type_of_property(const DocumentData& document, co return {}; } -String CppComprehensionEngine::type_of_variable(const Identifier& identifier) const +String CppComprehensionEngine::type_of_variable(Identifier const& identifier) const { - const ASTNode* current = &identifier; + ASTNode const* current = &identifier; while (current) { for (auto& decl : current->declarations()) { if (decl.is_variable_or_parameter_declaration()) { @@ -278,21 +278,21 @@ String CppComprehensionEngine::type_of_variable(const Identifier& identifier) co return {}; } -String CppComprehensionEngine::type_of(const DocumentData& document, const Expression& expression) const +String CppComprehensionEngine::type_of(DocumentData const& document, Expression const& expression) const { if (expression.is_member_expression()) { auto& member_expression = verify_cast<MemberExpression>(expression); VERIFY(member_expression.property()); if (member_expression.property()->is_identifier()) - return type_of_property(document, static_cast<const Identifier&>(*member_expression.property())); + return type_of_property(document, static_cast<Identifier const&>(*member_expression.property())); return {}; } - const Identifier* identifier { nullptr }; + Identifier const* identifier { nullptr }; if (expression.is_name()) { - identifier = static_cast<const Name&>(expression).name(); + identifier = static_cast<Name const&>(expression).name(); } else if (expression.is_identifier()) { - identifier = &static_cast<const Identifier&>(expression); + identifier = &static_cast<Identifier const&>(expression); } else { dbgln("expected identifier or name, got: {}", expression.class_name()); VERIFY_NOT_REACHED(); // TODO @@ -304,7 +304,7 @@ String CppComprehensionEngine::type_of(const DocumentData& document, const Expre return type_of_variable(*identifier); } -Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_type(const DocumentData& document, const String& type) const +Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_type(DocumentData const& document, String const& type) const { auto type_symbol = SymbolName::create(type); auto decl = find_declaration_of(document, type_symbol); @@ -331,17 +331,17 @@ Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_typ return properties; } -CppComprehensionEngine::Symbol CppComprehensionEngine::Symbol::create(StringView name, const Vector<StringView>& scope, NonnullRefPtr<Declaration> declaration, IsLocal is_local) +CppComprehensionEngine::Symbol CppComprehensionEngine::Symbol::create(StringView name, Vector<StringView> const& scope, NonnullRefPtr<Declaration> declaration, IsLocal is_local) { return { { name, scope }, move(declaration), is_local == IsLocal::Yes }; } -Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols(const ASTNode& node) const +Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols(ASTNode const& node) const { return get_child_symbols(node, {}, Symbol::IsLocal::No); } -Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols(const ASTNode& node, const Vector<StringView>& scope, Symbol::IsLocal is_local) const +Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols(ASTNode const& node, Vector<StringView> const& scope, Symbol::IsLocal is_local) const { Vector<Symbol> symbols; @@ -391,23 +391,23 @@ String CppComprehensionEngine::document_path_from_include_path(StringView includ return result; } -void CppComprehensionEngine::on_edit(const String& file) +void CppComprehensionEngine::on_edit(String const& file) { set_document_data(file, create_document_data_for(file)); } -void CppComprehensionEngine::file_opened([[maybe_unused]] const String& file) +void CppComprehensionEngine::file_opened([[maybe_unused]] String const& file) { get_or_create_document_data(file); } -Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) +Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position) { - const auto* document_ptr = get_or_create_document_data(filename); + auto const* document_ptr = get_or_create_document_data(filename); if (!document_ptr) return {}; - const auto& document = *document_ptr; + auto const& document = *document_ptr; auto decl = find_declaration_of(document, identifier_position); if (decl) { return GUI::AutocompleteProvider::ProjectLocation { decl->filename(), decl->start().line, decl->start().column }; @@ -416,7 +416,7 @@ Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::fin return find_preprocessor_definition(document, identifier_position); } -RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentData& document, const GUI::TextPosition& identifier_position) +RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(DocumentData const& document, const GUI::TextPosition& identifier_position) { auto node = document.parser().node_at(Cpp::Position { identifier_position.line(), identifier_position.column() }); if (!node) { @@ -426,7 +426,7 @@ RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentDa return find_declaration_of(document, *node); } -Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::find_preprocessor_definition(const DocumentData& document, const GUI::TextPosition& text_position) +Optional<GUI::AutocompleteProvider::ProjectLocation> CppComprehensionEngine::find_preprocessor_definition(DocumentData const& document, const GUI::TextPosition& text_position) { Position cpp_position { text_position.line(), text_position.column() }; auto substitution = find_preprocessor_substitution(document, cpp_position); @@ -459,11 +459,11 @@ struct TargetDeclaration { String name; }; -static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node, String name); -static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node) +static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, String name); +static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node) { if (node.is_identifier()) { - return get_target_declaration(node, static_cast<const Identifier&>(node).name()); + return get_target_declaration(node, static_cast<Identifier const&>(node).name()); } if (node.is_declaration()) { @@ -478,7 +478,7 @@ static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node) return {}; } -static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node, String name) +static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, String name) { if (node.parent() && node.parent()->is_name()) { auto& name_node = *verify_cast<Name>(node.parent()); @@ -509,7 +509,7 @@ static Optional<TargetDeclaration> get_target_declaration(const ASTNode& node, S return TargetDeclaration { TargetDeclaration::Type::Variable, name }; } -RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentData& document_data, const ASTNode& node) const +RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(DocumentData const& document_data, ASTNode const& node) const { dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "find_declaration_of: {} ({})", document_data.parser().text_of_node(node), node.class_name()); @@ -520,7 +520,7 @@ RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentDa auto reference_scope = scope_of_reference_to_symbol(node); auto current_scope = scope_of_node(node); - auto symbol_matches = [&](const Symbol& symbol) { + auto symbol_matches = [&](Symbol const& symbol) { bool match_function = target_decl.value().type == TargetDeclaration::Function && symbol.declaration->is_function(); bool match_variable = target_decl.value().type == TargetDeclaration::Variable && symbol.declaration->is_variable_declaration(); bool match_type = target_decl.value().type == TargetDeclaration::Type && (symbol.declaration->is_struct_or_class() || symbol.declaration->is_enum()); @@ -558,7 +558,7 @@ RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const DocumentDa Optional<Symbol> match; - for_each_available_symbol(document_data, [&](const Symbol& symbol) { + for_each_available_symbol(document_data, [&](Symbol const& symbol) { if (symbol_matches(symbol)) { match = symbol; return IterationDecision::Break; @@ -595,7 +595,7 @@ void CppComprehensionEngine::update_todo_entries(DocumentData& document) set_todo_entries_of_document(document.filename(), document.parser().get_todo_entries()); } -GUI::AutocompleteProvider::DeclarationType CppComprehensionEngine::type_of_declaration(const Declaration& decl) +GUI::AutocompleteProvider::DeclarationType CppComprehensionEngine::type_of_declaration(Declaration const& decl) { if (decl.is_struct()) return GUI::AutocompleteProvider::DeclarationType::Struct; @@ -612,7 +612,7 @@ GUI::AutocompleteProvider::DeclarationType CppComprehensionEngine::type_of_decla return GUI::AutocompleteProvider::DeclarationType::Variable; } -OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data(String&& text, const String& filename) +OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data(String&& text, String const& filename) { auto document_data = make<DocumentData>(); document_data->m_filename = filename; @@ -657,7 +657,7 @@ OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_docu return document_data; } -Vector<StringView> CppComprehensionEngine::scope_of_node(const ASTNode& node) const +Vector<StringView> CppComprehensionEngine::scope_of_node(ASTNode const& node) const { auto parent = node.parent(); @@ -683,7 +683,7 @@ Vector<StringView> CppComprehensionEngine::scope_of_node(const ASTNode& node) co return parent_scope; } -Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_include(const DocumentData&, Token include_path_token, Cpp::Position const& cursor_position) const +Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_autocomplete_include(DocumentData const&, Token include_path_token, Cpp::Position const& cursor_position) const { VERIFY(include_path_token.type() == Token::Type::IncludePath); auto partial_include = include_path_token.text().trim_whitespace(); @@ -751,10 +751,10 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a return options; } -RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(const CppComprehensionEngine::DocumentData& document, const CppComprehensionEngine::SymbolName& target_symbol_name) const +RefPtr<Declaration> CppComprehensionEngine::find_declaration_of(CppComprehensionEngine::DocumentData const& document, CppComprehensionEngine::SymbolName const& target_symbol_name) const { RefPtr<Declaration> target_declaration; - for_each_available_symbol(document, [&](const Symbol& symbol) { + for_each_available_symbol(document, [&](Symbol const& symbol) { if (symbol.name == target_symbol_name) { target_declaration = symbol.declaration; return IterationDecision::Break; @@ -797,7 +797,7 @@ String CppComprehensionEngine::SymbolName::to_string() const return String::formatted("{}::{}", scope_as_string(), name); } -bool CppComprehensionEngine::is_symbol_available(const Symbol& symbol, const Vector<StringView>& current_scope, const Vector<StringView>& reference_scope) +bool CppComprehensionEngine::is_symbol_available(Symbol const& symbol, Vector<StringView> const& current_scope, Vector<StringView> const& reference_scope) { if (!reference_scope.is_empty()) { @@ -818,13 +818,13 @@ bool CppComprehensionEngine::is_symbol_available(const Symbol& symbol, const Vec return true; } -Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get_function_params_hint(const String& filename, const GUI::TextPosition& identifier_position) +Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get_function_params_hint(String const& filename, const GUI::TextPosition& identifier_position) { - const auto* document_ptr = get_or_create_document_data(filename); + auto const* document_ptr = get_or_create_document_data(filename); if (!document_ptr) return {}; - const auto& document = *document_ptr; + auto const& document = *document_ptr; Cpp::Position cpp_position { identifier_position.line(), identifier_position.column() }; auto node = document.parser().node_at(cpp_position); if (!node) { @@ -883,7 +883,7 @@ Optional<CppComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get FunctionCall& call_node, size_t argument_index) { - const Identifier* callee = nullptr; + Identifier const* callee = nullptr; VERIFY(call_node.callee()); if (call_node.callee()->is_identifier()) { callee = verify_cast<Identifier>(call_node.callee()); @@ -929,15 +929,15 @@ Optional<CppComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get return hint; } -Vector<GUI::AutocompleteProvider::TokenInfo> CppComprehensionEngine::get_tokens_info(const String& filename) +Vector<GUI::AutocompleteProvider::TokenInfo> CppComprehensionEngine::get_tokens_info(String const& filename) { dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "CppComprehensionEngine::get_tokens_info: {}", filename); - const auto* document_ptr = get_or_create_document_data(filename); + auto const* document_ptr = get_or_create_document_data(filename); if (!document_ptr) return {}; - const auto& document = *document_ptr; + auto const& document = *document_ptr; Vector<GUI::AutocompleteProvider::TokenInfo> tokens_info; size_t i = 0; diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.h b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.h index 91eb1f1b64..0473480d1d 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.h @@ -23,14 +23,14 @@ using namespace ::Cpp; class CppComprehensionEngine : public CodeComprehensionEngine { public: - CppComprehensionEngine(const FileDB& filedb); + CppComprehensionEngine(FileDB const& filedb); - virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) override; - virtual void on_edit(const String& file) override; - virtual void file_opened([[maybe_unused]] const String& file) override; - virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) override; - virtual Optional<FunctionParamsHint> get_function_params_hint(const String&, const GUI::TextPosition&) override; - virtual Vector<GUI::AutocompleteProvider::TokenInfo> get_tokens_info(const String& filename) override; + virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(String const& file, const GUI::TextPosition& autocomplete_position) override; + virtual void on_edit(String const& file) override; + virtual void file_opened([[maybe_unused]] String const& file) override; + virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position) override; + virtual Optional<FunctionParamsHint> get_function_params_hint(String const&, const GUI::TextPosition&) override; + virtual Vector<GUI::AutocompleteProvider::TokenInfo> get_tokens_info(String const& filename) override; private: struct SymbolName { @@ -42,7 +42,7 @@ private: String scope_as_string() const; String to_string() const; - bool operator==(const SymbolName&) const = default; + bool operator==(SymbolName const&) const = default; }; struct Symbol { @@ -57,15 +57,15 @@ private: No, Yes }; - static Symbol create(StringView name, const Vector<StringView>& scope, NonnullRefPtr<Declaration>, IsLocal is_local); + static Symbol create(StringView name, Vector<StringView> const& scope, NonnullRefPtr<Declaration>, IsLocal is_local); }; friend Traits<SymbolName>; struct DocumentData { - const String& filename() const { return m_filename; } - const String& text() const { return m_text; } - const Preprocessor& preprocessor() const + String const& filename() const { return m_filename; } + String const& text() const { return m_text; } + Preprocessor const& preprocessor() const { VERIFY(m_preprocessor); return *m_preprocessor; @@ -75,7 +75,7 @@ private: VERIFY(m_preprocessor); return *m_preprocessor; } - const Parser& parser() const + Parser const& parser() const { VERIFY(m_parser); return *m_parser; @@ -95,52 +95,52 @@ private: HashTable<String> m_available_headers; }; - Vector<GUI::AutocompleteProvider::Entry> autocomplete_property(const DocumentData&, const MemberExpression&, const String partial_text) const; - Vector<GUI::AutocompleteProvider::Entry> autocomplete_name(const DocumentData&, const ASTNode&, const String& partial_text) const; - String type_of(const DocumentData&, const Expression&) const; - String type_of_property(const DocumentData&, const Identifier&) const; - String type_of_variable(const Identifier&) const; - bool is_property(const ASTNode&) const; - RefPtr<Declaration> find_declaration_of(const DocumentData&, const ASTNode&) const; - RefPtr<Declaration> find_declaration_of(const DocumentData&, const SymbolName&) const; - RefPtr<Declaration> find_declaration_of(const DocumentData&, const GUI::TextPosition& identifier_position); + Vector<GUI::AutocompleteProvider::Entry> autocomplete_property(DocumentData const&, MemberExpression const&, const String partial_text) const; + Vector<GUI::AutocompleteProvider::Entry> autocomplete_name(DocumentData const&, ASTNode const&, String const& partial_text) const; + String type_of(DocumentData const&, Expression const&) const; + String type_of_property(DocumentData const&, Identifier const&) const; + String type_of_variable(Identifier const&) const; + bool is_property(ASTNode const&) const; + RefPtr<Declaration> find_declaration_of(DocumentData const&, ASTNode const&) const; + RefPtr<Declaration> find_declaration_of(DocumentData const&, SymbolName const&) const; + RefPtr<Declaration> find_declaration_of(DocumentData const&, const GUI::TextPosition& identifier_position); enum class RecurseIntoScopes { No, Yes }; - Vector<Symbol> properties_of_type(const DocumentData& document, const String& type) const; - Vector<Symbol> get_child_symbols(const ASTNode&) const; - Vector<Symbol> get_child_symbols(const ASTNode&, const Vector<StringView>& scope, Symbol::IsLocal) const; + Vector<Symbol> properties_of_type(DocumentData const& document, String const& type) const; + Vector<Symbol> get_child_symbols(ASTNode const&) const; + Vector<Symbol> get_child_symbols(ASTNode const&, Vector<StringView> const& scope, Symbol::IsLocal) const; - const DocumentData* get_document_data(const String& file) const; - const DocumentData* get_or_create_document_data(const String& file); - void set_document_data(const String& file, OwnPtr<DocumentData>&& data); + DocumentData const* get_document_data(String const& file) const; + DocumentData const* get_or_create_document_data(String const& file); + void set_document_data(String const& file, OwnPtr<DocumentData>&& data); - OwnPtr<DocumentData> create_document_data_for(const String& file); + OwnPtr<DocumentData> create_document_data_for(String const& file); String document_path_from_include_path(StringView include_path) const; void update_declared_symbols(DocumentData&); void update_todo_entries(DocumentData&); - GUI::AutocompleteProvider::DeclarationType type_of_declaration(const Declaration&); - Vector<StringView> scope_of_node(const ASTNode&) const; - Vector<StringView> scope_of_reference_to_symbol(const ASTNode&) const; + GUI::AutocompleteProvider::DeclarationType type_of_declaration(Declaration const&); + Vector<StringView> scope_of_node(ASTNode const&) const; + Vector<StringView> scope_of_reference_to_symbol(ASTNode const&) const; - Optional<GUI::AutocompleteProvider::ProjectLocation> find_preprocessor_definition(const DocumentData&, const GUI::TextPosition&); + Optional<GUI::AutocompleteProvider::ProjectLocation> find_preprocessor_definition(DocumentData const&, const GUI::TextPosition&); Optional<Cpp::Preprocessor::Substitution> find_preprocessor_substitution(DocumentData const&, Cpp::Position const&); - OwnPtr<DocumentData> create_document_data(String&& text, const String& filename); - Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_property(const DocumentData&, const ASTNode&, Optional<Token> containing_token) const; - Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_name(const DocumentData&, const ASTNode&, Optional<Token> containing_token) const; - Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_include(const DocumentData&, Token include_path_token, Cpp::Position const& cursor_position) const; - static bool is_symbol_available(const Symbol&, const Vector<StringView>& current_scope, const Vector<StringView>& reference_scope); + OwnPtr<DocumentData> create_document_data(String&& text, String const& filename); + Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_property(DocumentData const&, ASTNode const&, Optional<Token> containing_token) const; + Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_name(DocumentData const&, ASTNode const&, Optional<Token> containing_token) const; + Optional<Vector<GUI::AutocompleteProvider::Entry>> try_autocomplete_include(DocumentData const&, Token include_path_token, Cpp::Position const& cursor_position) const; + static bool is_symbol_available(Symbol const&, Vector<StringView> const& current_scope, Vector<StringView> const& reference_scope); Optional<FunctionParamsHint> get_function_params_hint(DocumentData const&, FunctionCall&, size_t argument_index); template<typename Func> - void for_each_available_symbol(const DocumentData&, Func) const; + void for_each_available_symbol(DocumentData const&, Func) const; template<typename Func> - void for_each_included_document_recursive(const DocumentData&, Func) const; + void for_each_included_document_recursive(DocumentData const&, Func) const; GUI::AutocompleteProvider::TokenInfo::SemanticType get_token_semantic_type(DocumentData const&, Token const&); GUI::AutocompleteProvider::TokenInfo::SemanticType get_semantic_type_for_identifier(DocumentData const&, Position); @@ -154,7 +154,7 @@ private: }; template<typename Func> -void CppComprehensionEngine::for_each_available_symbol(const DocumentData& document, Func func) const +void CppComprehensionEngine::for_each_available_symbol(DocumentData const& document, Func func) const { for (auto& item : document.m_symbols) { auto decision = func(item.value); @@ -162,7 +162,7 @@ void CppComprehensionEngine::for_each_available_symbol(const DocumentData& docum return; } - for_each_included_document_recursive(document, [&](const DocumentData& document) { + for_each_included_document_recursive(document, [&](DocumentData const& document) { for (auto& item : document.m_symbols) { auto decision = func(item.value); if (decision == IterationDecision::Break) @@ -173,7 +173,7 @@ void CppComprehensionEngine::for_each_available_symbol(const DocumentData& docum } template<typename Func> -void CppComprehensionEngine::for_each_included_document_recursive(const DocumentData& document, Func func) const +void CppComprehensionEngine::for_each_included_document_recursive(DocumentData const& document, Func func) const { for (auto& included_path : document.m_available_headers) { auto* included_document = get_document_data(included_path); @@ -190,7 +190,7 @@ namespace AK { template<> struct Traits<LanguageServers::Cpp::CppComprehensionEngine::SymbolName> : public GenericTraits<LanguageServers::Cpp::CppComprehensionEngine::SymbolName> { - static unsigned hash(const LanguageServers::Cpp::CppComprehensionEngine::SymbolName& key) + static unsigned hash(LanguageServers::Cpp::CppComprehensionEngine::SymbolName const& key) { unsigned hash = 0; hash = pair_int_hash(hash, string_hash(key.name.characters_without_null_termination(), key.name.length())); diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/Tests.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/Tests.cpp index cb2dd30fa9..14dbd87944 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/Tests.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/Tests.cpp @@ -55,7 +55,7 @@ int run_tests() return s_some_test_failed ? 1 : 0; } -static void add_file(FileDB& filedb, const String& name) +static void add_file(FileDB& filedb, String const& name) { auto file = Core::File::open(LexicalPath::join(TESTS_ROOT_DIR, name).string(), Core::OpenMode::ReadOnly); VERIFY(!file.is_error()); diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp index e3f91b9124..a45882afbe 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp @@ -12,7 +12,7 @@ namespace LanguageServers { -RefPtr<const GUI::TextDocument> FileDB::get(const String& filename) const +RefPtr<const GUI::TextDocument> FileDB::get(String const& filename) const { auto absolute_path = to_absolute_path(filename); auto document_optional = m_open_files.get(absolute_path); @@ -22,15 +22,15 @@ RefPtr<const GUI::TextDocument> FileDB::get(const String& filename) const return *document_optional.value(); } -RefPtr<GUI::TextDocument> FileDB::get(const String& filename) +RefPtr<GUI::TextDocument> FileDB::get(String const& filename) { - auto document = reinterpret_cast<const FileDB*>(this)->get(filename); + auto document = reinterpret_cast<FileDB const*>(this)->get(filename); if (document.is_null()) return nullptr; return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref())); } -RefPtr<const GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& filename) const +RefPtr<const GUI::TextDocument> FileDB::get_or_create_from_filesystem(String const& filename) const { auto absolute_path = to_absolute_path(filename); auto document = get(absolute_path); @@ -39,20 +39,20 @@ RefPtr<const GUI::TextDocument> FileDB::get_or_create_from_filesystem(const Stri return create_from_filesystem(absolute_path); } -RefPtr<GUI::TextDocument> FileDB::get_or_create_from_filesystem(const String& filename) +RefPtr<GUI::TextDocument> FileDB::get_or_create_from_filesystem(String const& filename) { - auto document = reinterpret_cast<const FileDB*>(this)->get_or_create_from_filesystem(filename); + auto document = reinterpret_cast<FileDB const*>(this)->get_or_create_from_filesystem(filename); if (document.is_null()) return nullptr; return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref())); } -bool FileDB::is_open(const String& filename) const +bool FileDB::is_open(String const& filename) const { return m_open_files.contains(to_absolute_path(filename)); } -bool FileDB::add(const String& filename, int fd) +bool FileDB::add(String const& filename, int fd) { auto document = create_from_fd(fd); if (!document) @@ -62,7 +62,7 @@ bool FileDB::add(const String& filename, int fd) return true; } -String FileDB::to_absolute_path(const String& filename) const +String FileDB::to_absolute_path(String const& filename) const { if (LexicalPath { filename }.is_absolute()) { return filename; @@ -72,7 +72,7 @@ String FileDB::to_absolute_path(const String& filename) const return LexicalPath { String::formatted("{}/{}", m_project_root, filename) }.string(); } -RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(const String& filename) const +RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(String const& filename) const { auto file = Core::File::open(to_absolute_path(filename), Core::OpenMode::ReadOnly); if (file.is_error()) { @@ -120,7 +120,7 @@ RefPtr<GUI::TextDocument> FileDB::create_from_file(Core::File& file) const return document; } -void FileDB::on_file_edit_insert_text(const String& filename, const String& inserted_text, size_t start_line, size_t start_column) +void FileDB::on_file_edit_insert_text(String const& filename, String const& inserted_text, size_t start_line, size_t start_column) { VERIFY(is_open(filename)); auto document = get(filename); @@ -131,7 +131,7 @@ void FileDB::on_file_edit_insert_text(const String& filename, const String& inse dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text()); } -void FileDB::on_file_edit_remove_text(const String& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column) +void FileDB::on_file_edit_remove_text(String const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column) { // TODO: If file is not open - need to get its contents // Otherwise- somehow verify that respawned language server is synced with all file contents @@ -148,7 +148,7 @@ void FileDB::on_file_edit_remove_text(const String& filename, size_t start_line, dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text()); } -RefPtr<GUI::TextDocument> FileDB::create_with_content(const String& content) +RefPtr<GUI::TextDocument> FileDB::create_with_content(String const& content) { StringView content_view(content); auto document = GUI::TextDocument::create(&s_default_document_client); @@ -156,7 +156,7 @@ RefPtr<GUI::TextDocument> FileDB::create_with_content(const String& content) return document; } -bool FileDB::add(const String& filename, const String& content) +bool FileDB::add(String const& filename, String const& content) { auto document = create_with_content(content); if (!document) { diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.h b/Userland/DevTools/HackStudio/LanguageServers/FileDB.h index 3e744604fb..c8d64b2182 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.h +++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.h @@ -15,26 +15,26 @@ namespace LanguageServers { class FileDB final { public: - RefPtr<const GUI::TextDocument> get(const String& filename) const; - RefPtr<GUI::TextDocument> get(const String& filename); - RefPtr<const GUI::TextDocument> get_or_create_from_filesystem(const String& filename) const; - RefPtr<GUI::TextDocument> get_or_create_from_filesystem(const String& filename); - bool add(const String& filename, int fd); - bool add(const String& filename, const String& content); + RefPtr<const GUI::TextDocument> get(String const& filename) const; + RefPtr<GUI::TextDocument> get(String const& filename); + RefPtr<const GUI::TextDocument> get_or_create_from_filesystem(String const& filename) const; + RefPtr<GUI::TextDocument> get_or_create_from_filesystem(String const& filename); + bool add(String const& filename, int fd); + bool add(String const& filename, String const& content); - void set_project_root(const String& root_path) { m_project_root = root_path; } - const String& project_root() const { return m_project_root; } + void set_project_root(String const& root_path) { m_project_root = root_path; } + String const& project_root() const { return m_project_root; } - void on_file_edit_insert_text(const String& filename, const String& inserted_text, size_t start_line, size_t start_column); - void on_file_edit_remove_text(const String& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column); - String to_absolute_path(const String& filename) const; - bool is_open(const String& filename) const; + void on_file_edit_insert_text(String const& filename, String const& inserted_text, size_t start_line, size_t start_column); + void on_file_edit_remove_text(String const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column); + String to_absolute_path(String const& filename) const; + bool is_open(String const& filename) const; private: - RefPtr<GUI::TextDocument> create_from_filesystem(const String& filename) const; + RefPtr<GUI::TextDocument> create_from_filesystem(String const& filename) const; RefPtr<GUI::TextDocument> create_from_fd(int fd) const; RefPtr<GUI::TextDocument> create_from_file(Core::File&) const; - static RefPtr<GUI::TextDocument> create_with_content(const String&); + static RefPtr<GUI::TextDocument> create_with_content(String const&); private: HashMap<String, NonnullRefPtr<GUI::TextDocument>> m_open_files; diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h b/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h index 20eff7faf0..7e5ab2682d 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h @@ -20,7 +20,7 @@ private: : LanguageServers::ConnectionFromClient(move(socket)) { m_autocomplete_engine = make<ShellComprehensionEngine>(m_filedb); - m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { + m_autocomplete_engine->set_declarations_of_document_callback = [this](String const& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) { async_declarations_in_document(filename, move(declarations)); }; m_autocomplete_engine->set_todo_entries_of_document_callback = [this](String const& filename, Vector<Cpp::Parser::TodoEntry>&& todo_entries) { diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.cpp index 9b3dcd56ee..090ceaaa3d 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.cpp @@ -14,12 +14,12 @@ namespace LanguageServers::Shell { RefPtr<::Shell::Shell> ShellComprehensionEngine::s_shell {}; -ShellComprehensionEngine::ShellComprehensionEngine(const FileDB& filedb) +ShellComprehensionEngine::ShellComprehensionEngine(FileDB const& filedb) : CodeComprehensionEngine(filedb, true) { } -const ShellComprehensionEngine::DocumentData& ShellComprehensionEngine::get_or_create_document_data(const String& file) +ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_create_document_data(String const& file) { auto absolute_path = filedb().to_absolute_path(file); if (!m_documents.contains(absolute_path)) { @@ -28,7 +28,7 @@ const ShellComprehensionEngine::DocumentData& ShellComprehensionEngine::get_or_c return get_document_data(absolute_path); } -const ShellComprehensionEngine::DocumentData& ShellComprehensionEngine::get_document_data(const String& file) const +ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_document_data(String const& file) const { auto absolute_path = filedb().to_absolute_path(file); auto document_data = m_documents.get(absolute_path); @@ -36,7 +36,7 @@ const ShellComprehensionEngine::DocumentData& ShellComprehensionEngine::get_docu return *document_data.value(); } -OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_document_data_for(const String& file) +OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_document_data_for(String const& file) { auto document = filedb().get(file); if (!document) @@ -50,7 +50,7 @@ OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_ return document_data; } -void ShellComprehensionEngine::set_document_data(const String& file, OwnPtr<DocumentData>&& data) +void ShellComprehensionEngine::set_document_data(String const& file, OwnPtr<DocumentData>&& data) { m_documents.set(filedb().to_absolute_path(file), move(data)); } @@ -62,7 +62,7 @@ ShellComprehensionEngine::DocumentData::DocumentData(String&& _text, String _fil { } -const Vector<String>& ShellComprehensionEngine::DocumentData::sourced_paths() const +Vector<String> const& ShellComprehensionEngine::DocumentData::sourced_paths() const { if (all_sourced_paths.has_value()) return all_sourced_paths.value(); @@ -110,7 +110,7 @@ NonnullRefPtr<::Shell::AST::Node> ShellComprehensionEngine::DocumentData::parse( return ::Shell::AST::make_ref_counted<::Shell::AST::SyntaxError>(::Shell::AST::Position {}, "Unable to parse file"); } -size_t ShellComprehensionEngine::resolve(const ShellComprehensionEngine::DocumentData& document, const GUI::TextPosition& position) +size_t ShellComprehensionEngine::resolve(ShellComprehensionEngine::DocumentData const& document, const GUI::TextPosition& position) { size_t offset = 0; @@ -133,11 +133,11 @@ size_t ShellComprehensionEngine::resolve(const ShellComprehensionEngine::Documen return offset; } -Vector<GUI::AutocompleteProvider::Entry> ShellComprehensionEngine::get_suggestions(const String& file, const GUI::TextPosition& position) +Vector<GUI::AutocompleteProvider::Entry> ShellComprehensionEngine::get_suggestions(String const& file, const GUI::TextPosition& position) { dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "ShellComprehensionEngine position {}:{}", position.line(), position.column()); - const auto& document = get_or_create_document_data(file); + auto const& document = get_or_create_document_data(file); size_t offset_in_file = resolve(document, position); ::Shell::AST::HitTestResult hit_test = document.node->hit_test_position(offset_in_file); @@ -154,20 +154,20 @@ Vector<GUI::AutocompleteProvider::Entry> ShellComprehensionEngine::get_suggestio return entries; } -void ShellComprehensionEngine::on_edit(const String& file) +void ShellComprehensionEngine::on_edit(String const& file) { set_document_data(file, create_document_data_for(file)); } -void ShellComprehensionEngine::file_opened([[maybe_unused]] const String& file) +void ShellComprehensionEngine::file_opened([[maybe_unused]] String const& file) { set_document_data(file, create_document_data_for(file)); } -Optional<GUI::AutocompleteProvider::ProjectLocation> ShellComprehensionEngine::find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) +Optional<GUI::AutocompleteProvider::ProjectLocation> ShellComprehensionEngine::find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position) { dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "find_declaration_of({}, {}:{})", filename, identifier_position.line(), identifier_position.column()); - const auto& document = get_or_create_document_data(filename); + auto const& document = get_or_create_document_data(filename); auto position = resolve(document, identifier_position); auto result = document.node->hit_test_position(position); if (!result.matching_node) { @@ -192,10 +192,10 @@ Optional<GUI::AutocompleteProvider::ProjectLocation> ShellComprehensionEngine::f return {}; } -void ShellComprehensionEngine::update_declared_symbols(const DocumentData& document) +void ShellComprehensionEngine::update_declared_symbols(DocumentData const& document) { struct Visitor : public ::Shell::AST::NodeVisitor { - explicit Visitor(const String& filename) + explicit Visitor(String const& filename) : filename(filename) { } @@ -225,7 +225,7 @@ void ShellComprehensionEngine::update_declared_symbols(const DocumentData& docum declarations.append({ node->name().name, { filename, node->position().start_line.line_number, node->position().start_line.line_column }, GUI::AutocompleteProvider::DeclarationType::Function, {} }); } - const String& filename; + String const& filename; Vector<GUI::AutocompleteProvider::Declaration> declarations; } visitor { document.filename }; diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.h b/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.h index eaf4c64bd9..774a7be45a 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/ShellComprehensionEngine.h @@ -13,11 +13,11 @@ namespace LanguageServers::Shell { class ShellComprehensionEngine : public CodeComprehensionEngine { public: - ShellComprehensionEngine(const FileDB& filedb); - virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& position) override; - virtual void on_edit(const String& file) override; - virtual void file_opened([[maybe_unused]] const String& file) override; - virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String& filename, const GUI::TextPosition& identifier_position) override; + ShellComprehensionEngine(FileDB const& filedb); + virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(String const& file, const GUI::TextPosition& position) override; + virtual void on_edit(String const& file) override; + virtual void file_opened([[maybe_unused]] String const& file) override; + virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position) override; private: struct DocumentData { @@ -26,7 +26,7 @@ private: String text; NonnullRefPtr<::Shell::AST::Node> node; - const Vector<String>& sourced_paths() const; + Vector<String> const& sourced_paths() const; private: NonnullRefPtr<::Shell::AST::Node> parse() const; @@ -34,15 +34,15 @@ private: mutable Optional<Vector<String>> all_sourced_paths {}; }; - const DocumentData& get_document_data(const String& file) const; - const DocumentData& get_or_create_document_data(const String& file); - void set_document_data(const String& file, OwnPtr<DocumentData>&& data); + DocumentData const& get_document_data(String const& file) const; + DocumentData const& get_or_create_document_data(String const& file); + void set_document_data(String const& file, OwnPtr<DocumentData>&& data); - OwnPtr<DocumentData> create_document_data_for(const String& file); + OwnPtr<DocumentData> create_document_data_for(String const& file); String document_path_from_include_path(StringView include_path) const; - void update_declared_symbols(const DocumentData&); + void update_declared_symbols(DocumentData const&); - static size_t resolve(const ShellComprehensionEngine::DocumentData& document, const GUI::TextPosition& position); + static size_t resolve(ShellComprehensionEngine::DocumentData const& document, const GUI::TextPosition& position); ::Shell::Shell& shell() { diff --git a/Userland/DevTools/HackStudio/Locator.cpp b/Userland/DevTools/HackStudio/Locator.cpp index 0e0a4d1379..5470a1db55 100644 --- a/Userland/DevTools/HackStudio/Locator.cpp +++ b/Userland/DevTools/HackStudio/Locator.cpp @@ -21,7 +21,7 @@ namespace HackStudio { class LocatorSuggestionModel final : public GUI::Model { public: struct Suggestion { - static Suggestion create_filename(const String& filename); + static Suggestion create_filename(String const& filename); static Suggestion create_symbol_declaration(const GUI::AutocompleteProvider::Declaration&); bool is_filename() const { return as_filename.has_value(); } @@ -76,13 +76,13 @@ public: return {}; } - const Vector<Suggestion>& suggestions() const { return m_suggestions; } + Vector<Suggestion> const& suggestions() const { return m_suggestions; } private: Vector<Suggestion> m_suggestions; }; -LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(const String& filename) +LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(String const& filename) { LocatorSuggestionModel::Suggestion s; s.as_filename = filename; diff --git a/Userland/DevTools/HackStudio/Project.cpp b/Userland/DevTools/HackStudio/Project.cpp index 561684ec36..ed91439b87 100644 --- a/Userland/DevTools/HackStudio/Project.cpp +++ b/Userland/DevTools/HackStudio/Project.cpp @@ -10,13 +10,13 @@ namespace HackStudio { -Project::Project(const String& root_path) +Project::Project(String const& root_path) : m_root_path(root_path) { m_model = GUI::FileSystemModel::create(root_path, GUI::FileSystemModel::Mode::FilesAndDirectories); } -OwnPtr<Project> Project::open_with_root_path(const String& root_path) +OwnPtr<Project> Project::open_with_root_path(String const& root_path) { if (!Core::File::is_directory(root_path)) return {}; @@ -37,7 +37,7 @@ static void traverse_model(const GUI::FileSystemModel& model, const GUI::ModelIn } } -void Project::for_each_text_file(Function<void(const ProjectFile&)> callback) const +void Project::for_each_text_file(Function<void(ProjectFile const&)> callback) const { traverse_model(model(), {}, [&](auto& index) { auto file = create_file(model().full_path(index)); @@ -45,7 +45,7 @@ void Project::for_each_text_file(Function<void(const ProjectFile&)> callback) co }); } -NonnullRefPtr<ProjectFile> Project::create_file(const String& path) const +NonnullRefPtr<ProjectFile> Project::create_file(String const& path) const { auto full_path = to_absolute_path(path); return ProjectFile::construct_with_name(full_path); diff --git a/Userland/DevTools/HackStudio/Project.h b/Userland/DevTools/HackStudio/Project.h index 573564e02f..7763cfe752 100644 --- a/Userland/DevTools/HackStudio/Project.h +++ b/Userland/DevTools/HackStudio/Project.h @@ -19,21 +19,21 @@ class Project { AK_MAKE_NONMOVABLE(Project); public: - static OwnPtr<Project> open_with_root_path(const String& root_path); + static OwnPtr<Project> open_with_root_path(String const& root_path); GUI::FileSystemModel& model() { return *m_model; } const GUI::FileSystemModel& model() const { return *m_model; } String name() const { return LexicalPath::basename(m_root_path); } String root_path() const { return m_root_path; } - NonnullRefPtr<ProjectFile> create_file(const String& path) const; + NonnullRefPtr<ProjectFile> create_file(String const& path) const; - void for_each_text_file(Function<void(const ProjectFile&)>) const; + void for_each_text_file(Function<void(ProjectFile const&)>) const; String to_absolute_path(String const&) const; bool project_is_serenity() const; private: - explicit Project(const String& root_path); + explicit Project(String const& root_path); RefPtr<GUI::FileSystemModel> m_model; diff --git a/Userland/DevTools/HackStudio/ProjectBuilder.cpp b/Userland/DevTools/HackStudio/ProjectBuilder.cpp index 22cfdbdeba..e5d924fbbb 100644 --- a/Userland/DevTools/HackStudio/ProjectBuilder.cpp +++ b/Userland/DevTools/HackStudio/ProjectBuilder.cpp @@ -98,7 +98,7 @@ ErrorOr<String> ProjectBuilder::component_name(StringView cmake_file_path) { auto content = TRY(Core::File::open(cmake_file_path, Core::OpenMode::ReadOnly))->read_all(); - static const Regex<ECMA262> component_name(R"~~~(serenity_component\([\s]*(\w+)[\s\S]*\))~~~"); + static Regex<ECMA262> const component_name(R"~~~(serenity_component\([\s]*(\w+)[\s\S]*\))~~~"); RegexResult result; if (!component_name.search(StringView { content }, result)) return Error::from_string_literal("component not found"sv); @@ -192,7 +192,7 @@ void ProjectBuilder::for_each_library_definition(Function<void(String, String)> return; } - static const Regex<ECMA262> parse_library_definition(R"~~~(.+:serenity_lib[c]?\((\w+) (\w+)\).*)~~~"); + static Regex<ECMA262> const parse_library_definition(R"~~~(.+:serenity_lib[c]?\((\w+) (\w+)\).*)~~~"); for (auto& line : res.value().output.split('\n')) { RegexResult result; if (!parse_library_definition.search(line, result)) @@ -219,7 +219,7 @@ void ProjectBuilder::for_each_library_dependencies(Function<void(String, Vector< return; } - static const Regex<ECMA262> parse_library_definition(R"~~~(.+:target_link_libraries\((\w+) ([\w\s]+)\).*)~~~"); + static Regex<ECMA262> const parse_library_definition(R"~~~(.+:target_link_libraries\((\w+) ([\w\s]+)\).*)~~~"); for (auto& line : res.value().output.split('\n')) { RegexResult result; diff --git a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp index 4e75eaa580..8828de0418 100644 --- a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp +++ b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp @@ -11,7 +11,7 @@ HackStudio::ProjectDeclarations& HackStudio::ProjectDeclarations::the() static ProjectDeclarations s_instance; return s_instance; } -void HackStudio::ProjectDeclarations::set_declared_symbols(const String& filename, const Vector<GUI::AutocompleteProvider::Declaration>& declarations) +void HackStudio::ProjectDeclarations::set_declared_symbols(String const& filename, Vector<GUI::AutocompleteProvider::Declaration> const& declarations) { m_document_to_declarations.set(filename, declarations); if (on_update) diff --git a/Userland/DevTools/HackStudio/ProjectDeclarations.h b/Userland/DevTools/HackStudio/ProjectDeclarations.h index e7ffd5b4b0..70c2a15d4a 100644 --- a/Userland/DevTools/HackStudio/ProjectDeclarations.h +++ b/Userland/DevTools/HackStudio/ProjectDeclarations.h @@ -23,7 +23,7 @@ public: template<typename Func> void for_each_declared_symbol(Func); - void set_declared_symbols(const String& filename, const Vector<GUI::AutocompleteProvider::Declaration>&); + void set_declared_symbols(String const& filename, Vector<GUI::AutocompleteProvider::Declaration> const&); static Optional<GUI::Icon> get_icon_for(GUI::AutocompleteProvider::DeclarationType); diff --git a/Userland/DevTools/HackStudio/ProjectFile.cpp b/Userland/DevTools/HackStudio/ProjectFile.cpp index 90136b2fdd..70e8b9073d 100644 --- a/Userland/DevTools/HackStudio/ProjectFile.cpp +++ b/Userland/DevTools/HackStudio/ProjectFile.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -ProjectFile::ProjectFile(const String& name) +ProjectFile::ProjectFile(String const& name) : m_name(name) { } diff --git a/Userland/DevTools/HackStudio/ProjectFile.h b/Userland/DevTools/HackStudio/ProjectFile.h index 72fc3e7a24..e2b3c96404 100644 --- a/Userland/DevTools/HackStudio/ProjectFile.h +++ b/Userland/DevTools/HackStudio/ProjectFile.h @@ -16,12 +16,12 @@ namespace HackStudio { class ProjectFile : public RefCounted<ProjectFile> { public: - static NonnullRefPtr<ProjectFile> construct_with_name(const String& name) + static NonnullRefPtr<ProjectFile> construct_with_name(String const& name) { return adopt_ref(*new ProjectFile(name)); } - const String& name() const { return m_name; } + String const& name() const { return m_name; } bool could_render_text() const { return m_could_render_text; } GUI::TextDocument& document() const; @@ -33,7 +33,7 @@ public: void horizontal_scroll_value(int); private: - explicit ProjectFile(const String& name); + explicit ProjectFile(String const& name); void create_document_if_needed() const; String m_name; diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp index 2f823c9143..ad265b9b72 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp +++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp @@ -19,7 +19,7 @@ namespace HackStudio { -ProjectTemplate::ProjectTemplate(const String& id, const String& name, const String& description, const GUI::Icon& icon, int priority) +ProjectTemplate::ProjectTemplate(String const& id, String const& name, String const& description, const GUI::Icon& icon, int priority) : m_id(id) , m_name(name) , m_description(description) @@ -28,7 +28,7 @@ ProjectTemplate::ProjectTemplate(const String& id, const String& name, const Str { } -RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(const String& manifest_path) +RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(String const& manifest_path) { auto maybe_config = Core::ConfigFile::open(manifest_path); if (maybe_config.is_error()) @@ -61,7 +61,7 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(const String& manife return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority)); } -Result<void, String> ProjectTemplate::create_project(const String& name, const String& path) +Result<void, String> ProjectTemplate::create_project(String const& name, String const& path) { // Check if a file or directory already exists at the project path if (Core::File::exists(path)) @@ -97,7 +97,7 @@ Result<void, String> ProjectTemplate::create_project(const String& name, const S auto namespace_safe = name.replace("-", "_", true); pid_t child_pid; - const char* argv[] = { postcreate_script_path.characters(), name.characters(), path.characters(), namespace_safe.characters(), nullptr }; + char const* argv[] = { postcreate_script_path.characters(), name.characters(), path.characters(), namespace_safe.characters(), nullptr }; if ((errno = posix_spawn(&child_pid, postcreate_script_path.characters(), nullptr, nullptr, const_cast<char**>(argv), environ))) { perror("posix_spawn"); diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.h b/Userland/DevTools/HackStudio/ProjectTemplate.h index 35f09bd70d..7a42e90d5d 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.h +++ b/Userland/DevTools/HackStudio/ProjectTemplate.h @@ -20,15 +20,15 @@ class ProjectTemplate : public RefCounted<ProjectTemplate> { public: static String templates_path() { return "/res/devel/templates"; } - static RefPtr<ProjectTemplate> load_from_manifest(const String& manifest_path); + static RefPtr<ProjectTemplate> load_from_manifest(String const& manifest_path); - explicit ProjectTemplate(const String& id, const String& name, const String& description, const GUI::Icon& icon, int priority); + explicit ProjectTemplate(String const& id, String const& name, String const& description, const GUI::Icon& icon, int priority); - Result<void, String> create_project(const String& name, const String& path); + Result<void, String> create_project(String const& name, String const& path); - const String& id() const { return m_id; } - const String& name() const { return m_name; } - const String& description() const { return m_description; } + String const& id() const { return m_id; } + String const& name() const { return m_name; } + String const& description() const { return m_description; } const GUI::Icon& icon() const { return m_icon; } const String content_path() const { diff --git a/Userland/DevTools/HackStudio/TerminalWrapper.cpp b/Userland/DevTools/HackStudio/TerminalWrapper.cpp index de85ad006d..1c1ee04c0b 100644 --- a/Userland/DevTools/HackStudio/TerminalWrapper.cpp +++ b/Userland/DevTools/HackStudio/TerminalWrapper.cpp @@ -24,7 +24,7 @@ namespace HackStudio { -ErrorOr<void> TerminalWrapper::run_command(const String& command, Optional<String> working_directory, WaitForExit wait_for_exit, Optional<StringView> failure_message) +ErrorOr<void> TerminalWrapper::run_command(String const& command, Optional<String> working_directory, WaitForExit wait_for_exit, Optional<StringView> failure_message) { if (m_pid != -1) { GUI::MessageBox::show(window(), @@ -62,7 +62,7 @@ ErrorOr<void> TerminalWrapper::run_command(const String& command, Optional<Strin auto parts = command.split(' '); VERIFY(!parts.is_empty()); - const char** args = (const char**)calloc(parts.size() + 1, sizeof(const char*)); + char const** args = (char const**)calloc(parts.size() + 1, sizeof(char const*)); for (size_t i = 0; i < parts.size(); i++) { args[i] = parts[i].characters(); } diff --git a/Userland/DevTools/HackStudio/TerminalWrapper.h b/Userland/DevTools/HackStudio/TerminalWrapper.h index 128aff05e2..28373a7942 100644 --- a/Userland/DevTools/HackStudio/TerminalWrapper.h +++ b/Userland/DevTools/HackStudio/TerminalWrapper.h @@ -21,7 +21,7 @@ public: No, Yes }; - ErrorOr<void> run_command(const String&, Optional<String> working_directory = {}, WaitForExit = WaitForExit::No, Optional<StringView> failure_message = {}); + ErrorOr<void> run_command(String const&, Optional<String> working_directory = {}, WaitForExit = WaitForExit::No, Optional<StringView> failure_message = {}); ErrorOr<void> kill_running_command(); void clear_including_history(); diff --git a/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp b/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp index f734e45247..1228098553 100644 --- a/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp +++ b/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp @@ -86,7 +86,7 @@ private: void ToDoEntriesWidget::refresh() { - const auto& entries = ToDoEntries::the().get_entries(); + auto const& entries = ToDoEntries::the().get_entries(); auto results_model = adopt_ref(*new ToDoEntriesModel(move(entries))); m_result_view->set_model(results_model); } diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index 0b1cd19290..9473fcdc4d 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) notify_make_not_available(); } - const char* path_argument = nullptr; + char const* path_argument = nullptr; bool mode_coredump = false; Core::ArgsParser args_parser; args_parser.add_positional_argument(path_argument, "Path to a workspace or a file", "path", Core::ArgsParser::Required::No); @@ -94,7 +94,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) static bool make_is_available() { pid_t pid; - const char* argv[] = { "make", "--version", nullptr }; + char const* argv[] = { "make", "--version", nullptr }; posix_spawn_file_actions_t action; posix_spawn_file_actions_init(&action); posix_spawn_file_actions_addopen(&action, STDOUT_FILENO, "/dev/null", O_WRONLY, 0); @@ -147,12 +147,12 @@ GUI::TextEditor& current_editor() return s_hack_studio_widget->current_editor(); } -void open_file(const String& filename) +void open_file(String const& filename) { s_hack_studio_widget->open_file(filename); } -void open_file(const String& filename, size_t line, size_t column) +void open_file(String const& filename, size_t line, size_t column) { s_hack_studio_widget->open_file(filename, line, column); } diff --git a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.cpp b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.cpp index 85f3aa1936..c9f73d000a 100644 --- a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.cpp +++ b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.cpp @@ -17,7 +17,7 @@ RemoteObjectPropertyModel::RemoteObjectPropertyModel(RemoteObject& object) int RemoteObjectPropertyModel::row_count(const GUI::ModelIndex& index) const { - Function<int(const JsonValue&)> do_count = [&](const JsonValue& value) { + Function<int(JsonValue const&)> do_count = [&](JsonValue const& value) { if (value.is_array()) return value.as_array().size(); else if (value.is_object()) @@ -26,7 +26,7 @@ int RemoteObjectPropertyModel::row_count(const GUI::ModelIndex& index) const }; if (index.is_valid()) { - auto* path = static_cast<const JsonPath*>(index.internal_data()); + auto* path = static_cast<JsonPath const*>(index.internal_data()); return do_count(path->resolve(m_object.json)); } else { return do_count(m_object.json); @@ -46,7 +46,7 @@ String RemoteObjectPropertyModel::column_name(int column) const GUI::Variant RemoteObjectPropertyModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const { - auto* path = static_cast<const JsonPath*>(index.internal_data()); + auto* path = static_cast<JsonPath const*>(index.internal_data()); if (!path) return {}; @@ -72,7 +72,7 @@ void RemoteObjectPropertyModel::set_data(const GUI::ModelIndex& index, const GUI if (!index.is_valid()) return; - auto* path = static_cast<const JsonPath*>(index.internal_data()); + auto* path = static_cast<JsonPath const*>(index.internal_data()); if (path->size() != 1) return; @@ -83,9 +83,9 @@ void RemoteObjectPropertyModel::set_data(const GUI::ModelIndex& index, const GUI GUI::ModelIndex RemoteObjectPropertyModel::index(int row, int column, const GUI::ModelIndex& parent) const { - const auto& parent_path = parent.is_valid() ? *static_cast<const JsonPath*>(parent.internal_data()) : JsonPath {}; + auto const& parent_path = parent.is_valid() ? *static_cast<JsonPath const*>(parent.internal_data()) : JsonPath {}; - auto nth_child = [&](int n, const JsonValue& value) -> const JsonPath* { + auto nth_child = [&](int n, JsonValue const& value) -> JsonPath const* { auto path = make<JsonPath>(); path->extend(parent_path); int row_index = n; @@ -135,7 +135,7 @@ GUI::ModelIndex RemoteObjectPropertyModel::parent_index(const GUI::ModelIndex& i if (!index.is_valid()) return index; - auto path = *static_cast<const JsonPath*>(index.internal_data()); + auto path = *static_cast<JsonPath const*>(index.internal_data()); if (path.is_empty()) return {}; @@ -168,12 +168,12 @@ GUI::ModelIndex RemoteObjectPropertyModel::parent_index(const GUI::ModelIndex& i return {}; } -const JsonPath* RemoteObjectPropertyModel::cached_path_at(int n, const Vector<JsonPathElement>& prefix) const +JsonPath const* RemoteObjectPropertyModel::cached_path_at(int n, Vector<JsonPathElement> const& prefix) const { // FIXME: ModelIndex wants a void*, so we have to keep these // indices alive, but allocating a new path every time // we're asked for an index is silly, so we have to look for existing ones first. - const JsonPath* index_path = nullptr; + JsonPath const* index_path = nullptr; int row_index = n; for (auto& path : m_paths) { if (path.size() != prefix.size() + 1) @@ -195,7 +195,7 @@ const JsonPath* RemoteObjectPropertyModel::cached_path_at(int n, const Vector<Js return index_path; }; -const JsonPath* RemoteObjectPropertyModel::find_cached_path(const Vector<JsonPathElement>& path) const +JsonPath const* RemoteObjectPropertyModel::find_cached_path(Vector<JsonPathElement> const& path) const { for (auto& cpath : m_paths) { if (cpath.size() != path.size()) diff --git a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h index 8dc7a3d134..5b724996e0 100644 --- a/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h +++ b/Userland/DevTools/Inspector/RemoteObjectPropertyModel.h @@ -41,8 +41,8 @@ public: private: explicit RemoteObjectPropertyModel(RemoteObject&); - const JsonPath* cached_path_at(int n, const Vector<JsonPathElement>& prefix) const; - const JsonPath* find_cached_path(const Vector<JsonPathElement>& path) const; + JsonPath const* cached_path_at(int n, Vector<JsonPathElement> const& prefix) const; + JsonPath const* find_cached_path(Vector<JsonPathElement> const& path) const; RemoteObject& m_object; mutable NonnullOwnPtrVector<JsonPath> m_paths; diff --git a/Userland/DevTools/Inspector/RemoteProcess.cpp b/Userland/DevTools/Inspector/RemoteProcess.cpp index 20227702f2..5bb52c020b 100644 --- a/Userland/DevTools/Inspector/RemoteProcess.cpp +++ b/Userland/DevTools/Inspector/RemoteProcess.cpp @@ -27,7 +27,7 @@ RemoteProcess::RemoteProcess(pid_t pid) m_client = InspectorServerClient::try_create().release_value_but_fixme_should_propagate_errors(); } -void RemoteProcess::handle_identify_response(const JsonObject& response) +void RemoteProcess::handle_identify_response(JsonObject const& response) { int pid = response.get("pid").to_int(); VERIFY(pid == m_pid); @@ -38,7 +38,7 @@ void RemoteProcess::handle_identify_response(const JsonObject& response) on_update(); } -void RemoteProcess::handle_get_all_objects_response(const JsonObject& response) +void RemoteProcess::handle_get_all_objects_response(JsonObject const& response) { // FIXME: It would be good if we didn't have to make a local copy of the array value here! auto objects = response.get("objects"); @@ -82,7 +82,7 @@ void RemoteProcess::set_inspected_object(FlatPtr address) m_client->async_set_inspected_object(m_pid, address); } -void RemoteProcess::set_property(FlatPtr object, StringView name, const JsonValue& value) +void RemoteProcess::set_property(FlatPtr object, StringView name, JsonValue const& value) { m_client->async_set_object_property(m_pid, object, name, value.to_string()); } diff --git a/Userland/DevTools/Inspector/RemoteProcess.h b/Userland/DevTools/Inspector/RemoteProcess.h index 6f6fd4bc7d..a012424ef1 100644 --- a/Userland/DevTools/Inspector/RemoteProcess.h +++ b/Userland/DevTools/Inspector/RemoteProcess.h @@ -22,24 +22,24 @@ public: void update(); pid_t pid() const { return m_pid; } - const String& process_name() const { return m_process_name; } + String const& process_name() const { return m_process_name; } RemoteObjectGraphModel& object_graph_model() { return *m_object_graph_model; } - const NonnullOwnPtrVector<RemoteObject>& roots() const { return m_roots; } + NonnullOwnPtrVector<RemoteObject> const& roots() const { return m_roots; } void set_inspected_object(FlatPtr); - void set_property(FlatPtr object, StringView name, const JsonValue& value); + void set_property(FlatPtr object, StringView name, JsonValue const& value); bool is_inspectable(); Function<void()> on_update; private: - void handle_get_all_objects_response(const JsonObject&); - void handle_identify_response(const JsonObject&); + void handle_get_all_objects_response(JsonObject const&); + void handle_identify_response(JsonObject const&); - void send_request(const JsonObject&); + void send_request(JsonObject const&); pid_t m_pid { -1 }; String m_process_name; diff --git a/Userland/DevTools/Playground/main.cpp b/Userland/DevTools/Playground/main.cpp index d0cfe3e5ea..f7a2781684 100644 --- a/Userland/DevTools/Playground/main.cpp +++ b/Userland/DevTools/Playground/main.cpp @@ -37,14 +37,14 @@ class UnregisteredWidget final : public GUI::Widget { C_OBJECT(UnregisteredWidget); private: - UnregisteredWidget(const String& class_name); + UnregisteredWidget(String const& class_name); virtual void paint_event(GUI::PaintEvent& event) override; String m_text; }; -UnregisteredWidget::UnregisteredWidget(const String& class_name) +UnregisteredWidget::UnregisteredWidget(String const& class_name) { StringBuilder builder; builder.append(class_name); @@ -72,7 +72,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio thread recvfd sendfd rpath cpath wpath")); - const char* path = nullptr; + char const* path = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(path, "GML file to edit", "file", Core::ArgsParser::Required::No); args_parser.parse(arguments); diff --git a/Userland/DevTools/Profiler/FilesystemEventModel.cpp b/Userland/DevTools/Profiler/FilesystemEventModel.cpp index 96b9835cf1..f673bb0e0e 100644 --- a/Userland/DevTools/Profiler/FilesystemEventModel.cpp +++ b/Userland/DevTools/Profiler/FilesystemEventModel.cpp @@ -108,7 +108,7 @@ GUI::ModelIndex FileEventModel::parent_index(GUI::ModelIndex const& index) const return {}; if (node.parent()->parent()) { - const auto& children = node.parent()->parent()->children(); + auto const& children = node.parent()->parent()->children(); for (size_t row = 0; row < children.size(); ++row) { if (children.at(row).ptr() == node.parent()) { @@ -117,7 +117,7 @@ GUI::ModelIndex FileEventModel::parent_index(GUI::ModelIndex const& index) const } } - const auto& children = node.parent()->children(); + auto const& children = node.parent()->children(); for (size_t row = 0; row < children.size(); ++row) { if (children.at(row).ptr() == &node) { diff --git a/Userland/DevTools/Profiler/Profile.cpp b/Userland/DevTools/Profiler/Profile.cpp index c94426fc0d..c8644a38c7 100644 --- a/Userland/DevTools/Profiler/Profile.cpp +++ b/Userland/DevTools/Profiler/Profile.cpp @@ -388,7 +388,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path it->value->handle_thread_exit(event.tid, event.serial); continue; } else if (type_string == "read"sv) { - const auto string_index = perf_event.get("filename_index"sv).to_number<FlatPtr>(); + auto const string_index = perf_event.get("filename_index"sv).to_number<FlatPtr>(); event.data = Event::ReadData { .fd = perf_event.get("fd"sv).to_number<int>(), .size = perf_event.get("size"sv).to_number<size_t>(), diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.h b/Userland/DevTools/UserspaceEmulator/Emulator.h index 29b113f8ff..4f53aa50c8 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.h +++ b/Userland/DevTools/UserspaceEmulator/Emulator.h @@ -125,8 +125,8 @@ public: private: const String m_executable_path; - const Vector<StringView> m_arguments; - const Vector<String> m_environment; + Vector<StringView> const m_arguments; + Vector<String> const m_environment; SoftMMU m_mmu; NonnullOwnPtr<SoftCPU> m_cpu; diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp index e2b2e668e3..7f10a25c6b 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp @@ -371,11 +371,11 @@ int Emulator::virt$symlink(FlatPtr params_addr) mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); auto target = mmu().copy_buffer_from_vm((FlatPtr)params.target.characters, params.target.length); - params.target.characters = (const char*)target.data(); + params.target.characters = (char const*)target.data(); params.target.length = target.size(); auto link = mmu().copy_buffer_from_vm((FlatPtr)params.linkpath.characters, params.linkpath.length); - params.linkpath.characters = (const char*)link.data(); + params.linkpath.characters = (char const*)link.data(); params.linkpath.length = link.size(); return syscall(SC_symlink, ¶ms); @@ -387,11 +387,11 @@ int Emulator::virt$rename(FlatPtr params_addr) mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); auto new_path = mmu().copy_buffer_from_vm((FlatPtr)params.new_path.characters, params.new_path.length); - params.new_path.characters = (const char*)new_path.data(); + params.new_path.characters = (char const*)new_path.data(); params.new_path.length = new_path.size(); auto old_path = mmu().copy_buffer_from_vm((FlatPtr)params.old_path.characters, params.old_path.length); - params.old_path.characters = (const char*)old_path.data(); + params.old_path.characters = (char const*)old_path.data(); params.old_path.length = old_path.size(); return syscall(SC_rename, ¶ms); @@ -403,11 +403,11 @@ int Emulator::virt$set_coredump_metadata(FlatPtr params_addr) mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); auto key = mmu().copy_buffer_from_vm((FlatPtr)params.key.characters, params.key.length); - params.key.characters = (const char*)key.data(); + params.key.characters = (char const*)key.data(); params.key.length = key.size(); auto value = mmu().copy_buffer_from_vm((FlatPtr)params.value.characters, params.value.length); - params.value.characters = (const char*)value.data(); + params.value.characters = (char const*)value.data(); params.value.length = value.size(); return syscall(SC_set_coredump_metadata, ¶ms); @@ -416,7 +416,7 @@ int Emulator::virt$set_coredump_metadata(FlatPtr params_addr) int Emulator::virt$dbgputstr(FlatPtr characters, int length) { auto buffer = mmu().copy_buffer_from_vm(characters, length); - dbgputstr((const char*)buffer.data(), buffer.size()); + dbgputstr((char const*)buffer.data(), buffer.size()); return 0; } @@ -437,7 +437,7 @@ int Emulator::virt$chown(FlatPtr params_addr) mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); auto path = mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length); - params.path.characters = (const char*)path.data(); + params.path.characters = (char const*)path.data(); params.path.length = path.size(); return syscall(SC_chown, ¶ms); @@ -635,7 +635,7 @@ int Emulator::virt$recvmsg(int sockfd, FlatPtr msg_addr, int flags) mmu().copy_from_vm(mmu_iovs.data(), (FlatPtr)mmu_msg.msg_iov, mmu_msg.msg_iovlen * sizeof(iovec)); Vector<ByteBuffer, 1> buffers; Vector<iovec, 1> iovs; - for (const auto& iov : mmu_iovs) { + for (auto const& iov : mmu_iovs) { auto buffer_result = ByteBuffer::create_uninitialized(iov.iov_len); if (buffer_result.is_error()) return -ENOMEM; @@ -819,7 +819,7 @@ u32 Emulator::virt$open(u32 params_addr) host_params.dirfd = params.dirfd; host_params.mode = params.mode; host_params.options = params.options; - host_params.path.characters = (const char*)path.data(); + host_params.path.characters = (char const*)path.data(); host_params.path.length = path.size(); return syscall(SC_open, &host_params); @@ -1315,7 +1315,7 @@ int Emulator::virt$realpath(FlatPtr params_addr) auto& host_buffer = buffer_result.value(); Syscall::SC_realpath_params host_params; - host_params.path = { (const char*)path.data(), path.size() }; + host_params.path = { (char const*)path.data(), path.size() }; host_params.buffer = { (char*)host_buffer.data(), host_buffer.size() }; int rc = syscall(SC_realpath, &host_params); if (rc < 0) @@ -1587,7 +1587,7 @@ int Emulator::virt$readlink(FlatPtr params_addr) auto& host_buffer = buffer_result.value(); Syscall::SC_readlink_params host_params; - host_params.path = { (const char*)path.data(), path.size() }; + host_params.path = { (char const*)path.data(), path.size() }; host_params.buffer = { (char*)host_buffer.data(), host_buffer.size() }; int rc = syscall(SC_readlink, &host_params); if (rc < 0) diff --git a/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp b/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp index 291d8f8d48..2ba544f9af 100644 --- a/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp +++ b/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp @@ -208,7 +208,7 @@ Mallocation* MallocTracer::find_mallocation_after(FlatPtr address) return found_mallocation; } -void MallocTracer::audit_read(const Region& region, FlatPtr address, size_t size) +void MallocTracer::audit_read(Region const& region, FlatPtr address, size_t size) { if (!m_auditing_enabled) return; @@ -259,7 +259,7 @@ void MallocTracer::audit_read(const Region& region, FlatPtr address, size_t size } } -void MallocTracer::audit_write(const Region& region, FlatPtr address, size_t size) +void MallocTracer::audit_write(Region const& region, FlatPtr address, size_t size) { if (!m_auditing_enabled) return; diff --git a/Userland/DevTools/UserspaceEmulator/MallocTracer.h b/Userland/DevTools/UserspaceEmulator/MallocTracer.h index 8d35d9ed04..fe43d79987 100644 --- a/Userland/DevTools/UserspaceEmulator/MallocTracer.h +++ b/Userland/DevTools/UserspaceEmulator/MallocTracer.h @@ -63,8 +63,8 @@ public: void target_did_realloc(Badge<Emulator>, FlatPtr address, size_t); void target_did_change_chunk_size(Badge<Emulator>, FlatPtr, size_t); - void audit_read(const Region&, FlatPtr address, size_t); - void audit_write(const Region&, FlatPtr address, size_t); + void audit_read(Region const&, FlatPtr address, size_t); + void audit_write(Region const&, FlatPtr address, size_t); void dump_leak_report(); @@ -72,7 +72,7 @@ private: template<typename Callback> void for_each_mallocation(Callback callback) const; - Mallocation* find_mallocation(const Region&, FlatPtr); + Mallocation* find_mallocation(Region const&, FlatPtr); Mallocation* find_mallocation(FlatPtr); Mallocation* find_mallocation_before(FlatPtr); Mallocation* find_mallocation_after(FlatPtr); @@ -89,11 +89,11 @@ private: bool m_auditing_enabled { true }; }; -ALWAYS_INLINE Mallocation* MallocTracer::find_mallocation(const Region& region, FlatPtr address) +ALWAYS_INLINE Mallocation* MallocTracer::find_mallocation(Region const& region, FlatPtr address) { if (!is<MmapRegion>(region)) return nullptr; - if (!static_cast<const MmapRegion&>(region).is_malloc_block()) + if (!static_cast<MmapRegion const&>(region).is_malloc_block()) return nullptr; auto* malloc_data = static_cast<MmapRegion&>(const_cast<Region&>(region)).malloc_metadata(); if (!malloc_data) diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp index 7a2d6a78be..9c525c6ec9 100644 --- a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp +++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp @@ -12,7 +12,7 @@ namespace UserspaceEmulator { -static void* mmap_initialized(size_t bytes, char initial_value, const char* name) +static void* mmap_initialized(size_t bytes, char initial_value, char const* name) { auto* ptr = mmap_with_name(nullptr, bytes, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, name); VERIFY(ptr != MAP_FAILED); diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.h b/Userland/DevTools/UserspaceEmulator/MmapRegion.h index 82ee22a6aa..62d0e50308 100644 --- a/Userland/DevTools/UserspaceEmulator/MmapRegion.h +++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.h @@ -51,7 +51,7 @@ public: MallocRegionMetadata* malloc_metadata() { return m_malloc_metadata; } void set_malloc_metadata(Badge<MallocTracer>, NonnullOwnPtr<MallocRegionMetadata> metadata) { m_malloc_metadata = move(metadata); } - const String& name() const { return m_name; } + String const& name() const { return m_name; } String lib_name() const { if (m_name.contains("Loader.so"sv)) diff --git a/Userland/DevTools/UserspaceEmulator/Range.cpp b/Userland/DevTools/UserspaceEmulator/Range.cpp index 59bfcff501..ca1e13b4f8 100644 --- a/Userland/DevTools/UserspaceEmulator/Range.cpp +++ b/Userland/DevTools/UserspaceEmulator/Range.cpp @@ -9,7 +9,7 @@ namespace UserspaceEmulator { -Vector<Range, 2> Range::carve(const Range& taken) const +Vector<Range, 2> Range::carve(Range const& taken) const { VERIFY((taken.size() % PAGE_SIZE) == 0); Vector<Range, 2> parts; diff --git a/Userland/DevTools/UserspaceEmulator/Range.h b/Userland/DevTools/UserspaceEmulator/Range.h index 31a1d9e09d..29750e0530 100644 --- a/Userland/DevTools/UserspaceEmulator/Range.h +++ b/Userland/DevTools/UserspaceEmulator/Range.h @@ -30,7 +30,7 @@ public: VirtualAddress end() const { return m_base.offset(m_size); } - bool operator==(const Range& other) const + bool operator==(Range const& other) const { return m_base == other.m_base && m_size == other.m_size; } @@ -42,12 +42,12 @@ public: return base >= m_base && base.offset(size) <= end(); } - bool contains(const Range& other) const + bool contains(Range const& other) const { return contains(other.base(), other.size()); } - Vector<Range, 2> carve(const Range&) const; + Vector<Range, 2> carve(Range const&) const; Range split_at(VirtualAddress address) { diff --git a/Userland/DevTools/UserspaceEmulator/RangeAllocator.cpp b/Userland/DevTools/UserspaceEmulator/RangeAllocator.cpp index 8ed75c51cd..d673d7febd 100644 --- a/Userland/DevTools/UserspaceEmulator/RangeAllocator.cpp +++ b/Userland/DevTools/UserspaceEmulator/RangeAllocator.cpp @@ -33,7 +33,7 @@ void RangeAllocator::dump() const } } -void RangeAllocator::carve_at_index(int index, const Range& range) +void RangeAllocator::carve_at_index(int index, Range const& range) { auto remaining_parts = m_available_ranges[index].carve(range); VERIFY(remaining_parts.size() >= 1); @@ -142,7 +142,7 @@ Optional<Range> RangeAllocator::allocate_specific(VirtualAddress base, size_t si return {}; } -void RangeAllocator::deallocate(const Range& range) +void RangeAllocator::deallocate(Range const& range) { VERIFY(m_total_range.contains(range)); VERIFY(range.size()); diff --git a/Userland/DevTools/UserspaceEmulator/RangeAllocator.h b/Userland/DevTools/UserspaceEmulator/RangeAllocator.h index c0957d8021..63f9155d1a 100644 --- a/Userland/DevTools/UserspaceEmulator/RangeAllocator.h +++ b/Userland/DevTools/UserspaceEmulator/RangeAllocator.h @@ -20,16 +20,16 @@ public: Optional<Range> allocate_anywhere(size_t, size_t alignment = PAGE_SIZE); Optional<Range> allocate_specific(VirtualAddress, size_t); Optional<Range> allocate_randomized(size_t, size_t alignment); - void deallocate(const Range&); + void deallocate(Range const&); void reserve_user_range(VirtualAddress, size_t); void dump() const; - bool contains(const Range& range) const { return m_total_range.contains(range); } + bool contains(Range const& range) const { return m_total_range.contains(range); } private: - void carve_at_index(int, const Range&); + void carve_at_index(int, Range const&); Vector<Range> m_available_ranges; Range m_total_range; diff --git a/Userland/DevTools/UserspaceEmulator/Region.h b/Userland/DevTools/UserspaceEmulator/Region.h index 3efea3ad1a..9309ae38a5 100644 --- a/Userland/DevTools/UserspaceEmulator/Region.h +++ b/Userland/DevTools/UserspaceEmulator/Region.h @@ -21,7 +21,7 @@ class Region { public: virtual ~Region() = default; - const Range& range() const { return m_range; } + Range const& range() const { return m_range; } u32 base() const { return m_range.base().get(); } u32 size() const { return m_range.size(); } @@ -63,7 +63,7 @@ public: virtual u8* shadow_data() = 0; Emulator& emulator() { return m_emulator; } - const Emulator& emulator() const { return m_emulator; } + Emulator const& emulator() const { return m_emulator; } template<typename T> bool fast_is() const = delete; diff --git a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp index 5c664d2fdf..50782cd0d9 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -46,7 +46,7 @@ namespace UserspaceEmulator { template<typename T> -ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* message) +ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message) { if (value_with_shadow.is_uninitialized()) [[unlikely]] { reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message); @@ -54,7 +54,7 @@ ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* messag } } -ALWAYS_INLINE void SoftCPU::warn_if_flags_tainted(const char* message) const +ALWAYS_INLINE void SoftCPU::warn_if_flags_tainted(char const* message) const { if (m_flags_tainted) [[unlikely]] { reportln("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n", getpid(), message); @@ -208,7 +208,7 @@ void SoftCPU::push_string(StringView string) m_emulator.mmu().write8({ 0x23, esp().value() + string.length() }, shadow_wrap_as_initialized((u8)'\0')); } -void SoftCPU::push_buffer(const u8* data, size_t size) +void SoftCPU::push_buffer(u8 const* data, size_t size) { set_esp({ esp().value() - size, esp().shadow() }); warn_if_uninitialized(esp(), "push_buffer"); diff --git a/Userland/DevTools/UserspaceEmulator/SoftCPU.h b/Userland/DevTools/UserspaceEmulator/SoftCPU.h index e139a3a810..070d451092 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftCPU.h +++ b/Userland/DevTools/UserspaceEmulator/SoftCPU.h @@ -81,7 +81,7 @@ public: ValueWithShadow<u16> pop16(); void push_string(StringView); - void push_buffer(const u8* data, size_t); + void push_buffer(u8 const* data, size_t); u16 segment(X86::SegmentRegister seg) const { return m_segment[(int)seg]; } u16& segment(X86::SegmentRegister seg) { return m_segment[(int)seg]; } @@ -463,7 +463,7 @@ public: m_flags_tainted = a.is_uninitialized() || b.is_uninitialized() || c.is_uninitialized(); } - void warn_if_flags_tainted(const char* message) const; + void warn_if_flags_tainted(char const* message) const; // ^X86::InstructionStream virtual bool can_read() override { return false; } diff --git a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp index a5146a13e0..67c2bba6a9 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp @@ -28,7 +28,7 @@ } while (0) template<typename T> -ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* message) +ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message) { if (value_with_shadow.is_uninitialized()) [[unlikely]] { reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message); diff --git a/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp b/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp index b11e968a15..ab99784cb7 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp @@ -305,11 +305,11 @@ void SoftMMU::write256(X86::LogicalAddress address, ValueWithShadow<u256> value) region->write256(address.offset() - region->base(), value); } -void SoftMMU::copy_to_vm(FlatPtr destination, const void* source, size_t size) +void SoftMMU::copy_to_vm(FlatPtr destination, void const* source, size_t size) { // FIXME: We should have a way to preserve the shadow data here as well. for (size_t i = 0; i < size; ++i) - write8({ 0x23, destination + i }, shadow_wrap_as_initialized(((const u8*)source)[i])); + write8({ 0x23, destination + i }, shadow_wrap_as_initialized(((u8 const*)source)[i])); } void SoftMMU::copy_from_vm(void* destination, const FlatPtr source, size_t size) @@ -336,7 +336,7 @@ bool SoftMMU::fast_fill_memory8(X86::LogicalAddress address, size_t size, ValueW if (!region->contains(address.offset() + size - 1)) return false; - if (is<MmapRegion>(*region) && static_cast<const MmapRegion&>(*region).is_malloc_block()) { + if (is<MmapRegion>(*region) && static_cast<MmapRegion const&>(*region).is_malloc_block()) { if (auto* tracer = m_emulator.malloc_tracer()) { // FIXME: Add a way to audit an entire range of memory instead of looping here! for (size_t i = 0; i < size; ++i) { @@ -361,7 +361,7 @@ bool SoftMMU::fast_fill_memory32(X86::LogicalAddress address, size_t count, Valu if (!region->contains(address.offset() + (count * sizeof(u32)) - 1)) return false; - if (is<MmapRegion>(*region) && static_cast<const MmapRegion&>(*region).is_malloc_block()) { + if (is<MmapRegion>(*region) && static_cast<MmapRegion const&>(*region).is_malloc_block()) { if (auto* tracer = m_emulator.malloc_tracer()) { // FIXME: Add a way to audit an entire range of memory instead of looping here! for (size_t i = 0; i < count; ++i) { diff --git a/Userland/DevTools/UserspaceEmulator/SoftMMU.h b/Userland/DevTools/UserspaceEmulator/SoftMMU.h index 24f1a27b41..f36bb39bd6 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftMMU.h +++ b/Userland/DevTools/UserspaceEmulator/SoftMMU.h @@ -88,7 +88,7 @@ public: bool fast_fill_memory8(X86::LogicalAddress, size_t size, ValueWithShadow<u8>); bool fast_fill_memory32(X86::LogicalAddress, size_t size, ValueWithShadow<u32>); - void copy_to_vm(FlatPtr destination, const void* source, size_t); + void copy_to_vm(FlatPtr destination, void const* source, size_t); void copy_from_vm(void* destination, const FlatPtr source, size_t); ByteBuffer copy_buffer_from_vm(const FlatPtr source, size_t); diff --git a/Userland/DevTools/UserspaceEmulator/ValueWithShadow.h b/Userland/DevTools/UserspaceEmulator/ValueWithShadow.h index e7ad1988a0..6dc10e0653 100644 --- a/Userland/DevTools/UserspaceEmulator/ValueWithShadow.h +++ b/Userland/DevTools/UserspaceEmulator/ValueWithShadow.h @@ -116,7 +116,7 @@ public: return false; } - ValueAndShadowReference<T>& operator=(const ValueWithShadow<T>&); + ValueAndShadowReference<T>& operator=(ValueWithShadow<T> const&); T shadow_as_value() const requires(IsTriviallyConstructible<T>) { @@ -165,14 +165,14 @@ ALWAYS_INLINE ValueWithShadow<T> shadow_wrap_with_taint_from(T value, U const& t } template<typename T> -inline ValueWithShadow<T>::ValueWithShadow(const ValueAndShadowReference<T>& other) +inline ValueWithShadow<T>::ValueWithShadow(ValueAndShadowReference<T> const& other) : m_value(other.value()) , m_shadow(other.shadow()) { } template<typename T> -inline ValueAndShadowReference<T>& ValueAndShadowReference<T>::operator=(const ValueWithShadow<T>& other) +inline ValueAndShadowReference<T>& ValueAndShadowReference<T>::operator=(ValueWithShadow<T> const& other) { m_value = other.value(); m_shadow = other.shadow(); |