mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
HackStudio: Relay completions requests to the language server unfiltered
Previously, the client would decide when to ask the server for completions, and it would only do so for identifiers that had spans (determined via the highlighter!). Swap this around and make the server decide if it wants to complete something. This commit also adds a CompletionKind (which only has one value: Identifier), to work with other kinds of completions as well.
This commit is contained in:
parent
b42c6ea281
commit
9e73b0b696
12 changed files with 125 additions and 50 deletions
|
@ -28,23 +28,25 @@
|
|||
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <DevTools/HackStudio/AutoCompleteResponse.h>
|
||||
#include <LibCpp/Lexer.h>
|
||||
#include <LibGUI/TextPosition.h>
|
||||
|
||||
namespace LanguageServers::Cpp {
|
||||
|
||||
using namespace ::Cpp;
|
||||
using ::HackStudio::AutoCompleteResponse;
|
||||
|
||||
class AutoComplete {
|
||||
public:
|
||||
AutoComplete() = delete;
|
||||
|
||||
static Vector<String> get_suggestions(const String& code, GUI::TextPosition autocomplete_position);
|
||||
static Vector<AutoCompleteResponse> get_suggestions(const String& code, GUI::TextPosition autocomplete_position);
|
||||
|
||||
private:
|
||||
static Optional<size_t> token_in_position(const Vector<Cpp::Token>&, GUI::TextPosition);
|
||||
static String text_of_token(const Vector<String> lines, const Cpp::Token&);
|
||||
static Vector<String> identifier_prefixes(const Vector<String> lines, const Vector<Cpp::Token>&, size_t target_token_index);
|
||||
static Vector<AutoCompleteResponse> identifier_prefixes(const Vector<String> lines, const Vector<Cpp::Token>&, size_t target_token_index);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue