mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:37:36 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)>;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
__Count
|
||||
};
|
||||
|
||||
explicit SearchResultsModel(const Vector<Match>&& matches)
|
||||
explicit SearchResultsModel(Vector<Match> const&& matches)
|
||||
: m_matches(move(matches))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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>);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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&);
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
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(const Vector<GUI::AutocompleteProvider::Entry>&) const;
|
||||
void declaration_found(const String& file, size_t line, size_t column) const;
|
||||
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)
|
||||
|
|
|
@ -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) \
|
||||
{ \
|
||||
} \
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 };
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace HackStudio {
|
||||
|
||||
ProjectFile::ProjectFile(const String& name)
|
||||
ProjectFile::ProjectFile(String const& name)
|
||||
: m_name(name)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue