mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
HackStudio: Use new format functions.
This commit is contained in:
parent
3b601cd4bd
commit
7c4fb2b804
Notes:
sideshowbarker
2024-07-19 01:56:57 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/7c4fb2b8047 Pull-request: https://github.com/SerenityOS/serenity/pull/3731
23 changed files with 112 additions and 117 deletions
|
@ -38,7 +38,7 @@ namespace HackStudio {
|
||||||
void CursorTool::on_mousedown(GUI::MouseEvent& event)
|
void CursorTool::on_mousedown(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CURSOR_TOOL
|
#ifdef DEBUG_CURSOR_TOOL
|
||||||
dbg() << "CursorTool::on_mousedown";
|
dbgln("CursorTool::on_mousedown");
|
||||||
#endif
|
#endif
|
||||||
auto& form_widget = m_editor.form_widget();
|
auto& form_widget = m_editor.form_widget();
|
||||||
auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No);
|
auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No);
|
||||||
|
@ -77,7 +77,7 @@ void CursorTool::on_mousedown(GUI::MouseEvent& event)
|
||||||
void CursorTool::on_mouseup(GUI::MouseEvent& event)
|
void CursorTool::on_mouseup(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CURSOR_TOOL
|
#ifdef DEBUG_CURSOR_TOOL
|
||||||
dbg() << "CursorTool::on_mouseup";
|
dbgln("CursorTool::on_mouseup");
|
||||||
#endif
|
#endif
|
||||||
if (event.button() == GUI::MouseButton::Left) {
|
if (event.button() == GUI::MouseButton::Left) {
|
||||||
auto& form_widget = m_editor.form_widget();
|
auto& form_widget = m_editor.form_widget();
|
||||||
|
@ -98,7 +98,7 @@ void CursorTool::on_mouseup(GUI::MouseEvent& event)
|
||||||
void CursorTool::on_mousemove(GUI::MouseEvent& event)
|
void CursorTool::on_mousemove(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CURSOR_TOOL
|
#ifdef DEBUG_CURSOR_TOOL
|
||||||
dbg() << "CursorTool::on_mousemove";
|
dbgln("CursorTool::on_mousemove");
|
||||||
#endif
|
#endif
|
||||||
auto& form_widget = m_editor.form_widget();
|
auto& form_widget = m_editor.form_widget();
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ void CursorTool::on_mousemove(GUI::MouseEvent& event)
|
||||||
void CursorTool::on_keydown(GUI::KeyEvent& event)
|
void CursorTool::on_keydown(GUI::KeyEvent& event)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CURSOR_TOOL
|
#ifdef DEBUG_CURSOR_TOOL
|
||||||
dbg() << "CursorTool::on_keydown";
|
dbgln("CursorTool::on_keydown");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto move_selected_widgets_by = [this](int x, int y) {
|
auto move_selected_widgets_by = [this](int x, int y) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(const Debug::
|
||||||
do {
|
do {
|
||||||
String name = debug_session.debug_info().name_of_containing_function(current_instruction);
|
String name = debug_session.debug_info().name_of_containing_function(current_instruction);
|
||||||
if (name.is_null()) {
|
if (name.is_null()) {
|
||||||
dbg() << "BacktraceModel: couldn't find containing function for address: " << (void*)current_instruction;
|
dbgln("BacktraceModel: couldn't find containing function for address: {:p}", current_instruction);
|
||||||
name = "<missing>";
|
name = "<missing>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ void DebugInfoWidget::update_state(const Debug::DebugSession& debug_session, con
|
||||||
}
|
}
|
||||||
auto selected_index = m_backtrace_view->model()->index(0);
|
auto selected_index = m_backtrace_view->model()->index(0);
|
||||||
if (!selected_index.is_valid()) {
|
if (!selected_index.is_valid()) {
|
||||||
dbg() << "Warning: DebugInfoWidget: backtrace selected index is invalid";
|
dbgln("Warning: DebugInfoWidget: backtrace selected index is invalid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_backtrace_view->selection().set(selected_index);
|
m_backtrace_view->selection().set(selected_index);
|
||||||
|
|
|
@ -78,7 +78,7 @@ void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointC
|
||||||
|
|
||||||
auto address = session->debug_info().get_instruction_from_source(position.file_path, position.line_number);
|
auto address = session->debug_info().get_instruction_from_source(position.file_path, position.line_number);
|
||||||
if (!address.has_value()) {
|
if (!address.has_value()) {
|
||||||
dbg() << "Warning: couldn't get instruction address from source";
|
dbgln("Warning: couldn't get instruction address from source");
|
||||||
// TODO: Currently, the GUI will indicate that a breakpoint was inserted/removed at this line,
|
// TODO: Currently, the GUI will indicate that a breakpoint was inserted/removed at this line,
|
||||||
// regardless of whether we actually succeeded to insert it. (For example a breakpoint on a comment, or an include statement).
|
// regardless of whether we actually succeeded to insert it. (For example a breakpoint on a comment, or an include statement).
|
||||||
// We should indicate failure via a return value from this function, and not update the breakpoint GUI if we fail.
|
// We should indicate failure via a return value from this function, and not update the breakpoint GUI if we fail.
|
||||||
|
@ -97,7 +97,7 @@ void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointC
|
||||||
Debug::DebugInfo::SourcePosition Debugger::create_source_position(const String& file, size_t line)
|
Debug::DebugInfo::SourcePosition Debugger::create_source_position(const String& file, size_t line)
|
||||||
{
|
{
|
||||||
if (!file.starts_with('/') && !file.starts_with("./"))
|
if (!file.starts_with('/') && !file.starts_with("./"))
|
||||||
return { String::format("./%s", file.characters()), line + 1 };
|
return { String::formatted("./{}", file), line + 1 };
|
||||||
return { file, line + 1 };
|
return { file, line + 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,13 +113,13 @@ void Debugger::start()
|
||||||
ASSERT(!!m_debug_session);
|
ASSERT(!!m_debug_session);
|
||||||
|
|
||||||
for (const auto& breakpoint : m_breakpoints) {
|
for (const auto& breakpoint : m_breakpoints) {
|
||||||
dbg() << "insertig breakpoint at: " << breakpoint.file_path << ":" << breakpoint.line_number;
|
dbgln("insertig breakpoint at: {}:{}", breakpoint.file_path, breakpoint.line_number);
|
||||||
auto address = m_debug_session->debug_info().get_instruction_from_source(breakpoint.file_path, breakpoint.line_number);
|
auto address = m_debug_session->debug_info().get_instruction_from_source(breakpoint.file_path, breakpoint.line_number);
|
||||||
if (address.has_value()) {
|
if (address.has_value()) {
|
||||||
bool success = m_debug_session->insert_breakpoint(reinterpret_cast<void*>(address.value()));
|
bool success = m_debug_session->insert_breakpoint(reinterpret_cast<void*>(address.value()));
|
||||||
ASSERT(success);
|
ASSERT(success);
|
||||||
} else {
|
} else {
|
||||||
dbg() << "couldn't insert breakpoint";
|
dbgln("couldn't insert breakpoint");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ int Debugger::debugger_loop()
|
||||||
|
|
||||||
m_debug_session->run([this](Debug::DebugSession::DebugBreakReason reason, Optional<PtraceRegisters> optional_regs) {
|
m_debug_session->run([this](Debug::DebugSession::DebugBreakReason reason, Optional<PtraceRegisters> optional_regs) {
|
||||||
if (reason == Debug::DebugSession::DebugBreakReason::Exited) {
|
if (reason == Debug::DebugSession::DebugBreakReason::Exited) {
|
||||||
dbg() << "Program exited";
|
dbgln("Program exited");
|
||||||
m_on_exit_callback();
|
m_on_exit_callback();
|
||||||
return Debug::DebugSession::DebugDecision::Detach;
|
return Debug::DebugSession::DebugDecision::Detach;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ int Debugger::debugger_loop()
|
||||||
// NOTE: Is detaching from the debuggee the best thing to do here?
|
// NOTE: Is detaching from the debuggee the best thing to do here?
|
||||||
// We could display a dialog in the UI, remind the user that there is
|
// We could display a dialog in the UI, remind the user that there is
|
||||||
// a live debugged process, and ask whether they want to terminate/detach.
|
// a live debugged process, and ask whether they want to terminate/detach.
|
||||||
dbg() << "Debugger exiting";
|
dbgln("Debugger exiting");
|
||||||
return Debug::DebugSession::DebugDecision::Detach;
|
return Debug::DebugSession::DebugDecision::Detach;
|
||||||
}
|
}
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
|
|
@ -40,7 +40,7 @@ DisassemblyModel::DisassemblyModel(const Debug::DebugSession& debug_session, con
|
||||||
{
|
{
|
||||||
auto containing_function = debug_session.debug_info().get_containing_function(regs.eip);
|
auto containing_function = debug_session.debug_info().get_containing_function(regs.eip);
|
||||||
if (!containing_function.has_value()) {
|
if (!containing_function.has_value()) {
|
||||||
dbg() << "Cannot disassemble as the containing function was not found.";
|
dbgln("Cannot disassemble as the containing function was not found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,12 +110,11 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole
|
||||||
|
|
||||||
if (role == GUI::ModelRole::Display) {
|
if (role == GUI::ModelRole::Display) {
|
||||||
if (index.column() == Column::Address)
|
if (index.column() == Column::Address)
|
||||||
return String::format("%#08x", insn.address);
|
return String::formatted("{:p}", insn.address);
|
||||||
if (index.column() == Column::InstructionBytes) {
|
if (index.column() == Column::InstructionBytes) {
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
for (auto ch : insn.bytes) {
|
for (auto ch : insn.bytes)
|
||||||
builder.appendf("%02x ", (u8)ch);
|
builder.appendff("{:02x} ", static_cast<unsigned char>(ch));
|
||||||
}
|
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
if (index.column() == Column::Disassembly)
|
if (index.column() == Column::Disassembly)
|
||||||
|
|
|
@ -107,7 +107,7 @@ GUI::Variant RegistersModel::data(const GUI::ModelIndex& index, GUI::ModelRole r
|
||||||
if (index.column() == Column::Register)
|
if (index.column() == Column::Register)
|
||||||
return reg.name;
|
return reg.name;
|
||||||
if (index.column() == Column::Value)
|
if (index.column() == Column::Value)
|
||||||
return String::format("%#08x", reg.value);
|
return String::formatted("{:08x}", reg.value);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -84,19 +84,19 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var
|
||||||
return enumerator->constant_data.as_u32 == enumerator_value;
|
return enumerator->constant_data.as_u32 == enumerator_value;
|
||||||
});
|
});
|
||||||
ASSERT(!it.is_end());
|
ASSERT(!it.is_end());
|
||||||
return String::format("%s::%s", variable.type_name.characters(), (*it)->name.characters());
|
return String::formatted("{}::{}", variable.type_name, (*it)->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variable.type_name == "int") {
|
if (variable.type_name == "int") {
|
||||||
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
||||||
ASSERT(value.has_value());
|
ASSERT(value.has_value());
|
||||||
return String::format("%d", static_cast<int>(value.value()));
|
return String::formatted("{}", static_cast<int>(value.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variable.type_name == "char") {
|
if (variable.type_name == "char") {
|
||||||
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
||||||
ASSERT(value.has_value());
|
ASSERT(value.has_value());
|
||||||
return String::format("'%c' (%d)", static_cast<char>(value.value()), static_cast<char>(value.value()));
|
return String::formatted("'{0:c}' ({0:d})", value.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variable.type_name == "bool") {
|
if (variable.type_name == "bool") {
|
||||||
|
@ -105,13 +105,13 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var
|
||||||
return (value.value() & 1) ? "true" : "false";
|
return (value.value() & 1) ? "true" : "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
return String::format("type: %s @ %08x, ", variable.type_name.characters(), variable_address);
|
return String::formatted("type: {} @ {:p}, ", variable.type_name, variable_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Optional<u32> string_to_variable_value(const StringView& string_value, const Debug::DebugInfo::VariableInfo& variable)
|
static Optional<u32> string_to_variable_value(const StringView& string_value, const Debug::DebugInfo::VariableInfo& variable)
|
||||||
{
|
{
|
||||||
if (variable.is_enum_type()) {
|
if (variable.is_enum_type()) {
|
||||||
auto prefix_string = String::format("%s::", variable.type_name.characters());
|
auto prefix_string = String::formatted("{}::", variable.type_name);
|
||||||
auto string_to_use = string_value;
|
auto string_to_use = string_value;
|
||||||
if (string_value.starts_with(prefix_string))
|
if (string_value.starts_with(prefix_string))
|
||||||
string_to_use = string_value.substring_view(prefix_string.length(), string_value.length() - prefix_string.length());
|
string_to_use = string_value.substring_view(prefix_string.length(), string_value.length() - prefix_string.length());
|
||||||
|
@ -155,8 +155,9 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, const Stri
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::MessageBox::show(parent_window,
|
GUI::MessageBox::show(
|
||||||
String::format("String value \"%s\" could not be converted to a value of type %s.", string_value.to_string().characters(), variable->type_name.characters()),
|
parent_window,
|
||||||
|
String::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name),
|
||||||
"Set value failed",
|
"Set value failed",
|
||||||
GUI::MessageBox::Type::Error);
|
GUI::MessageBox::Type::Error);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +168,7 @@ GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, GUI::ModelRole r
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case GUI::ModelRole::Display: {
|
case GUI::ModelRole::Display: {
|
||||||
auto value_as_string = variable_value_as_string(*variable);
|
auto value_as_string = variable_value_as_string(*variable);
|
||||||
return String::format("%s: %s", variable->name.characters(), value_as_string.characters());
|
return String::formatted("{}: {}", variable->name, value_as_string);
|
||||||
}
|
}
|
||||||
case GUI::ModelRole::Icon:
|
case GUI::ModelRole::Icon:
|
||||||
return m_variable_icon;
|
return m_variable_icon;
|
||||||
|
|
|
@ -142,7 +142,7 @@ static HashMap<String, String>& man_paths()
|
||||||
// FIXME: This should also search man3, possibly other places..
|
// FIXME: This should also search man3, possibly other places..
|
||||||
Core::DirIterator it("/usr/share/man/man2", Core::DirIterator::Flags::SkipDots);
|
Core::DirIterator it("/usr/share/man/man2", Core::DirIterator::Flags::SkipDots);
|
||||||
while (it.has_next()) {
|
while (it.has_next()) {
|
||||||
auto path = String::format("/usr/share/man/man2/%s", it.next_path().characters());
|
auto path = String::formatted("/usr/share/man/man2/{}", it.next_path());
|
||||||
auto title = LexicalPath(path).title();
|
auto title = LexicalPath(path).title();
|
||||||
paths.set(title, path);
|
paths.set(title, path);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ void Editor::show_documentation_tooltip_if_available(const String& hovered_token
|
||||||
auto it = man_paths().find(hovered_token);
|
auto it = man_paths().find(hovered_token);
|
||||||
if (it == man_paths().end()) {
|
if (it == man_paths().end()) {
|
||||||
#ifdef EDITOR_DEBUG
|
#ifdef EDITOR_DEBUG
|
||||||
dbg() << "no man path for " << hovered_token;
|
dbgln("no man path for {}", hovered_token);
|
||||||
#endif
|
#endif
|
||||||
m_documentation_tooltip_window->hide();
|
m_documentation_tooltip_window->hide();
|
||||||
return;
|
return;
|
||||||
|
@ -167,18 +167,18 @@ void Editor::show_documentation_tooltip_if_available(const String& hovered_token
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EDITOR_DEBUG
|
#ifdef EDITOR_DEBUG
|
||||||
dbg() << "opening " << it->value;
|
dbgln("opening {}", it->value);
|
||||||
#endif
|
#endif
|
||||||
auto file = Core::File::construct(it->value);
|
auto file = Core::File::construct(it->value);
|
||||||
if (!file->open(Core::File::ReadOnly)) {
|
if (!file->open(Core::File::ReadOnly)) {
|
||||||
dbg() << "failed to open " << it->value << " " << file->error_string();
|
dbgln("failed to open {}, {}", it->value, file->error_string());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto man_document = Markdown::Document::parse(file->read_all());
|
auto man_document = Markdown::Document::parse(file->read_all());
|
||||||
|
|
||||||
if (!man_document) {
|
if (!man_document) {
|
||||||
dbg() << "failed to parse markdown";
|
dbgln("failed to parse markdown");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ void Editor::mousemove_event(GUI::MouseEvent& event)
|
||||||
adjusted_range.end().set_column(min(end_line_length, adjusted_range.end().column() + 1));
|
adjusted_range.end().set_column(min(end_line_length, adjusted_range.end().column() + 1));
|
||||||
auto hovered_span_text = document().text_in_range(adjusted_range);
|
auto hovered_span_text = document().text_in_range(adjusted_range);
|
||||||
#ifdef EDITOR_DEBUG
|
#ifdef EDITOR_DEBUG
|
||||||
dbg() << "Hovering: " << adjusted_range << " \"" << hovered_span_text << "\"";
|
dbgln("Hovering: {} \"{}\"", adjusted_range, hovered_span_text);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (highlighter->is_navigatable(span.data)) {
|
if (highlighter->is_navigatable(span.data)) {
|
||||||
|
@ -305,7 +305,7 @@ void Editor::mousedown_event(GUI::MouseEvent& event)
|
||||||
auto span_text = document().text_in_range(adjusted_range);
|
auto span_text = document().text_in_range(adjusted_range);
|
||||||
auto header_path = span_text.substring(1, span_text.length() - 2);
|
auto header_path = span_text.substring(1, span_text.length() - 2);
|
||||||
#ifdef EDITOR_DEBUG
|
#ifdef EDITOR_DEBUG
|
||||||
dbg() << "Ctrl+click: " << adjusted_range << " \"" << header_path << "\"";
|
dbgln("Ctrl+click: {} \"{}\"", adjusted_range, header_path);
|
||||||
#endif
|
#endif
|
||||||
navigate_to_include_if_available(header_path);
|
navigate_to_include_if_available(header_path);
|
||||||
return;
|
return;
|
||||||
|
@ -392,7 +392,7 @@ static HashMap<String, String>& include_paths()
|
||||||
if (!Core::File::is_directory(path)) {
|
if (!Core::File::is_directory(path)) {
|
||||||
auto key = path.substring(base.length() + 1, path.length() - base.length() - 1);
|
auto key = path.substring(base.length() + 1, path.length() - base.length() - 1);
|
||||||
#ifdef EDITOR_DEBUG
|
#ifdef EDITOR_DEBUG
|
||||||
dbg() << "Adding header \"" << key << "\" in path \"" << path << "\"";
|
dbgln("Adding header \"{}\" in path \"{}\"", key, path);
|
||||||
#endif
|
#endif
|
||||||
paths.set(key, path);
|
paths.set(key, path);
|
||||||
} else {
|
} else {
|
||||||
|
@ -416,7 +416,7 @@ void Editor::navigate_to_include_if_available(String path)
|
||||||
auto it = include_paths().find(path);
|
auto it = include_paths().find(path);
|
||||||
if (it == include_paths().end()) {
|
if (it == include_paths().end()) {
|
||||||
#ifdef EDITOR_DEBUG
|
#ifdef EDITOR_DEBUG
|
||||||
dbg() << "no header " << path << " found.";
|
dbgln("no header {} found.", path);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ EditorWrapper::EditorWrapper()
|
||||||
m_editor->set_automatic_indentation_enabled(true);
|
m_editor->set_automatic_indentation_enabled(true);
|
||||||
|
|
||||||
m_editor->on_cursor_change = [this] {
|
m_editor->on_cursor_change = [this] {
|
||||||
m_cursor_label->set_text(String::format("Line: %d, Column: %d", m_editor->cursor().line() + 1, m_editor->cursor().column()));
|
m_cursor_label->set_text(String::formatted("Line: {}, Column: {}", m_editor->cursor().line() + 1, m_editor->cursor().column()));
|
||||||
};
|
};
|
||||||
|
|
||||||
m_editor->on_focus = [this] {
|
m_editor->on_focus = [this] {
|
||||||
|
|
|
@ -161,9 +161,8 @@ void DiffViewer::set_content(const String& original, const String& diff)
|
||||||
m_hunks = Diff::parse_hunks(diff);
|
m_hunks = Diff::parse_hunks(diff);
|
||||||
|
|
||||||
#ifdef DEBUG_DIFF
|
#ifdef DEBUG_DIFF
|
||||||
for (size_t i = 0; i < m_original_lines.size(); ++i) {
|
for (size_t i = 0; i < m_original_lines.size(); ++i)
|
||||||
dbg() << i << ":" << m_original_lines[i];
|
dbgln("{}:{}", i, m_original_lines[i]);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ bool GitRepo::commit(const String& message)
|
||||||
|
|
||||||
Optional<String> GitRepo::original_file_content(const LexicalPath& file) const
|
Optional<String> GitRepo::original_file_content(const LexicalPath& file) const
|
||||||
{
|
{
|
||||||
return command({ "show", String::format("HEAD:%s", file.string().characters()) });
|
return command({ "show", String::formatted("HEAD:{}", file) });
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<String> GitRepo::unstaged_diff(const LexicalPath& file) const
|
Optional<String> GitRepo::unstaged_diff(const LexicalPath& file) const
|
||||||
|
|
|
@ -128,7 +128,7 @@ bool GitWidget::initialize_if_needed()
|
||||||
void GitWidget::refresh()
|
void GitWidget::refresh()
|
||||||
{
|
{
|
||||||
if (!initialize_if_needed()) {
|
if (!initialize_if_needed()) {
|
||||||
dbg() << "GitWidget initialization failed";
|
dbgln("GitWidget initialization failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ void GitWidget::refresh()
|
||||||
|
|
||||||
void GitWidget::stage_file(const LexicalPath& file)
|
void GitWidget::stage_file(const LexicalPath& file)
|
||||||
{
|
{
|
||||||
dbg() << "staging: " << file.string();
|
dbgln("staging: {}", file);
|
||||||
bool rc = m_git_repo->stage(file);
|
bool rc = m_git_repo->stage(file);
|
||||||
ASSERT(rc);
|
ASSERT(rc);
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -148,7 +148,7 @@ void GitWidget::stage_file(const LexicalPath& file)
|
||||||
|
|
||||||
void GitWidget::unstage_file(const LexicalPath& file)
|
void GitWidget::unstage_file(const LexicalPath& file)
|
||||||
{
|
{
|
||||||
dbg() << "unstaging: " << file.string();
|
dbgln("unstaging: {}", file);
|
||||||
bool rc = m_git_repo->unstage(file);
|
bool rc = m_git_repo->unstage(file);
|
||||||
ASSERT(rc);
|
ASSERT(rc);
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -160,7 +160,7 @@ void GitWidget::commit()
|
||||||
auto res = GUI::InputBox::show(message, window(), "Commit message:", "Commit");
|
auto res = GUI::InputBox::show(message, window(), "Commit message:", "Commit");
|
||||||
if (res != GUI::InputBox::ExecOK || message.is_empty())
|
if (res != GUI::InputBox::ExecOK || message.is_empty())
|
||||||
return;
|
return;
|
||||||
dbg() << "commit message: " << message;
|
dbgln("commit message: {}", message);
|
||||||
m_git_repo->commit(message);
|
m_git_repo->commit(message);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ void HackStudioWidget::open_file(const String& filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currently_open_file = filename;
|
m_currently_open_file = filename;
|
||||||
window()->set_title(String::format("%s - HackStudio", m_currently_open_file.characters()));
|
window()->set_title(String::formatted("{} - HackStudio", m_currently_open_file));
|
||||||
m_project_tree_view->update();
|
m_project_tree_view->update();
|
||||||
|
|
||||||
current_editor_wrapper().filename_label().set_text(filename);
|
current_editor_wrapper().filename_label().set_text(filename);
|
||||||
|
@ -271,11 +271,11 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_action()
|
||||||
return;
|
return;
|
||||||
auto file = Core::File::construct(filename);
|
auto file = Core::File::construct(filename);
|
||||||
if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
|
if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
|
||||||
GUI::MessageBox::show(window(), String::format("Failed to create '%s'", filename.characters()), "Error", GUI::MessageBox::Type::Error);
|
GUI::MessageBox::show(window(), String::formatted("Failed to create '{}'", filename), "Error", GUI::MessageBox::Type::Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_project->add_file(filename)) {
|
if (!m_project->add_file(filename)) {
|
||||||
GUI::MessageBox::show(window(), String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error);
|
GUI::MessageBox::show(window(), String::formatted("Failed to add '{}' to project", filename), "Error", GUI::MessageBox::Type::Error);
|
||||||
// FIXME: Should we unlink the file here maybe?
|
// FIXME: Should we unlink the file here maybe?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_existing_file_action()
|
||||||
return;
|
return;
|
||||||
auto& filename = result.value();
|
auto& filename = result.value();
|
||||||
if (!m_project->add_file(filename)) {
|
if (!m_project->add_file(filename)) {
|
||||||
GUI::MessageBox::show(window(), String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error);
|
GUI::MessageBox::show(window(), String::formatted("Failed to add '{}' to project", filename), "Error", GUI::MessageBox::Type::Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_project_tree_view->toggle_index(m_project_tree_view->model()->index(0, 0));
|
m_project_tree_view->toggle_index(m_project_tree_view->model()->index(0, 0));
|
||||||
|
@ -322,9 +322,9 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
if (files.size() == 1) {
|
if (files.size() == 1) {
|
||||||
message = String::format("Really remove %s from the project?", LexicalPath(files[0]).basename().characters());
|
message = String::formatted("Really remove {} from the project?", LexicalPath(files[0]).basename());
|
||||||
} else {
|
} else {
|
||||||
message = String::format("Really remove %d files from the project?", files.size());
|
message = String::formatted("Really remove {} files from the project?", files.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = GUI::MessageBox::show(window(),
|
auto result = GUI::MessageBox::show(window(),
|
||||||
|
@ -338,7 +338,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
|
||||||
for (auto& file : files) {
|
for (auto& file : files) {
|
||||||
if (!m_project->remove_file(file)) {
|
if (!m_project->remove_file(file)) {
|
||||||
GUI::MessageBox::show(window(),
|
GUI::MessageBox::show(window(),
|
||||||
String::format("Removing file %s from the project failed.", file.characters()),
|
String::formatted("Removing file {} from the project failed.", file),
|
||||||
"Removal failed",
|
"Removal failed",
|
||||||
GUI::MessageBox::Type::Error);
|
GUI::MessageBox::Type::Error);
|
||||||
break;
|
break;
|
||||||
|
@ -492,11 +492,11 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action()
|
||||||
{
|
{
|
||||||
return GUI::Action::create("Debug", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"), [this](auto&) {
|
return GUI::Action::create("Debug", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"), [this](auto&) {
|
||||||
if (m_project->type() != ProjectType::Cpp) {
|
if (m_project->type() != ProjectType::Cpp) {
|
||||||
GUI::MessageBox::show(window(), String::format("Cannot debug current project type", get_project_executable_path().characters()), "Error", GUI::MessageBox::Type::Error);
|
GUI::MessageBox::show(window(), "Cannot debug current project type", "Error", GUI::MessageBox::Type::Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!GUI::FilePicker::file_exists(get_project_executable_path())) {
|
if (!GUI::FilePicker::file_exists(get_project_executable_path())) {
|
||||||
GUI::MessageBox::show(window(), String::format("Could not find file: %s. (did you build the project?)", get_project_executable_path().characters()), "Error", GUI::MessageBox::Type::Error);
|
GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error", GUI::MessageBox::Type::Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Debugger::the().session()) {
|
if (Debugger::the().session()) {
|
||||||
|
@ -517,7 +517,7 @@ void HackStudioWidget::initialize_debugger()
|
||||||
const auto& debug_session = *Debugger::the().session();
|
const auto& debug_session = *Debugger::the().session();
|
||||||
auto source_position = debug_session.debug_info().get_source_position(regs.eip);
|
auto source_position = debug_session.debug_info().get_source_position(regs.eip);
|
||||||
if (!source_position.has_value()) {
|
if (!source_position.has_value()) {
|
||||||
dbg() << "Could not find source position for address: " << (void*)regs.eip;
|
dbgln("Could not find source position for address: {:p}", regs.eip);
|
||||||
return Debugger::HasControlPassedToUser::No;
|
return Debugger::HasControlPassedToUser::No;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ String HackStudioWidget::get_full_path_of_serenity_source(const String& file)
|
||||||
relative_path_builder.join("/", path_parts);
|
relative_path_builder.join("/", path_parts);
|
||||||
constexpr char SERENITY_LIBS_PREFIX[] = "/usr/src/serenity";
|
constexpr char SERENITY_LIBS_PREFIX[] = "/usr/src/serenity";
|
||||||
LexicalPath serenity_sources_base(SERENITY_LIBS_PREFIX);
|
LexicalPath serenity_sources_base(SERENITY_LIBS_PREFIX);
|
||||||
return String::format("%s/%s", serenity_sources_base.string().characters(), relative_path_builder.to_string().characters());
|
return String::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(const String& file_name)
|
NonnullRefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(const String& file_name)
|
||||||
|
@ -593,7 +593,7 @@ String HackStudioWidget::get_project_executable_path() const
|
||||||
void HackStudioWidget::build(TerminalWrapper& wrapper)
|
void HackStudioWidget::build(TerminalWrapper& wrapper)
|
||||||
{
|
{
|
||||||
if (m_project->type() == ProjectType::JavaScript && m_currently_open_file.ends_with(".js"))
|
if (m_project->type() == ProjectType::JavaScript && m_currently_open_file.ends_with(".js"))
|
||||||
wrapper.run_command(String::format("js -A %s", m_currently_open_file.characters()));
|
wrapper.run_command(String::formatted("js -A {}", m_currently_open_file));
|
||||||
else
|
else
|
||||||
wrapper.run_command("make");
|
wrapper.run_command("make");
|
||||||
}
|
}
|
||||||
|
@ -601,7 +601,7 @@ void HackStudioWidget::build(TerminalWrapper& wrapper)
|
||||||
void HackStudioWidget::run(TerminalWrapper& wrapper)
|
void HackStudioWidget::run(TerminalWrapper& wrapper)
|
||||||
{
|
{
|
||||||
if (m_project->type() == ProjectType::JavaScript && m_currently_open_file.ends_with(".js"))
|
if (m_project->type() == ProjectType::JavaScript && m_currently_open_file.ends_with(".js"))
|
||||||
wrapper.run_command(String::format("js %s", m_currently_open_file.characters()));
|
wrapper.run_command(String::format("js {}", m_currently_open_file));
|
||||||
else
|
else
|
||||||
wrapper.run_command("make run");
|
wrapper.run_command("make run");
|
||||||
}
|
}
|
||||||
|
@ -666,12 +666,8 @@ void HackStudioWidget::create_form_editor(GUI::Widget& parent)
|
||||||
|
|
||||||
GUI::WidgetClassRegistration::for_each([&, this](const GUI::WidgetClassRegistration& reg) {
|
GUI::WidgetClassRegistration::for_each([&, this](const GUI::WidgetClassRegistration& reg) {
|
||||||
constexpr size_t gui_namespace_prefix_length = sizeof("GUI::") - 1;
|
constexpr size_t gui_namespace_prefix_length = sizeof("GUI::") - 1;
|
||||||
auto icon_path = String::format(
|
auto icon_path = String::formatted("/res/icons/hackstudio/G{}.png",
|
||||||
"/res/icons/hackstudio/G%s.png",
|
reg.class_name().substring(gui_namespace_prefix_length, reg.class_name().length() - gui_namespace_prefix_length));
|
||||||
reg.class_name().substring(
|
|
||||||
gui_namespace_prefix_length,
|
|
||||||
reg.class_name().length() - gui_namespace_prefix_length)
|
|
||||||
.characters());
|
|
||||||
if (!Core::File::exists(icon_path))
|
if (!Core::File::exists(icon_path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -898,11 +894,11 @@ HackStudioWidget::~HackStudioWidget()
|
||||||
if (!m_debugger_thread.is_null()) {
|
if (!m_debugger_thread.is_null()) {
|
||||||
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Exit);
|
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Exit);
|
||||||
void* retval;
|
void* retval;
|
||||||
dbg() << "Waiting for debugger thread to terminate";
|
dbgln("Waiting for debugger thread to terminate");
|
||||||
int rc = pthread_join(m_debugger_thread->tid(), &retval);
|
int rc = pthread_join(m_debugger_thread->tid(), &retval);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
perror("pthread_join");
|
perror("pthread_join");
|
||||||
dbg() << "error joining debugger thread";
|
dbgln("error joining debugger thread");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ Vector<AutoCompleteResponse> AutoComplete::get_suggestions(const String& code, G
|
||||||
|
|
||||||
#ifdef DEBUG_AUTOCOMPLETE
|
#ifdef DEBUG_AUTOCOMPLETE
|
||||||
for (auto& suggestion : suggestions) {
|
for (auto& suggestion : suggestions) {
|
||||||
dbg() << "suggestion: " << suggestion.completion;
|
dbgln("suggestion: {}", suggestion.completion);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ OwnPtr<Messages::LanguageServer::GreetResponse> ClientConnection::handle(const M
|
||||||
{
|
{
|
||||||
m_project_root = LexicalPath(message.project_root());
|
m_project_root = LexicalPath(message.project_root());
|
||||||
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
||||||
dbg() << "project_root: " << m_project_root.string();
|
dbgln("project_root: {}", m_project_root);
|
||||||
#endif
|
#endif
|
||||||
return make<Messages::LanguageServer::GreetResponse>(client_id());
|
return make<Messages::LanguageServer::GreetResponse>(client_id());
|
||||||
}
|
}
|
||||||
|
@ -81,16 +81,16 @@ static DefaultDocumentClient s_default_document_client;
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FileOpened& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FileOpened& message)
|
||||||
{
|
{
|
||||||
LexicalPath file_path(String::format("%s/%s", m_project_root.string().characters(), message.file_name().characters()));
|
LexicalPath file_path(String::formatted("{}/{}", m_project_root, message.file_name()));
|
||||||
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
||||||
dbg() << "FileOpened: " << file_path.string();
|
dbgln("FileOpened: {}", file_path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto file = Core::File::construct(file_path.string());
|
auto file = Core::File::construct(file_path.string());
|
||||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||||
errno = file->error();
|
errno = file->error();
|
||||||
perror("open");
|
perror("open");
|
||||||
dbg() << "Failed to open project file: " << file_path.string();
|
dbgln("Failed to open project file: {}", file_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto content = file->read_all();
|
auto content = file->read_all();
|
||||||
|
@ -106,31 +106,31 @@ void ClientConnection::handle(const Messages::LanguageServer::FileOpened& messag
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
||||||
dbg() << "InsertText for file: " << message.file_name();
|
dbgln("InsertText for file: {}", message.file_name());
|
||||||
dbg() << "Text: " << message.text();
|
dbgln("Text: {}", message.text());
|
||||||
dbg() << "[" << message.start_line() << ":" << message.start_column() << "]";
|
dbgln("[{}:{}]", message.start_line(), message.start_column());
|
||||||
#endif
|
#endif
|
||||||
auto document = document_for(message.file_name());
|
auto document = document_for(message.file_name());
|
||||||
if (!document) {
|
if (!document) {
|
||||||
dbg() << "file " << message.file_name() << " has not been opened";
|
dbgln("file {} has not been opened", message.file_name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() };
|
GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() };
|
||||||
document->insert_at(start_position, message.text(), &s_default_document_client);
|
document->insert_at(start_position, message.text(), &s_default_document_client);
|
||||||
#ifdef DEBUG_FILE_CONTENT
|
#ifdef DEBUG_FILE_CONTENT
|
||||||
dbg() << document->text();
|
dbgln("{}", document->text());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText& message)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
||||||
dbg() << "RemoveText for file: " << message.file_name();
|
dbgln("RemoveText for file: {}", message.file_name());
|
||||||
dbg() << "[" << message.start_line() << ":" << message.start_column() << " - " << message.end_line() << ":" << message.end_column() << "]";
|
dbgln("[{}:{} - {}:{}]", message.start_line(), message.start_column(), message.end_line(), message.end_column());
|
||||||
#endif
|
#endif
|
||||||
auto document = document_for(message.file_name());
|
auto document = document_for(message.file_name());
|
||||||
if (!document) {
|
if (!document) {
|
||||||
dbg() << "file " << message.file_name() << " has not been opened";
|
dbgln("file {} has not been opened", message.file_name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() };
|
GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() };
|
||||||
|
@ -143,19 +143,19 @@ void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText
|
||||||
|
|
||||||
document->remove(range);
|
document->remove(range);
|
||||||
#ifdef DEBUG_FILE_CONTENT
|
#ifdef DEBUG_FILE_CONTENT
|
||||||
dbg() << document->text();
|
dbgln("{}", document->text());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message)
|
void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
#ifdef DEBUG_CPP_LANGUAGE_SERVER
|
||||||
dbg() << "AutoCompleteSuggestions for: " << message.file_name() << " " << message.cursor_line() << ":" << message.cursor_column();
|
dbgln("AutoCompleteSuggestions for: {} {}:{}", message.file_name(), message.cursor_line(), message.cursor_column());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto document = document_for(message.file_name());
|
auto document = document_for(message.file_name());
|
||||||
if (!document) {
|
if (!document) {
|
||||||
dbg() << "file " << message.file_name() << " has not been opened";
|
dbgln("file {} has not been opened", message.file_name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ void ClientConnection::handle(const Messages::LanguageServer::SetFileContent& me
|
||||||
{
|
{
|
||||||
auto document = document_for(message.file_name());
|
auto document = document_for(message.file_name());
|
||||||
if (!document) {
|
if (!document) {
|
||||||
dbg() << "file " << message.file_name() << " has not been opened";
|
dbgln("file {} has not been opened", message.file_name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto content = message.content();
|
auto content = message.content();
|
||||||
|
|
|
@ -43,16 +43,16 @@ Vector<AutoCompleteResponse> AutoComplete::get_suggestions(const String& code, s
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
#ifdef DEBUG_AUTOCOMPLETE
|
#ifdef DEBUG_AUTOCOMPLETE
|
||||||
dbg() << "Complete '" << code << "': ";
|
dbgln("Complete '{}'", code);
|
||||||
ast->dump(1);
|
ast->dump(1);
|
||||||
dbg() << "At offset " << offset;
|
dbgln("At offset {}", offset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto result = ast->complete_for_editor(m_shell, offset);
|
auto result = ast->complete_for_editor(m_shell, offset);
|
||||||
Vector<AutoCompleteResponse> completions;
|
Vector<AutoCompleteResponse> completions;
|
||||||
for (auto& entry : result) {
|
for (auto& entry : result) {
|
||||||
#ifdef DEBUG_AUTOCOMPLETE
|
#ifdef DEBUG_AUTOCOMPLETE
|
||||||
dbg() << "Suggestion: '" << entry.text_string << "' starting at " << entry.input_offset;
|
dbgln("Suggestion: '{}' starting at {}", entry.text_string, entry.input_offset);
|
||||||
#endif
|
#endif
|
||||||
completions.append({ entry.text_string, entry.input_offset });
|
completions.append({ entry.text_string, entry.input_offset });
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ OwnPtr<Messages::LanguageServer::GreetResponse> ClientConnection::handle(const M
|
||||||
{
|
{
|
||||||
m_project_root = LexicalPath(message.project_root());
|
m_project_root = LexicalPath(message.project_root());
|
||||||
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
||||||
dbg() << "project_root: " << m_project_root.string();
|
dbgln("project_root: {}", m_project_root);
|
||||||
#endif
|
#endif
|
||||||
return make<Messages::LanguageServer::GreetResponse>(client_id());
|
return make<Messages::LanguageServer::GreetResponse>(client_id());
|
||||||
}
|
}
|
||||||
|
@ -81,16 +81,16 @@ static DefaultDocumentClient s_default_document_client;
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FileOpened& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FileOpened& message)
|
||||||
{
|
{
|
||||||
LexicalPath file_path(String::format("%s/%s", m_project_root.string().characters(), message.file_name().characters()));
|
LexicalPath file_path(String::formatted("{}/{}", m_project_root, message.file_name()));
|
||||||
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
||||||
dbg() << "FileOpened: " << file_path.string();
|
dbgln("FileOpened: {}", file_path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto file = Core::File::construct(file_path.string());
|
auto file = Core::File::construct(file_path.string());
|
||||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||||
errno = file->error();
|
errno = file->error();
|
||||||
perror("open");
|
perror("open");
|
||||||
dbg() << "Failed to open project file: " << file_path.string();
|
dbgln("Failed to open project file: {}", file_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto content = file->read_all();
|
auto content = file->read_all();
|
||||||
|
@ -106,31 +106,31 @@ void ClientConnection::handle(const Messages::LanguageServer::FileOpened& messag
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
||||||
dbg() << "InsertText for file: " << message.file_name();
|
dbgln("InsertText for file: {}", message.file_name());
|
||||||
dbg() << "Text: " << message.text();
|
dbgln("Text: {}", message.text());
|
||||||
dbg() << "[" << message.start_line() << ":" << message.start_column() << "]";
|
dbgln("[{}:{}]", message.start_line(), message.start_column());
|
||||||
#endif
|
#endif
|
||||||
auto document = document_for(message.file_name());
|
auto document = document_for(message.file_name());
|
||||||
if (!document) {
|
if (!document) {
|
||||||
dbg() << "file " << message.file_name() << " has not been opened";
|
dbgln("file {} has not been opened", message.file_name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() };
|
GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() };
|
||||||
document->insert_at(start_position, message.text(), &s_default_document_client);
|
document->insert_at(start_position, message.text(), &s_default_document_client);
|
||||||
#ifdef DEBUG_FILE_CONTENT
|
#ifdef DEBUG_FILE_CONTENT
|
||||||
dbg() << document->text();
|
dbgln("{}", document->text());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText& message)
|
void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText& message)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
||||||
dbg() << "RemoveText for file: " << message.file_name();
|
dbgln("RemoveText for file: {}", message.file_name());
|
||||||
dbg() << "[" << message.start_line() << ":" << message.start_column() << " - " << message.end_line() << ":" << message.end_column() << "]";
|
dbgln("[{}:{} - {}:{}]", message.start_line(), message.start_column(), message.end_line(), message.end_column());
|
||||||
#endif
|
#endif
|
||||||
auto document = document_for(message.file_name());
|
auto document = document_for(message.file_name());
|
||||||
if (!document) {
|
if (!document) {
|
||||||
dbg() << "file " << message.file_name() << " has not been opened";
|
dbgln("file {} has not been opened", message.file_name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() };
|
GUI::TextPosition start_position { (size_t)message.start_line(), (size_t)message.start_column() };
|
||||||
|
@ -150,12 +150,12 @@ void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText
|
||||||
void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message)
|
void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
#ifdef DEBUG_SH_LANGUAGE_SERVER
|
||||||
dbg() << "AutoCompleteSuggestions for: " << message.file_name() << " " << message.cursor_line() << ":" << message.cursor_column();
|
dbgln("AutoCompleteSuggestions for: {} {}:{}", message.file_name(), message.cursor_line(), message.cursor_column());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto document = document_for(message.file_name());
|
auto document = document_for(message.file_name());
|
||||||
if (!document) {
|
if (!document) {
|
||||||
dbg() << "file " << message.file_name() << " has not been opened";
|
dbgln("file {} has not been opened", message.file_name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ void ClientConnection::handle(const Messages::LanguageServer::SetFileContent& me
|
||||||
{
|
{
|
||||||
auto document = document_for(message.file_name());
|
auto document = document_for(message.file_name());
|
||||||
if (!document) {
|
if (!document) {
|
||||||
dbg() << "file " << message.file_name() << " has not been opened";
|
dbgln("file {} has not been opened", message.file_name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto content = message.content();
|
auto content = message.content();
|
||||||
|
|
|
@ -179,9 +179,9 @@ void Locator::update_suggestions()
|
||||||
if (file.name().contains(typed_text))
|
if (file.name().contains(typed_text))
|
||||||
suggestions.append(file.name());
|
suggestions.append(file.name());
|
||||||
});
|
});
|
||||||
dbg() << "I have " << suggestions.size() << " suggestion(s):";
|
dbgln("I have {} suggestion(s):", suggestions.size());
|
||||||
for (auto& s : suggestions) {
|
for (auto& s : suggestions) {
|
||||||
dbg() << " " << s;
|
dbgln(" {}", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_suggestions = !suggestions.is_empty();
|
bool has_suggestions = !suggestions.is_empty();
|
||||||
|
@ -194,7 +194,7 @@ void Locator::update_suggestions()
|
||||||
m_suggestion_view->selection().set(m_suggestion_view->model()->index(0));
|
m_suggestion_view->selection().set(m_suggestion_view->model()->index(0));
|
||||||
|
|
||||||
m_popup_window->move_to(screen_relative_rect().top_left().translated(0, -m_popup_window->height()));
|
m_popup_window->move_to(screen_relative_rect().top_left().translated(0, -m_popup_window->height()));
|
||||||
dbg() << "Popup rect: " << m_popup_window->rect();
|
dbgln("Popup rect: {}", m_popup_window->rect());
|
||||||
m_popup_window->show();
|
m_popup_window->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,10 +82,10 @@ void ProcessStateWidget::refresh()
|
||||||
|
|
||||||
auto& data = active_process_data.value();
|
auto& data = active_process_data.value();
|
||||||
|
|
||||||
m_pid_label->set_text(String::format("%s(%d)", data.name.characters(), pid));
|
m_pid_label->set_text(String::formatted("{}({})", data.name, pid));
|
||||||
m_state_label->set_text(data.threads.first().state);
|
m_state_label->set_text(data.threads.first().state);
|
||||||
m_cpu_label->set_text(String::format("%d", data.threads.first().times_scheduled));
|
m_cpu_label->set_text(String::formatted("{}", data.threads.first().times_scheduled));
|
||||||
m_memory_label->set_text(String::format("%d", data.amount_resident));
|
m_memory_label->set_text(String::formatted("{}", data.amount_resident));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessStateWidget::set_tty_fd(int tty_fd)
|
void ProcessStateWidget::set_tty_fd(int tty_fd)
|
||||||
|
|
|
@ -353,11 +353,11 @@ void Project::rebuild_tree()
|
||||||
#if 0
|
#if 0
|
||||||
Function<void(ProjectTreeNode&, int indent)> dump_tree = [&](ProjectTreeNode& node, int indent) {
|
Function<void(ProjectTreeNode&, int indent)> dump_tree = [&](ProjectTreeNode& node, int indent) {
|
||||||
for (int i = 0; i < indent; ++i)
|
for (int i = 0; i < indent; ++i)
|
||||||
printf(" ");
|
new_out(" ");
|
||||||
if (node.name.is_null())
|
if (node.name.is_null())
|
||||||
printf("(null)\n");
|
outln("(null)");
|
||||||
else
|
else
|
||||||
printf("%s\n", node.name.characters());
|
outln("{}", node.name);
|
||||||
for (auto& child : node.children) {
|
for (auto& child : node.children) {
|
||||||
dump_tree(*child, indent + 2);
|
dump_tree(*child, indent + 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,11 +76,11 @@ void TerminalWrapper::run_command(const String& command)
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
if (WIFEXITED(wstatus)) {
|
if (WIFEXITED(wstatus)) {
|
||||||
m_terminal_widget->inject_string(String::format("\033[%d;1m(Command exited with code %d)\033[0m\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus)));
|
m_terminal_widget->inject_string(String::formatted("\033[{};1m(Command exited with code {})\033[0m\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus)));
|
||||||
} else if (WIFSTOPPED(wstatus)) {
|
} else if (WIFSTOPPED(wstatus)) {
|
||||||
m_terminal_widget->inject_string(String::format("\033[34;1m(Command stopped!)\033[0m\n"));
|
m_terminal_widget->inject_string("\033[34;1m(Command stopped!)\033[0m\n");
|
||||||
} else if (WIFSIGNALED(wstatus)) {
|
} else if (WIFSIGNALED(wstatus)) {
|
||||||
m_terminal_widget->inject_string(String::format("\033[34;1m(Command signaled with %s!)\033[0m\n", strsignal(WTERMSIG(wstatus))));
|
m_terminal_widget->inject_string(String::formatted("\033[34;1m(Command signaled with {}!)\033[0m\n", strsignal(WTERMSIG(wstatus))));
|
||||||
}
|
}
|
||||||
m_process_state_widget->set_tty_fd(-1);
|
m_process_state_widget->set_tty_fd(-1);
|
||||||
m_pid = -1;
|
m_pid = -1;
|
||||||
|
|
|
@ -32,25 +32,25 @@ namespace HackStudio {
|
||||||
void WidgetTool::on_mousedown(GUI::MouseEvent& event)
|
void WidgetTool::on_mousedown(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
(void)event;
|
(void)event;
|
||||||
dbg() << "WidgetTool::on_mousedown";
|
dbgln("WidgetTool::on_mousedown");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetTool::on_mouseup(GUI::MouseEvent& event)
|
void WidgetTool::on_mouseup(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
(void)event;
|
(void)event;
|
||||||
dbg() << "WidgetTool::on_mouseup";
|
dbgln("WidgetTool::on_mouseup");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetTool::on_mousemove(GUI::MouseEvent& event)
|
void WidgetTool::on_mousemove(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
(void)event;
|
(void)event;
|
||||||
dbg() << "WidgetTool::on_mousemove";
|
dbgln("WidgetTool::on_mousemove");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetTool::on_keydown(GUI::KeyEvent& event)
|
void WidgetTool::on_keydown(GUI::KeyEvent& event)
|
||||||
{
|
{
|
||||||
(void)event;
|
(void)event;
|
||||||
dbg() << "WidgetTool::on_keydown";
|
dbgln("WidgetTool::on_keydown");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ GUI::Variant WidgetTreeModel::data(const GUI::ModelIndex& index, GUI::ModelRole
|
||||||
return m_widget_icon;
|
return m_widget_icon;
|
||||||
}
|
}
|
||||||
if (role == GUI::ModelRole::Display) {
|
if (role == GUI::ModelRole::Display) {
|
||||||
return String::format("%s (%s)", widget->class_name(), widget->relative_rect().to_string().characters());
|
return String::formatted("{} ({})", widget->class_name(), widget->relative_rect());
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue