LibGUI+HackStudio: Add an opt-in autocompletion interface to TextEditor

...and use that to implement autocomplete in HackStudio.

Now everyone can have autocomplete :^)
This commit is contained in:
AnotherTest 2020-12-30 13:55:06 +03:30 committed by Andreas Kling
parent 7e457b98c3
commit 20b74e4ede
Notes: sideshowbarker 2024-07-19 00:23:55 +09:00
19 changed files with 211 additions and 162 deletions

View file

@ -35,7 +35,7 @@
namespace LanguageServers::Shell {
Vector<AutoCompleteResponse> AutoComplete::get_suggestions(const String& code, size_t offset)
Vector<GUI::AutocompleteProvider::Entry> AutoComplete::get_suggestions(const String& code, size_t offset)
{
// FIXME: No need to reparse this every time!
auto ast = ::Shell::Parser { code }.parse();
@ -49,7 +49,7 @@ Vector<AutoCompleteResponse> AutoComplete::get_suggestions(const String& code, s
#endif
auto result = ast->complete_for_editor(m_shell, offset);
Vector<AutoCompleteResponse> completions;
Vector<GUI::AutocompleteProvider::Entry> completions;
for (auto& entry : result) {
#ifdef DEBUG_AUTOCOMPLETE
dbgln("Suggestion: '{}' starting at {}", entry.text_string, entry.input_offset);