ladybird/Userland/Libraries/LibCodeComprehension/CodeComprehensionEngine.h
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30

58 lines
2.1 KiB
C++

/*
* Copyright (c) 2021, Itamar S. <itamar8910@gmail.com>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "FileDB.h"
#include "Types.h"
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/Vector.h>
#include <LibGUI/TextPosition.h>
namespace CodeComprehension {
class CodeComprehensionEngine {
AK_MAKE_NONCOPYABLE(CodeComprehensionEngine);
AK_MAKE_NONMOVABLE(CodeComprehensionEngine);
public:
CodeComprehensionEngine(FileDB const& filedb, bool store_all_declarations = false);
virtual ~CodeComprehensionEngine() = default;
virtual Vector<AutocompleteResultEntry> get_suggestions(ByteString const& file, GUI::TextPosition const& autocomplete_position) = 0;
// TODO: In the future we can pass the range that was edited and only re-parse what we have to.
virtual void on_edit([[maybe_unused]] ByteString const& file) {};
virtual void file_opened([[maybe_unused]] ByteString const& file) {};
virtual Optional<ProjectLocation> find_declaration_of(ByteString const&, GUI::TextPosition const&) { return {}; }
struct FunctionParamsHint {
Vector<ByteString> params;
size_t current_index { 0 };
};
virtual Optional<FunctionParamsHint> get_function_params_hint(ByteString const&, GUI::TextPosition const&) { return {}; }
virtual Vector<TokenInfo> get_tokens_info(ByteString const&) { return {}; }
Function<void(ByteString const&, Vector<Declaration>&&)> set_declarations_of_document_callback;
Function<void(ByteString const&, Vector<TodoEntry>&&)> set_todo_entries_of_document_callback;
protected:
FileDB const& filedb() const { return m_filedb; }
void set_declarations_of_document(ByteString const&, Vector<Declaration>&&);
void set_todo_entries_of_document(ByteString const&, Vector<TodoEntry>&&);
HashMap<ByteString, Vector<Declaration>> const& all_declarations() const { return m_all_declarations; }
private:
HashMap<ByteString, Vector<Declaration>> m_all_declarations;
FileDB const& m_filedb;
bool m_store_all_declarations { false };
};
}