1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

LibCodeComprehension: Re-organize code comprehension related code

This moves all code comprehension-related code to a new library,
LibCodeComprehension.

This also moves some types related to code comprehension tasks (such as
autocomplete, find declaration) out of LibGUI and into
LibCodeComprehension.
This commit is contained in:
Itamar 2022-05-14 17:09:24 +03:00 committed by Andreas Kling
parent a2c34554cd
commit b35293d945
65 changed files with 685 additions and 491 deletions

View file

@ -9,22 +9,22 @@
#include <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
#include <LibCodeComprehension/FileDB.h>
#include <LibGUI/TextDocument.h>
namespace LanguageServers {
class FileDB final {
class FileDB final : public CodeComprehension::FileDB {
public:
RefPtr<const GUI::TextDocument> get(String const& filename) const;
RefPtr<GUI::TextDocument> get(String const& filename);
RefPtr<const GUI::TextDocument> get_or_create_from_filesystem(String const& filename) const;
RefPtr<GUI::TextDocument> get_or_create_from_filesystem(String const& filename);
FileDB() = default;
virtual Optional<String> get_or_read_from_filesystem(StringView filename) const override;
RefPtr<const GUI::TextDocument> get_document(String const& filename) const;
RefPtr<GUI::TextDocument> get_document(String const& filename);
bool add(String const& filename, int fd);
bool add(String const& filename, String const& content);
void set_project_root(String const& root_path) { m_project_root = root_path; }
String const& project_root() const { return m_project_root; }
void on_file_edit_insert_text(String const& filename, String const& inserted_text, size_t start_line, size_t start_column);
void on_file_edit_remove_text(String const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column);
String to_absolute_path(String const& filename) const;