summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio/LanguageServers
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/DevTools/HackStudio/LanguageServers')
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/ClientConnection.h1
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/Cpp/CMakeLists.txt1
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.h11
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/Cpp/LexerAutoComplete.cpp87
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/Cpp/LexerAutoComplete.h32
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc1
-rw-r--r--Userland/DevTools/HackStudio/LanguageServers/Shell/ClientConnection.h3
7 files changed, 0 insertions, 136 deletions
diff --git a/Userland/DevTools/HackStudio/LanguageServers/ClientConnection.h b/Userland/DevTools/HackStudio/LanguageServers/ClientConnection.h
index acf63dbd3a..2ad2ce92ac 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/ClientConnection.h
+++ b/Userland/DevTools/HackStudio/LanguageServers/ClientConnection.h
@@ -34,7 +34,6 @@ protected:
virtual void set_file_content(String const&, String const&) override;
virtual void auto_complete_suggestions(GUI::AutocompleteProvider::ProjectLocation const&) override;
virtual void find_declaration(GUI::AutocompleteProvider::ProjectLocation const&) override;
- virtual void set_auto_complete_mode(String const&) override = 0;
FileDB m_filedb;
OwnPtr<AutoCompleteEngine> m_autocomplete_engine;
diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CMakeLists.txt b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CMakeLists.txt
index a6c405548d..19e5edd513 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CMakeLists.txt
+++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CMakeLists.txt
@@ -1,5 +1,4 @@
set(SOURCES
- LexerAutoComplete.cpp
ParserAutoComplete.cpp
Tests.cpp
main.cpp
diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.h b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.h
index 248e764684..405727ed46 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.h
+++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.h
@@ -6,7 +6,6 @@
#pragma once
-#include "LexerAutoComplete.h"
#include "ParserAutoComplete.h"
#include <DevTools/HackStudio/LanguageServers/ClientConnection.h>
@@ -26,15 +25,5 @@ public:
}
virtual ~ClientConnection() override = default;
-
-private:
- virtual void set_auto_complete_mode(String const& mode) override
- {
- dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "SetAutoCompleteMode: {}", mode);
- if (mode == "Parser")
- m_autocomplete_engine = make<ParserAutoComplete>(m_filedb);
- else
- m_autocomplete_engine = make<LexerAutoComplete>(m_filedb);
- }
};
}
diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/LexerAutoComplete.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/LexerAutoComplete.cpp
deleted file mode 100644
index fa59fbcd8f..0000000000
--- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/LexerAutoComplete.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "LexerAutoComplete.h"
-#include <AK/Debug.h>
-#include <AK/HashTable.h>
-#include <LibCpp/Lexer.h>
-
-namespace LanguageServers::Cpp {
-
-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();
-
- auto index_of_target_token = token_in_position(tokens, autocomplete_position);
- if (!index_of_target_token.has_value())
- return {};
-
- auto suggestions = identifier_prefixes(lines, tokens, index_of_target_token.value());
-
- if constexpr (AUTOCOMPLETE_DEBUG) {
- for (auto& suggestion : suggestions) {
- dbgln("suggestion: {}", suggestion.completion);
- }
- }
-
- return suggestions;
-}
-
-StringView LexerAutoComplete::text_of_token(const Vector<String>& lines, const Cpp::Token& token)
-{
- VERIFY(token.start().line == token.end().line);
- VERIFY(token.start().column <= token.end().column);
- return lines[token.start().line].substring_view(token.start().column, token.end().column - token.start().column + 1);
-}
-
-Optional<size_t> LexerAutoComplete::token_in_position(const Vector<Cpp::Token>& tokens, const GUI::TextPosition& position)
-{
- for (size_t token_index = 0; token_index < tokens.size(); ++token_index) {
- auto& token = tokens[token_index];
- if (token.start().line != token.end().line)
- continue;
- if (token.start().line != position.line())
- continue;
- if (token.start().column + 1 > position.column() || token.end().column + 1 < position.column())
- continue;
- return token_index;
- }
- return {};
-}
-
-Vector<GUI::AutocompleteProvider::Entry> LexerAutoComplete::identifier_prefixes(const Vector<String>& lines, const Vector<Cpp::Token>& tokens, size_t target_token_index)
-{
- auto partial_input = text_of_token(lines, tokens[target_token_index]);
- Vector<GUI::AutocompleteProvider::Entry> suggestions;
-
- HashTable<String> suggestions_lookup; // To avoid duplicate results
-
- for (size_t i = 0; i < target_token_index; ++i) {
- auto& token = tokens[i];
- if (token.type() != Cpp::Token::Type::Identifier)
- continue;
- auto text = text_of_token(lines, token);
- if (text.starts_with(partial_input) && suggestions_lookup.set(text) == AK::HashSetResult::InsertedNewEntry) {
- suggestions.append({ text, partial_input.length(), GUI::AutocompleteProvider::CompletionKind::Identifier });
- }
- }
- return suggestions;
-}
-
-}
diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/LexerAutoComplete.h b/Userland/DevTools/HackStudio/LanguageServers/Cpp/LexerAutoComplete.h
deleted file mode 100644
index 697a7e8094..0000000000
--- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/LexerAutoComplete.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/String.h>
-#include <AK/Vector.h>
-#include <DevTools/HackStudio/AutoCompleteResponse.h>
-#include <DevTools/HackStudio/LanguageServers/AutoCompleteEngine.h>
-#include <LibCpp/Lexer.h>
-#include <LibGUI/TextPosition.h>
-
-namespace LanguageServers::Cpp {
-
-using namespace ::Cpp;
-
-class LexerAutoComplete : public AutoCompleteEngine {
-public:
- LexerAutoComplete(const FileDB& filedb);
-
- virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) override;
-
-private:
- Optional<size_t> token_in_position(const Vector<Cpp::Token>&, const GUI::TextPosition&);
- StringView text_of_token(const Vector<String>& lines, const Cpp::Token&);
- Vector<GUI::AutocompleteProvider::Entry> identifier_prefixes(const Vector<String>& lines, const Vector<Cpp::Token>&, size_t target_token_index);
-};
-
-}
diff --git a/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc b/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc
index 036f5f514c..1ab41a93ea 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc
+++ b/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc
@@ -8,6 +8,5 @@ endpoint LanguageServer
set_file_content(String filename, String content) =|
auto_complete_suggestions(GUI::AutocompleteProvider::ProjectLocation location) =|
- set_auto_complete_mode(String mode) =|
find_declaration(GUI::AutocompleteProvider::ProjectLocation location) =|
}
diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/ClientConnection.h b/Userland/DevTools/HackStudio/LanguageServers/Shell/ClientConnection.h
index e359ba8497..cca280f166 100644
--- a/Userland/DevTools/HackStudio/LanguageServers/Shell/ClientConnection.h
+++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/ClientConnection.h
@@ -23,8 +23,5 @@ class ClientConnection final : public LanguageServers::ClientConnection {
};
}
virtual ~ClientConnection() override = default;
-
-private:
- virtual void set_auto_complete_mode(String const&) override { }
};
}