mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
CppLanguageServer: Cache declarations from headers in every document
Previously, to get the globally available declarations in a document (including declarations from headers), we would have to recursively walk the #include tree and get the declarations of each included document. To improve upon this, we now store a HashTable of globally available declaration from included header files in each document, and populate it when we first process the document. Before this, invoking simple autocomplete actions in code documents that had a very large #include tree (e.g when <LibGUI/Widget.h> was included) hang the CppLanguageServer process and used 100% CPU until the process ran out of memory. Now, the autocomplete request in that situation returns immediately :^)
This commit is contained in:
parent
c85775d9f5
commit
5c19a48b95
2 changed files with 18 additions and 15 deletions
|
@ -59,6 +59,9 @@ private:
|
|||
String m_text;
|
||||
OwnPtr<Preprocessor> m_preprocessor;
|
||||
OwnPtr<Parser> m_parser;
|
||||
|
||||
// FIXME: This HashTable must be re-computed if a declaration from a header file is modified
|
||||
HashTable<NonnullRefPtr<Declaration>> m_declarations_from_headers;
|
||||
};
|
||||
|
||||
Vector<GUI::AutocompleteProvider::Entry> autocomplete_property(const DocumentData&, const MemberExpression&, const String partial_text) const;
|
||||
|
@ -85,7 +88,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(const DocumentData&);
|
||||
void update_declared_symbols(DocumentData&);
|
||||
GUI::AutocompleteProvider::DeclarationType type_of_declaration(const Declaration&);
|
||||
String scope_of_declaration(const Declaration&);
|
||||
Optional<GUI::AutocompleteProvider::ProjectLocation> find_preprocessor_definition(const DocumentData&, const GUI::TextPosition&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue