1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:28:11 +00:00

LanguageServers/Cpp: Use FileDB and AutoCompleteEngine base class

This commit is contained in:
Itamar 2021-02-06 16:25:15 +02:00 committed by Andreas Kling
parent bed06b13f3
commit 02038a0ede
7 changed files with 126 additions and 97 deletions

View file

@ -31,8 +31,19 @@
namespace LanguageServers::Cpp {
Vector<GUI::AutocompleteProvider::Entry> LexerAutoComplete::get_suggestions(const String& code, const GUI::TextPosition& autocomplete_position)
LexerAutoComplete::LexerAutoComplete(const FileDB& filedb)
: AutoCompleteEngine(filedb)
{
}
Vector<GUI::AutocompleteProvider::Entry> LexerAutoComplete::get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position)
{
auto document = filedb().get(file);
if (!document) {
dbgln("didn't find document for {}", file);
return {};
}
auto code = document->text();
auto lines = code.split('\n', true);
Cpp::Lexer lexer(code);
auto tokens = lexer.lex();