mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
LanguageServers/Cpp: Use FileDB and AutoCompleteEngine base class
This commit is contained in:
parent
bed06b13f3
commit
02038a0ede
Notes:
sideshowbarker
2024-07-18 22:28:50 +09:00
Author: https://github.com/itamar8910
Commit: 02038a0ede
Pull-request: https://github.com/SerenityOS/serenity/pull/5244
Reviewed-by: https://github.com/alimpfard
7 changed files with 126 additions and 97 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue