mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
HackStudio: Add C++ Language Server
The language server keeps track of the content of currently edited files by receiving updates about edit actions. Also, C++ autocompletion is no longer tied to HackStudio itself and moved to be part of the language server.
This commit is contained in:
parent
bf53d7ff64
commit
863f14788f
18 changed files with 451 additions and 21 deletions
|
@ -39,6 +39,9 @@ public:
|
|||
|
||||
String action_text() const { return m_action_text; }
|
||||
|
||||
virtual bool is_insert_text() const { return false; }
|
||||
virtual bool is_remove_text() const { return false; }
|
||||
|
||||
protected:
|
||||
Command() { }
|
||||
void set_action_text(const String& text) { m_action_text = text; }
|
||||
|
|
|
@ -282,6 +282,18 @@ void TextDocument::set_all_cursors(const TextPosition& position)
|
|||
}
|
||||
}
|
||||
|
||||
String TextDocument::text() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < line_count(); ++i) {
|
||||
auto& line = this->line(i);
|
||||
builder.append(line.view());
|
||||
if (i != line_count() - 1)
|
||||
builder.append('\n');
|
||||
}
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
String TextDocument::text_in_range(const TextRange& a_range) const
|
||||
{
|
||||
auto range = a_range.normalized();
|
||||
|
|
|
@ -103,6 +103,7 @@ public:
|
|||
|
||||
void update_views(Badge<TextDocumentLine>);
|
||||
|
||||
String text() const;
|
||||
String text_in_range(const TextRange&) const;
|
||||
|
||||
Vector<TextRange> find_all(const StringView& needle) const;
|
||||
|
@ -210,6 +211,9 @@ public:
|
|||
InsertTextCommand(TextDocument&, const String&, const TextPosition&);
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
virtual bool is_insert_text() const override { return true; }
|
||||
const String& text() const { return m_text; }
|
||||
const TextRange& range() const { return m_range; }
|
||||
|
||||
private:
|
||||
String m_text;
|
||||
|
@ -221,6 +225,8 @@ public:
|
|||
RemoveTextCommand(TextDocument&, const String&, const TextRange&);
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
virtual bool is_remove_text() const override { return true; }
|
||||
const TextRange& range() const { return m_range; }
|
||||
|
||||
private:
|
||||
String m_text;
|
||||
|
|
|
@ -1254,14 +1254,7 @@ bool TextEditor::write_to_file(const StringView& path)
|
|||
|
||||
String TextEditor::text() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < line_count(); ++i) {
|
||||
auto& line = this->line(i);
|
||||
builder.append(line.view());
|
||||
if (i != line_count() - 1)
|
||||
builder.append('\n');
|
||||
}
|
||||
return builder.to_string();
|
||||
return document().text();
|
||||
}
|
||||
|
||||
void TextEditor::clear()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue