1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:27:45 +00:00

LanguageServers: Add function to collect TODO entries in a document

This commit is contained in:
Federico Guerinoni 2021-05-17 22:19:50 +02:00 committed by Linus Groh
parent c397e030f4
commit 26a7356e90
12 changed files with 103 additions and 0 deletions

View file

@ -31,4 +31,11 @@ void CodeComprehensionEngine::set_declarations_of_document(const String& filenam
m_all_declarations.set(filename, declarations);
set_declarations_of_document_callback(filename, move(declarations));
}
void CodeComprehensionEngine::set_todo_entries_of_document(const String& filename, Vector<String>&& todo_entries)
{
VERIFY(set_todo_entries_of_document_callback);
set_todo_entries_of_document_callback(filename, move(todo_entries));
}
}

View file

@ -30,10 +30,12 @@ public:
public:
Function<void(const String&, Vector<GUI::AutocompleteProvider::Declaration>&&)> set_declarations_of_document_callback;
Function<void(const String&, Vector<String>&&)> 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>&&);
void set_todo_entries_of_document(const String&, Vector<String>&&);
const HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>>& all_declarations() const { return m_all_declarations; }
private:

View file

@ -22,6 +22,9 @@ public:
m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) {
async_declarations_in_document(filename, move(declarations));
};
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](const String& filename, Vector<String>&& todo_entries) {
async_todo_entries_in_document(filename, move(todo_entries));
};
}
virtual ~ClientConnection() override = default;

View file

@ -520,6 +520,11 @@ void CppComprehensionEngine::update_declared_symbols(DocumentData& document)
set_declarations_of_document(document.filename(), move(declarations));
}
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)
{
if (decl.is_struct())
@ -574,6 +579,7 @@ OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_docu
root->dump();
update_declared_symbols(*document_data);
update_todo_entries(*document_data);
return document_data;
}

View file

@ -121,6 +121,7 @@ private:
OwnPtr<DocumentData> create_document_data_for(const String& file);
String document_path_from_include_path(const 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;

View file

@ -3,4 +3,5 @@ endpoint LanguageClient
auto_complete_suggestions(Vector<GUI::AutocompleteProvider::Entry> suggestions) =|
declaration_location(GUI::AutocompleteProvider::ProjectLocation location) =|
declarations_in_document(String filename, Vector<GUI::AutocompleteProvider::Declaration> declarations) =|
todo_entries_in_document(String filename, Vector<String> todo_entries) =|
}

View file

@ -21,6 +21,9 @@ class ClientConnection final : public LanguageServers::ClientConnection {
m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) {
async_declarations_in_document(filename, move(declarations));
};
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](const String& filename, Vector<String>&& todo_entries) {
async_todo_entries_in_document(filename, move(todo_entries));
};
}
virtual ~ClientConnection() override = default;
};