mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:47:46 +00:00
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')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -15,7 +15,7 @@ CodeComprehensionEngine::CodeComprehensionEngine(FileDB const& filedb, bool shou
|
|||
{
|
||||
}
|
||||
|
||||
void CodeComprehensionEngine::set_declarations_of_document(DeprecatedString const& filename, Vector<Declaration>&& declarations)
|
||||
void CodeComprehensionEngine::set_declarations_of_document(ByteString const& filename, Vector<Declaration>&& declarations)
|
||||
{
|
||||
// Callback may not be configured if we're running tests
|
||||
if (!set_declarations_of_document_callback)
|
||||
|
@ -31,7 +31,7 @@ void CodeComprehensionEngine::set_declarations_of_document(DeprecatedString cons
|
|||
set_declarations_of_document_callback(filename, move(declarations));
|
||||
}
|
||||
|
||||
void CodeComprehensionEngine::set_todo_entries_of_document(DeprecatedString const& filename, Vector<TodoEntry>&& todo_entries)
|
||||
void CodeComprehensionEngine::set_todo_entries_of_document(ByteString const& filename, Vector<TodoEntry>&& todo_entries)
|
||||
{
|
||||
// Callback may not be configured if we're running tests
|
||||
if (!set_todo_entries_of_document_callback)
|
||||
|
|
|
@ -24,33 +24,33 @@ public:
|
|||
CodeComprehensionEngine(FileDB const& filedb, bool store_all_declarations = false);
|
||||
virtual ~CodeComprehensionEngine() = default;
|
||||
|
||||
virtual Vector<AutocompleteResultEntry> get_suggestions(DeprecatedString const& file, GUI::TextPosition const& autocomplete_position) = 0;
|
||||
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]] DeprecatedString const& file) {};
|
||||
virtual void file_opened([[maybe_unused]] DeprecatedString const& file) {};
|
||||
virtual void on_edit([[maybe_unused]] ByteString const& file) {};
|
||||
virtual void file_opened([[maybe_unused]] ByteString const& file) {};
|
||||
|
||||
virtual Optional<ProjectLocation> find_declaration_of(DeprecatedString const&, GUI::TextPosition const&) { return {}; }
|
||||
virtual Optional<ProjectLocation> find_declaration_of(ByteString const&, GUI::TextPosition const&) { return {}; }
|
||||
|
||||
struct FunctionParamsHint {
|
||||
Vector<DeprecatedString> params;
|
||||
Vector<ByteString> params;
|
||||
size_t current_index { 0 };
|
||||
};
|
||||
virtual Optional<FunctionParamsHint> get_function_params_hint(DeprecatedString const&, GUI::TextPosition const&) { return {}; }
|
||||
virtual Optional<FunctionParamsHint> get_function_params_hint(ByteString const&, GUI::TextPosition const&) { return {}; }
|
||||
|
||||
virtual Vector<TokenInfo> get_tokens_info(DeprecatedString const&) { return {}; }
|
||||
virtual Vector<TokenInfo> get_tokens_info(ByteString const&) { return {}; }
|
||||
|
||||
Function<void(DeprecatedString const&, Vector<Declaration>&&)> set_declarations_of_document_callback;
|
||||
Function<void(DeprecatedString const&, Vector<TodoEntry>&&)> set_todo_entries_of_document_callback;
|
||||
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(DeprecatedString const&, Vector<Declaration>&&);
|
||||
void set_todo_entries_of_document(DeprecatedString const&, Vector<TodoEntry>&&);
|
||||
HashMap<DeprecatedString, Vector<Declaration>> const& all_declarations() const { return m_all_declarations; }
|
||||
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<DeprecatedString, Vector<Declaration>> m_all_declarations;
|
||||
HashMap<ByteString, Vector<Declaration>> m_all_declarations;
|
||||
FileDB const& m_filedb;
|
||||
bool m_store_all_declarations { false };
|
||||
};
|
||||
|
|
|
@ -19,10 +19,10 @@ private:
|
|||
: LanguageServers::ConnectionFromClient(move(socket))
|
||||
{
|
||||
m_autocomplete_engine = make<CodeComprehension::Cpp::CppComprehensionEngine>(m_filedb);
|
||||
m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
|
||||
m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
|
||||
async_declarations_in_document(filename, move(declarations));
|
||||
};
|
||||
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
|
||||
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
|
||||
async_todo_entries_in_document(filename, move(todo_entries));
|
||||
};
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ CppComprehensionEngine::CppComprehensionEngine(FileDB const& filedb)
|
|||
{
|
||||
}
|
||||
|
||||
CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_create_document_data(DeprecatedString const& file)
|
||||
CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_create_document_data(ByteString const& file)
|
||||
{
|
||||
auto absolute_path = filedb().to_absolute_path(file);
|
||||
if (!m_documents.contains(absolute_path)) {
|
||||
|
@ -34,7 +34,7 @@ CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_creat
|
|||
return get_document_data(absolute_path);
|
||||
}
|
||||
|
||||
CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document_data(DeprecatedString const& file) const
|
||||
CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document_data(ByteString const& file) const
|
||||
{
|
||||
auto absolute_path = filedb().to_absolute_path(file);
|
||||
auto document_data = m_documents.get(absolute_path);
|
||||
|
@ -43,7 +43,7 @@ CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document
|
|||
return document_data.value();
|
||||
}
|
||||
|
||||
OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data_for(DeprecatedString const& file)
|
||||
OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data_for(ByteString const& file)
|
||||
{
|
||||
if (m_unfinished_documents.contains(file)) {
|
||||
return {};
|
||||
|
@ -56,12 +56,12 @@ OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_docu
|
|||
return create_document_data(move(document.value()), file);
|
||||
}
|
||||
|
||||
void CppComprehensionEngine::set_document_data(DeprecatedString const& file, OwnPtr<DocumentData>&& data)
|
||||
void CppComprehensionEngine::set_document_data(ByteString const& file, OwnPtr<DocumentData>&& data)
|
||||
{
|
||||
m_documents.set(filedb().to_absolute_path(file), move(data));
|
||||
}
|
||||
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::get_suggestions(DeprecatedString const& file, const GUI::TextPosition& autocomplete_position)
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::get_suggestions(ByteString const& file, const GUI::TextPosition& autocomplete_position)
|
||||
{
|
||||
Cpp::Position position { autocomplete_position.line(), autocomplete_position.column() > 0 ? autocomplete_position.column() - 1 : 0 };
|
||||
|
||||
|
@ -104,7 +104,7 @@ Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::get_s
|
|||
|
||||
Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEngine::try_autocomplete_name(DocumentData const& document, ASTNode const& node, Optional<Token> containing_token) const
|
||||
{
|
||||
auto partial_text = DeprecatedString::empty();
|
||||
auto partial_text = ByteString::empty();
|
||||
if (containing_token.has_value() && containing_token.value().type() != Token::Type::ColonColon) {
|
||||
partial_text = containing_token.value().text();
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
|
|||
|
||||
auto const& parent = static_cast<MemberExpression const&>(*node.parent());
|
||||
|
||||
auto partial_text = DeprecatedString::empty();
|
||||
auto partial_text = ByteString::empty();
|
||||
if (containing_token.value().type() != Token::Type::Dot) {
|
||||
if (&node != parent.property())
|
||||
return {};
|
||||
|
@ -131,7 +131,7 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
|
|||
return autocomplete_property(document, parent, partial_text);
|
||||
}
|
||||
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::autocomplete_name(DocumentData const& document, ASTNode const& node, DeprecatedString const& partial_text) const
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::autocomplete_name(DocumentData const& document, ASTNode const& node, ByteString const& partial_text) const
|
||||
{
|
||||
auto reference_scope = scope_of_reference_to_symbol(node);
|
||||
auto current_scope = scope_of_node(node);
|
||||
|
@ -206,7 +206,7 @@ Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(ASTNode
|
|||
return scope_parts;
|
||||
}
|
||||
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, const DeprecatedString partial_text) const
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, const ByteString partial_text) const
|
||||
{
|
||||
VERIFY(parent.object());
|
||||
auto type = type_of(document, *parent.object());
|
||||
|
@ -233,7 +233,7 @@ bool CppComprehensionEngine::is_property(ASTNode const& node) const
|
|||
return parent.property() == &node;
|
||||
}
|
||||
|
||||
DeprecatedString CppComprehensionEngine::type_of_property(DocumentData const& document, Identifier const& identifier) const
|
||||
ByteString CppComprehensionEngine::type_of_property(DocumentData const& document, Identifier const& identifier) const
|
||||
{
|
||||
auto& parent = verify_cast<MemberExpression>(*identifier.parent());
|
||||
VERIFY(parent.object());
|
||||
|
@ -253,12 +253,12 @@ DeprecatedString CppComprehensionEngine::type_of_property(DocumentData const& do
|
|||
VERIFY(verify_cast<NamedType>(*type).name());
|
||||
if (verify_cast<NamedType>(*type).name())
|
||||
return verify_cast<NamedType>(*type).name()->full_name();
|
||||
return DeprecatedString::empty();
|
||||
return ByteString::empty();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
DeprecatedString CppComprehensionEngine::type_of_variable(Identifier const& identifier) const
|
||||
ByteString CppComprehensionEngine::type_of_variable(Identifier const& identifier) const
|
||||
{
|
||||
ASTNode const* current = &identifier;
|
||||
while (current) {
|
||||
|
@ -269,7 +269,7 @@ DeprecatedString CppComprehensionEngine::type_of_variable(Identifier const& iden
|
|||
VERIFY(verify_cast<NamedType>(*var_or_param.type()).name());
|
||||
if (verify_cast<NamedType>(*var_or_param.type()).name())
|
||||
return verify_cast<NamedType>(*var_or_param.type()).name()->full_name();
|
||||
return DeprecatedString::empty();
|
||||
return ByteString::empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ DeprecatedString CppComprehensionEngine::type_of_variable(Identifier const& iden
|
|||
return {};
|
||||
}
|
||||
|
||||
DeprecatedString CppComprehensionEngine::type_of(DocumentData const& document, Expression const& expression) const
|
||||
ByteString CppComprehensionEngine::type_of(DocumentData const& document, Expression const& expression) const
|
||||
{
|
||||
if (expression.is_member_expression()) {
|
||||
auto& member_expression = verify_cast<MemberExpression>(expression);
|
||||
|
@ -304,7 +304,7 @@ DeprecatedString CppComprehensionEngine::type_of(DocumentData const& document, E
|
|||
return type_of_variable(*identifier);
|
||||
}
|
||||
|
||||
Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_type(DocumentData const& document, DeprecatedString const& type) const
|
||||
Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_type(DocumentData const& document, ByteString const& type) const
|
||||
{
|
||||
auto type_symbol = SymbolName::create(type);
|
||||
auto decl = find_declaration_of(document, type_symbol);
|
||||
|
@ -362,21 +362,21 @@ Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols
|
|||
return symbols;
|
||||
}
|
||||
|
||||
DeprecatedString CppComprehensionEngine::document_path_from_include_path(StringView include_path) const
|
||||
ByteString CppComprehensionEngine::document_path_from_include_path(StringView include_path) const
|
||||
{
|
||||
static Regex<PosixExtended> library_include("<(.+)>");
|
||||
static Regex<PosixExtended> user_defined_include("\"(.+)\"");
|
||||
|
||||
auto document_path_for_library_include = [&](StringView include_path) -> DeprecatedString {
|
||||
auto document_path_for_library_include = [&](StringView include_path) -> ByteString {
|
||||
RegexResult result;
|
||||
if (!library_include.search(include_path, result))
|
||||
return {};
|
||||
|
||||
auto path = result.capture_group_matches.at(0).at(0).view.string_view();
|
||||
return DeprecatedString::formatted("/usr/include/{}", path);
|
||||
return ByteString::formatted("/usr/include/{}", path);
|
||||
};
|
||||
|
||||
auto document_path_for_user_defined_include = [&](StringView include_path) -> DeprecatedString {
|
||||
auto document_path_for_user_defined_include = [&](StringView include_path) -> ByteString {
|
||||
RegexResult result;
|
||||
if (!user_defined_include.search(include_path, result))
|
||||
return {};
|
||||
|
@ -391,17 +391,17 @@ DeprecatedString CppComprehensionEngine::document_path_from_include_path(StringV
|
|||
return result;
|
||||
}
|
||||
|
||||
void CppComprehensionEngine::on_edit(DeprecatedString const& file)
|
||||
void CppComprehensionEngine::on_edit(ByteString const& file)
|
||||
{
|
||||
set_document_data(file, create_document_data_for(file));
|
||||
}
|
||||
|
||||
void CppComprehensionEngine::file_opened([[maybe_unused]] DeprecatedString const& file)
|
||||
void CppComprehensionEngine::file_opened([[maybe_unused]] ByteString const& file)
|
||||
{
|
||||
get_or_create_document_data(file);
|
||||
}
|
||||
|
||||
Optional<CodeComprehension::ProjectLocation> CppComprehensionEngine::find_declaration_of(DeprecatedString const& filename, const GUI::TextPosition& identifier_position)
|
||||
Optional<CodeComprehension::ProjectLocation> CppComprehensionEngine::find_declaration_of(ByteString const& filename, const GUI::TextPosition& identifier_position)
|
||||
{
|
||||
auto const* document_ptr = get_or_create_document_data(filename);
|
||||
if (!document_ptr)
|
||||
|
@ -456,10 +456,10 @@ struct TargetDeclaration {
|
|||
Property,
|
||||
Scope
|
||||
} type;
|
||||
DeprecatedString name;
|
||||
ByteString name;
|
||||
};
|
||||
|
||||
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, DeprecatedString name);
|
||||
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, ByteString name);
|
||||
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node)
|
||||
{
|
||||
if (node.is_identifier()) {
|
||||
|
@ -478,7 +478,7 @@ static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node)
|
|||
return {};
|
||||
}
|
||||
|
||||
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, DeprecatedString name)
|
||||
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, ByteString name)
|
||||
{
|
||||
if (node.parent() && node.parent()->is_name()) {
|
||||
auto& name_node = *verify_cast<Name>(node.parent());
|
||||
|
@ -612,7 +612,7 @@ CodeComprehension::DeclarationType CppComprehensionEngine::type_of_declaration(C
|
|||
return CodeComprehension::DeclarationType::Variable;
|
||||
}
|
||||
|
||||
OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data(DeprecatedString text, DeprecatedString const& filename)
|
||||
OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data(ByteString text, ByteString const& filename)
|
||||
{
|
||||
auto document_data = make<DocumentData>();
|
||||
document_data->m_filename = filename;
|
||||
|
@ -693,7 +693,7 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
|
|||
System,
|
||||
} include_type { Project };
|
||||
|
||||
DeprecatedString include_root;
|
||||
ByteString include_root;
|
||||
bool already_has_suffix = false;
|
||||
if (partial_include.starts_with('<')) {
|
||||
include_root = "/usr/include/";
|
||||
|
@ -716,7 +716,7 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
|
|||
return {};
|
||||
|
||||
auto last_slash = partial_include.find_last('/');
|
||||
auto include_dir = DeprecatedString::empty();
|
||||
auto include_dir = ByteString::empty();
|
||||
auto partial_basename = partial_include.substring_view((last_slash.has_value() ? last_slash.value() : 0) + 1);
|
||||
if (last_slash.has_value()) {
|
||||
include_dir = partial_include.substring_view(1, last_slash.value());
|
||||
|
@ -738,12 +738,12 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
|
|||
|
||||
if (FileSystem::is_directory(LexicalPath::join(full_dir, path).string())) {
|
||||
// FIXME: Don't dismiss the autocomplete when filling these suggestions.
|
||||
auto completion = DeprecatedString::formatted("{}{}{}/", prefix, include_dir, path);
|
||||
auto completion = ByteString::formatted("{}{}{}/", prefix, include_dir, path);
|
||||
options.empend(completion, include_dir.length() + partial_basename.length() + 1, CodeComprehension::Language::Cpp, path, CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying::No);
|
||||
} else if (path.ends_with(".h"sv)) {
|
||||
// FIXME: Place the cursor after the trailing > or ", even if it was
|
||||
// already typed.
|
||||
auto completion = DeprecatedString::formatted("{}{}{}{}", prefix, include_dir, path, already_has_suffix ? "" : suffix);
|
||||
auto completion = ByteString::formatted("{}{}{}{}", prefix, include_dir, path, already_has_suffix ? "" : suffix);
|
||||
options.empend(completion, include_dir.length() + partial_basename.length() + 1, CodeComprehension::Language::Cpp, path);
|
||||
}
|
||||
}
|
||||
|
@ -764,17 +764,17 @@ RefPtr<Cpp::Declaration const> CppComprehensionEngine::find_declaration_of(CppCo
|
|||
return target_declaration;
|
||||
}
|
||||
|
||||
DeprecatedString CppComprehensionEngine::SymbolName::scope_as_string() const
|
||||
ByteString CppComprehensionEngine::SymbolName::scope_as_string() const
|
||||
{
|
||||
if (scope.is_empty())
|
||||
return DeprecatedString::empty();
|
||||
return ByteString::empty();
|
||||
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < scope.size() - 1; ++i) {
|
||||
builder.appendff("{}::", scope[i]);
|
||||
}
|
||||
builder.append(scope.last());
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
CppComprehensionEngine::SymbolName CppComprehensionEngine::SymbolName::create(StringView name, Vector<StringView>&& scope)
|
||||
|
@ -790,11 +790,11 @@ CppComprehensionEngine::SymbolName CppComprehensionEngine::SymbolName::create(St
|
|||
return SymbolName::create(name, move(parts));
|
||||
}
|
||||
|
||||
DeprecatedString CppComprehensionEngine::SymbolName::to_deprecated_string() const
|
||||
ByteString CppComprehensionEngine::SymbolName::to_byte_string() const
|
||||
{
|
||||
if (scope.is_empty())
|
||||
return name;
|
||||
return DeprecatedString::formatted("{}::{}", scope_as_string(), name);
|
||||
return ByteString::formatted("{}::{}", scope_as_string(), name);
|
||||
}
|
||||
|
||||
bool CppComprehensionEngine::is_symbol_available(Symbol const& symbol, Vector<StringView> const& current_scope, Vector<StringView> const& reference_scope)
|
||||
|
@ -818,7 +818,7 @@ bool CppComprehensionEngine::is_symbol_available(Symbol const& symbol, Vector<St
|
|||
return true;
|
||||
}
|
||||
|
||||
Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get_function_params_hint(DeprecatedString const& filename, const GUI::TextPosition& identifier_position)
|
||||
Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get_function_params_hint(ByteString const& filename, const GUI::TextPosition& identifier_position)
|
||||
{
|
||||
auto const* document_ptr = get_or_create_document_data(filename);
|
||||
if (!document_ptr)
|
||||
|
@ -923,13 +923,13 @@ Optional<CppComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get
|
|||
for (auto token : document_of_declaration->parser().tokens_in_range(arg->start(), arg->end())) {
|
||||
tokens_text.append(token.text());
|
||||
}
|
||||
hint.params.append(DeprecatedString::join(' ', tokens_text));
|
||||
hint.params.append(ByteString::join(' ', tokens_text));
|
||||
}
|
||||
|
||||
return hint;
|
||||
}
|
||||
|
||||
Vector<CodeComprehension::TokenInfo> CppComprehensionEngine::get_tokens_info(DeprecatedString const& filename)
|
||||
Vector<CodeComprehension::TokenInfo> CppComprehensionEngine::get_tokens_info(ByteString const& filename)
|
||||
{
|
||||
dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "CppComprehensionEngine::get_tokens_info: {}", filename);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <DevTools/HackStudio/AutoCompleteResponse.h>
|
||||
|
@ -25,12 +25,12 @@ class CppComprehensionEngine : public CodeComprehensionEngine {
|
|||
public:
|
||||
CppComprehensionEngine(FileDB const& filedb);
|
||||
|
||||
virtual Vector<CodeComprehension::AutocompleteResultEntry> get_suggestions(DeprecatedString const& file, GUI::TextPosition const& autocomplete_position) override;
|
||||
virtual void on_edit(DeprecatedString const& file) override;
|
||||
virtual void file_opened([[maybe_unused]] DeprecatedString const& file) override;
|
||||
virtual Optional<CodeComprehension::ProjectLocation> find_declaration_of(DeprecatedString const& filename, GUI::TextPosition const& identifier_position) override;
|
||||
virtual Optional<FunctionParamsHint> get_function_params_hint(DeprecatedString const&, GUI::TextPosition const&) override;
|
||||
virtual Vector<CodeComprehension::TokenInfo> get_tokens_info(DeprecatedString const& filename) override;
|
||||
virtual Vector<CodeComprehension::AutocompleteResultEntry> get_suggestions(ByteString const& file, GUI::TextPosition const& autocomplete_position) override;
|
||||
virtual void on_edit(ByteString const& file) override;
|
||||
virtual void file_opened([[maybe_unused]] ByteString const& file) override;
|
||||
virtual Optional<CodeComprehension::ProjectLocation> find_declaration_of(ByteString const& filename, GUI::TextPosition const& identifier_position) override;
|
||||
virtual Optional<FunctionParamsHint> get_function_params_hint(ByteString const&, GUI::TextPosition const&) override;
|
||||
virtual Vector<CodeComprehension::TokenInfo> get_tokens_info(ByteString const& filename) override;
|
||||
|
||||
private:
|
||||
struct SymbolName {
|
||||
|
@ -39,8 +39,8 @@ private:
|
|||
|
||||
static SymbolName create(StringView, Vector<StringView>&&);
|
||||
static SymbolName create(StringView);
|
||||
DeprecatedString scope_as_string() const;
|
||||
DeprecatedString to_deprecated_string() const;
|
||||
ByteString scope_as_string() const;
|
||||
ByteString to_byte_string() const;
|
||||
|
||||
bool operator==(SymbolName const&) const = default;
|
||||
};
|
||||
|
@ -63,8 +63,8 @@ private:
|
|||
friend Traits<SymbolName>;
|
||||
|
||||
struct DocumentData {
|
||||
DeprecatedString const& filename() const { return m_filename; }
|
||||
DeprecatedString const& text() const { return m_text; }
|
||||
ByteString const& filename() const { return m_filename; }
|
||||
ByteString const& text() const { return m_text; }
|
||||
Preprocessor const& preprocessor() const
|
||||
{
|
||||
VERIFY(m_preprocessor);
|
||||
|
@ -86,20 +86,20 @@ private:
|
|||
return *m_parser;
|
||||
}
|
||||
|
||||
DeprecatedString m_filename;
|
||||
DeprecatedString m_text;
|
||||
ByteString m_filename;
|
||||
ByteString m_text;
|
||||
OwnPtr<Preprocessor> m_preprocessor;
|
||||
OwnPtr<Parser> m_parser;
|
||||
|
||||
HashMap<SymbolName, Symbol> m_symbols;
|
||||
HashTable<DeprecatedString> m_available_headers;
|
||||
HashTable<ByteString> m_available_headers;
|
||||
};
|
||||
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> autocomplete_property(DocumentData const&, MemberExpression const&, const DeprecatedString partial_text) const;
|
||||
Vector<AutocompleteResultEntry> autocomplete_name(DocumentData const&, ASTNode const&, DeprecatedString const& partial_text) const;
|
||||
DeprecatedString type_of(DocumentData const&, Expression const&) const;
|
||||
DeprecatedString type_of_property(DocumentData const&, Identifier const&) const;
|
||||
DeprecatedString type_of_variable(Identifier const&) const;
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> autocomplete_property(DocumentData const&, MemberExpression const&, const ByteString partial_text) const;
|
||||
Vector<AutocompleteResultEntry> autocomplete_name(DocumentData const&, ASTNode const&, ByteString const& partial_text) const;
|
||||
ByteString type_of(DocumentData const&, Expression const&) const;
|
||||
ByteString type_of_property(DocumentData const&, Identifier const&) const;
|
||||
ByteString type_of_variable(Identifier const&) const;
|
||||
bool is_property(ASTNode const&) const;
|
||||
RefPtr<Cpp::Declaration const> find_declaration_of(DocumentData const&, ASTNode const&) const;
|
||||
RefPtr<Cpp::Declaration const> find_declaration_of(DocumentData const&, SymbolName const&) const;
|
||||
|
@ -110,16 +110,16 @@ private:
|
|||
Yes
|
||||
};
|
||||
|
||||
Vector<Symbol> properties_of_type(DocumentData const& document, DeprecatedString const& type) const;
|
||||
Vector<Symbol> properties_of_type(DocumentData const& document, ByteString const& type) const;
|
||||
Vector<Symbol> get_child_symbols(ASTNode const&) const;
|
||||
Vector<Symbol> get_child_symbols(ASTNode const&, Vector<StringView> const& scope, Symbol::IsLocal) const;
|
||||
|
||||
DocumentData const* get_document_data(DeprecatedString const& file) const;
|
||||
DocumentData const* get_or_create_document_data(DeprecatedString const& file);
|
||||
void set_document_data(DeprecatedString const& file, OwnPtr<DocumentData>&& data);
|
||||
DocumentData const* get_document_data(ByteString const& file) const;
|
||||
DocumentData const* get_or_create_document_data(ByteString const& file);
|
||||
void set_document_data(ByteString const& file, OwnPtr<DocumentData>&& data);
|
||||
|
||||
OwnPtr<DocumentData> create_document_data_for(DeprecatedString const& file);
|
||||
DeprecatedString document_path_from_include_path(StringView include_path) const;
|
||||
OwnPtr<DocumentData> create_document_data_for(ByteString const& file);
|
||||
ByteString document_path_from_include_path(StringView include_path) const;
|
||||
void update_declared_symbols(DocumentData&);
|
||||
void update_todo_entries(DocumentData&);
|
||||
CodeComprehension::DeclarationType type_of_declaration(Cpp::Declaration const&);
|
||||
|
@ -129,7 +129,7 @@ private:
|
|||
Optional<CodeComprehension::ProjectLocation> find_preprocessor_definition(DocumentData const&, const GUI::TextPosition&);
|
||||
Optional<Cpp::Preprocessor::Substitution> find_preprocessor_substitution(DocumentData const&, Cpp::Position const&);
|
||||
|
||||
OwnPtr<DocumentData> create_document_data(DeprecatedString text, DeprecatedString const& filename);
|
||||
OwnPtr<DocumentData> create_document_data(ByteString text, ByteString const& filename);
|
||||
Optional<Vector<CodeComprehension::AutocompleteResultEntry>> try_autocomplete_property(DocumentData const&, ASTNode const&, Optional<Token> containing_token) const;
|
||||
Optional<Vector<CodeComprehension::AutocompleteResultEntry>> try_autocomplete_name(DocumentData const&, ASTNode const&, Optional<Token> containing_token) const;
|
||||
Optional<Vector<CodeComprehension::AutocompleteResultEntry>> try_autocomplete_include(DocumentData const&, Token include_path_token, Cpp::Position const& cursor_position) const;
|
||||
|
@ -145,12 +145,12 @@ private:
|
|||
CodeComprehension::TokenInfo::SemanticType get_token_semantic_type(DocumentData const&, Token const&);
|
||||
CodeComprehension::TokenInfo::SemanticType get_semantic_type_for_identifier(DocumentData const&, Position);
|
||||
|
||||
HashMap<DeprecatedString, OwnPtr<DocumentData>> m_documents;
|
||||
HashMap<ByteString, OwnPtr<DocumentData>> m_documents;
|
||||
|
||||
// A document's path will be in this set if we're currently processing it.
|
||||
// A document is added to this set when we start processing it (e.g because it was #included) and removed when we're done.
|
||||
// We use this to prevent circular #includes from looping indefinitely.
|
||||
HashTable<DeprecatedString> m_unfinished_documents;
|
||||
HashTable<ByteString> m_unfinished_documents;
|
||||
};
|
||||
|
||||
template<typename Func>
|
||||
|
|
|
@ -44,14 +44,14 @@ class FileDB : public CodeComprehension::FileDB {
|
|||
public:
|
||||
FileDB() = default;
|
||||
|
||||
void add(DeprecatedString filename, DeprecatedString content)
|
||||
void add(ByteString filename, ByteString content)
|
||||
{
|
||||
m_map.set(filename, content);
|
||||
}
|
||||
|
||||
virtual Optional<DeprecatedString> get_or_read_from_filesystem(StringView filename) const override
|
||||
virtual Optional<ByteString> get_or_read_from_filesystem(StringView filename) const override
|
||||
{
|
||||
DeprecatedString target_filename = filename;
|
||||
ByteString target_filename = filename;
|
||||
if (project_root().has_value() && filename.starts_with(*project_root())) {
|
||||
target_filename = LexicalPath::relative_path(filename, *project_root());
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
HashMap<DeprecatedString, DeprecatedString> m_map;
|
||||
HashMap<ByteString, ByteString> m_map;
|
||||
};
|
||||
|
||||
static void test_complete_local_args();
|
||||
|
@ -86,10 +86,10 @@ int run_tests()
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void add_file(FileDB& filedb, DeprecatedString const& name)
|
||||
static void add_file(FileDB& filedb, ByteString const& name)
|
||||
{
|
||||
auto file = Core::File::open(LexicalPath::join(TESTS_ROOT_DIR, name).string(), Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
|
||||
filedb.add(name, DeprecatedString::copy(MUST(file->read_until_eof())));
|
||||
filedb.add(name, ByteString::copy(MUST(file->read_until_eof())));
|
||||
}
|
||||
|
||||
void test_complete_local_args()
|
||||
|
@ -246,19 +246,19 @@ void test_parameters_hint()
|
|||
auto result = engine.get_function_params_hint("parameters_hint1.cpp", { 4, 9 });
|
||||
if (!result.has_value())
|
||||
FAIL("failed to get parameters hint (1)");
|
||||
if (result->params != Vector<DeprecatedString> { "int x", "char y" } || result->current_index != 0)
|
||||
if (result->params != Vector<ByteString> { "int x", "char y" } || result->current_index != 0)
|
||||
FAIL("bad result (1)");
|
||||
|
||||
result = engine.get_function_params_hint("parameters_hint1.cpp", { 5, 15 });
|
||||
if (!result.has_value())
|
||||
FAIL("failed to get parameters hint (2)");
|
||||
if (result->params != Vector<DeprecatedString> { "int x", "char y" } || result->current_index != 1)
|
||||
if (result->params != Vector<ByteString> { "int x", "char y" } || result->current_index != 1)
|
||||
FAIL("bad result (2)");
|
||||
|
||||
result = engine.get_function_params_hint("parameters_hint1.cpp", { 6, 8 });
|
||||
if (!result.has_value())
|
||||
FAIL("failed to get parameters hint (3)");
|
||||
if (result->params != Vector<DeprecatedString> { "int x", "char y" } || result->current_index != 0)
|
||||
if (result->params != Vector<ByteString> { "int x", "char y" } || result->current_index != 0)
|
||||
FAIL("bad result (3)");
|
||||
|
||||
PASS;
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
|
||||
namespace CodeComprehension {
|
||||
|
||||
DeprecatedString FileDB::to_absolute_path(StringView filename) const
|
||||
ByteString FileDB::to_absolute_path(StringView filename) const
|
||||
{
|
||||
if (LexicalPath { filename }.is_absolute()) {
|
||||
return filename;
|
||||
}
|
||||
if (!m_project_root.has_value())
|
||||
return filename;
|
||||
return LexicalPath { DeprecatedString::formatted("{}/{}", *m_project_root, filename) }.string();
|
||||
return LexicalPath { ByteString::formatted("{}/{}", *m_project_root, filename) }.string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
namespace CodeComprehension {
|
||||
|
@ -18,7 +18,7 @@ class FileDB {
|
|||
public:
|
||||
virtual ~FileDB() = default;
|
||||
|
||||
virtual Optional<DeprecatedString> get_or_read_from_filesystem(StringView filename) const = 0;
|
||||
virtual Optional<ByteString> get_or_read_from_filesystem(StringView filename) const = 0;
|
||||
void set_project_root(StringView project_root)
|
||||
{
|
||||
if (project_root.is_null())
|
||||
|
@ -26,14 +26,14 @@ public:
|
|||
else
|
||||
m_project_root = project_root;
|
||||
}
|
||||
Optional<DeprecatedString> const& project_root() const { return m_project_root; }
|
||||
DeprecatedString to_absolute_path(StringView filename) const;
|
||||
Optional<ByteString> const& project_root() const { return m_project_root; }
|
||||
ByteString to_absolute_path(StringView filename) const;
|
||||
|
||||
protected:
|
||||
FileDB() = default;
|
||||
|
||||
private:
|
||||
Optional<DeprecatedString> m_project_root;
|
||||
Optional<ByteString> m_project_root;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ private:
|
|||
: LanguageServers::ConnectionFromClient(move(socket))
|
||||
{
|
||||
m_autocomplete_engine = make<CodeComprehension::Shell::ShellComprehensionEngine>(m_filedb);
|
||||
m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
|
||||
m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
|
||||
async_declarations_in_document(filename, move(declarations));
|
||||
};
|
||||
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
|
||||
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
|
||||
async_todo_entries_in_document(filename, move(todo_entries));
|
||||
};
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ ShellComprehensionEngine::ShellComprehensionEngine(FileDB const& filedb)
|
|||
{
|
||||
}
|
||||
|
||||
ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_create_document_data(DeprecatedString const& file)
|
||||
ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_create_document_data(ByteString const& file)
|
||||
{
|
||||
auto absolute_path = filedb().to_absolute_path(file);
|
||||
if (!m_documents.contains(absolute_path)) {
|
||||
|
@ -27,7 +27,7 @@ ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_c
|
|||
return get_document_data(absolute_path);
|
||||
}
|
||||
|
||||
ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_document_data(DeprecatedString const& file) const
|
||||
ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_document_data(ByteString const& file) const
|
||||
{
|
||||
auto absolute_path = filedb().to_absolute_path(file);
|
||||
auto document_data = m_documents.get(absolute_path);
|
||||
|
@ -35,7 +35,7 @@ ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_docu
|
|||
return *document_data.value();
|
||||
}
|
||||
|
||||
OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_document_data_for(DeprecatedString const& file)
|
||||
OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_document_data_for(ByteString const& file)
|
||||
{
|
||||
auto document = filedb().get_or_read_from_filesystem(file);
|
||||
if (!document.has_value())
|
||||
|
@ -50,19 +50,19 @@ OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_
|
|||
return document_data;
|
||||
}
|
||||
|
||||
void ShellComprehensionEngine::set_document_data(DeprecatedString const& file, OwnPtr<DocumentData>&& data)
|
||||
void ShellComprehensionEngine::set_document_data(ByteString const& file, OwnPtr<DocumentData>&& data)
|
||||
{
|
||||
m_documents.set(filedb().to_absolute_path(file), move(data));
|
||||
}
|
||||
|
||||
ShellComprehensionEngine::DocumentData::DocumentData(DeprecatedString&& _text, DeprecatedString _filename)
|
||||
ShellComprehensionEngine::DocumentData::DocumentData(ByteString&& _text, ByteString _filename)
|
||||
: filename(move(_filename))
|
||||
, text(move(_text))
|
||||
, node(parse())
|
||||
{
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> const& ShellComprehensionEngine::DocumentData::sourced_paths() const
|
||||
Vector<ByteString> const& ShellComprehensionEngine::DocumentData::sourced_paths() const
|
||||
{
|
||||
if (all_sourced_paths.has_value())
|
||||
return all_sourced_paths.value();
|
||||
|
@ -82,19 +82,19 @@ Vector<DeprecatedString> const& ShellComprehensionEngine::DocumentData::sourced_
|
|||
auto name_list = name_list_node->resolve_as_list(nullptr).release_value_but_fixme_should_propagate_errors();
|
||||
StringBuilder builder;
|
||||
builder.join(' ', name_list);
|
||||
sourced_files.set(builder.to_deprecated_string());
|
||||
sourced_files.set(builder.to_byte_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
::Shell::AST::NodeVisitor::visit(node);
|
||||
}
|
||||
|
||||
HashTable<DeprecatedString> sourced_files;
|
||||
HashTable<ByteString> sourced_files;
|
||||
} visitor;
|
||||
|
||||
node->visit(visitor);
|
||||
|
||||
Vector<DeprecatedString> sourced_paths;
|
||||
Vector<ByteString> sourced_paths;
|
||||
for (auto& entry : visitor.sourced_files)
|
||||
sourced_paths.append(move(entry));
|
||||
|
||||
|
@ -134,7 +134,7 @@ size_t ShellComprehensionEngine::resolve(ShellComprehensionEngine::DocumentData
|
|||
return offset;
|
||||
}
|
||||
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> ShellComprehensionEngine::get_suggestions(DeprecatedString const& file, const GUI::TextPosition& position)
|
||||
Vector<CodeComprehension::AutocompleteResultEntry> ShellComprehensionEngine::get_suggestions(ByteString const& file, const GUI::TextPosition& position)
|
||||
{
|
||||
dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "ShellComprehensionEngine position {}:{}", position.line(), position.column());
|
||||
|
||||
|
@ -155,17 +155,17 @@ Vector<CodeComprehension::AutocompleteResultEntry> ShellComprehensionEngine::get
|
|||
return entries;
|
||||
}
|
||||
|
||||
void ShellComprehensionEngine::on_edit(DeprecatedString const& file)
|
||||
void ShellComprehensionEngine::on_edit(ByteString const& file)
|
||||
{
|
||||
set_document_data(file, create_document_data_for(file));
|
||||
}
|
||||
|
||||
void ShellComprehensionEngine::file_opened([[maybe_unused]] DeprecatedString const& file)
|
||||
void ShellComprehensionEngine::file_opened([[maybe_unused]] ByteString const& file)
|
||||
{
|
||||
set_document_data(file, create_document_data_for(file));
|
||||
}
|
||||
|
||||
Optional<CodeComprehension::ProjectLocation> ShellComprehensionEngine::find_declaration_of(DeprecatedString const& filename, const GUI::TextPosition& identifier_position)
|
||||
Optional<CodeComprehension::ProjectLocation> ShellComprehensionEngine::find_declaration_of(ByteString const& filename, const GUI::TextPosition& identifier_position)
|
||||
{
|
||||
dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "find_declaration_of({}, {}:{})", filename, identifier_position.line(), identifier_position.column());
|
||||
auto const& document = get_or_create_document_data(filename);
|
||||
|
@ -196,7 +196,7 @@ Optional<CodeComprehension::ProjectLocation> ShellComprehensionEngine::find_decl
|
|||
void ShellComprehensionEngine::update_declared_symbols(DocumentData const& document)
|
||||
{
|
||||
struct Visitor : public ::Shell::AST::NodeVisitor {
|
||||
explicit Visitor(DeprecatedString const& filename)
|
||||
explicit Visitor(ByteString const& filename)
|
||||
: filename(filename)
|
||||
{
|
||||
}
|
||||
|
@ -208,9 +208,9 @@ void ShellComprehensionEngine::update_declared_symbols(DocumentData const& docum
|
|||
if (!literal)
|
||||
continue;
|
||||
|
||||
DeprecatedString name;
|
||||
ByteString name;
|
||||
if (literal->is_bareword())
|
||||
name = static_ptr_cast<::Shell::AST::BarewordLiteral const>(literal)->text().to_deprecated_string();
|
||||
name = static_ptr_cast<::Shell::AST::BarewordLiteral const>(literal)->text().to_byte_string();
|
||||
|
||||
if (!name.is_empty()) {
|
||||
dbgln("Found variable {}", name);
|
||||
|
@ -223,10 +223,10 @@ void ShellComprehensionEngine::update_declared_symbols(DocumentData const& docum
|
|||
void visit(::Shell::AST::FunctionDeclaration const* node) override
|
||||
{
|
||||
dbgln("Found function {}", node->name().name);
|
||||
declarations.append({ node->name().name.to_deprecated_string(), { filename, node->position().start_line.line_number, node->position().start_line.line_column }, CodeComprehension::DeclarationType::Function, {} });
|
||||
declarations.append({ node->name().name.to_byte_string(), { filename, node->position().start_line.line_number, node->position().start_line.line_column }, CodeComprehension::DeclarationType::Function, {} });
|
||||
}
|
||||
|
||||
DeprecatedString const& filename;
|
||||
ByteString const& filename;
|
||||
Vector<CodeComprehension::Declaration> declarations;
|
||||
} visitor { document.filename };
|
||||
|
||||
|
|
|
@ -14,31 +14,31 @@ namespace CodeComprehension::Shell {
|
|||
class ShellComprehensionEngine : public CodeComprehensionEngine {
|
||||
public:
|
||||
ShellComprehensionEngine(FileDB const& filedb);
|
||||
virtual Vector<CodeComprehension::AutocompleteResultEntry> get_suggestions(DeprecatedString const& file, const GUI::TextPosition& position) override;
|
||||
virtual void on_edit(DeprecatedString const& file) override;
|
||||
virtual void file_opened([[maybe_unused]] DeprecatedString const& file) override;
|
||||
virtual Optional<CodeComprehension::ProjectLocation> find_declaration_of(DeprecatedString const& filename, const GUI::TextPosition& identifier_position) override;
|
||||
virtual Vector<CodeComprehension::AutocompleteResultEntry> get_suggestions(ByteString const& file, const GUI::TextPosition& position) override;
|
||||
virtual void on_edit(ByteString const& file) override;
|
||||
virtual void file_opened([[maybe_unused]] ByteString const& file) override;
|
||||
virtual Optional<CodeComprehension::ProjectLocation> find_declaration_of(ByteString const& filename, const GUI::TextPosition& identifier_position) override;
|
||||
|
||||
private:
|
||||
struct DocumentData {
|
||||
DocumentData(DeprecatedString&& text, DeprecatedString filename);
|
||||
DeprecatedString filename;
|
||||
DeprecatedString text;
|
||||
DocumentData(ByteString&& text, ByteString filename);
|
||||
ByteString filename;
|
||||
ByteString text;
|
||||
NonnullRefPtr<::Shell::AST::Node> node;
|
||||
|
||||
Vector<DeprecatedString> const& sourced_paths() const;
|
||||
Vector<ByteString> const& sourced_paths() const;
|
||||
|
||||
private:
|
||||
NonnullRefPtr<::Shell::AST::Node> parse() const;
|
||||
|
||||
mutable Optional<Vector<DeprecatedString>> all_sourced_paths {};
|
||||
mutable Optional<Vector<ByteString>> all_sourced_paths {};
|
||||
};
|
||||
|
||||
DocumentData const& get_document_data(DeprecatedString const& file) const;
|
||||
DocumentData const& get_or_create_document_data(DeprecatedString const& file);
|
||||
void set_document_data(DeprecatedString const& file, OwnPtr<DocumentData>&& data);
|
||||
DocumentData const& get_document_data(ByteString const& file) const;
|
||||
DocumentData const& get_or_create_document_data(ByteString const& file);
|
||||
void set_document_data(ByteString const& file, OwnPtr<DocumentData>&& data);
|
||||
|
||||
OwnPtr<DocumentData> create_document_data_for(DeprecatedString const& file);
|
||||
OwnPtr<DocumentData> create_document_data_for(ByteString const& file);
|
||||
void update_declared_symbols(DocumentData const&);
|
||||
|
||||
static size_t resolve(ShellComprehensionEngine::DocumentData const& document, const GUI::TextPosition& position);
|
||||
|
@ -51,7 +51,7 @@ private:
|
|||
return *s_shell;
|
||||
}
|
||||
|
||||
HashMap<DeprecatedString, OwnPtr<DocumentData>> m_documents;
|
||||
HashMap<ByteString, OwnPtr<DocumentData>> m_documents;
|
||||
static RefPtr<::Shell::Shell> s_shell;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
|
||||
namespace CodeComprehension {
|
||||
|
||||
|
@ -16,11 +16,11 @@ enum class Language {
|
|||
};
|
||||
|
||||
struct AutocompleteResultEntry {
|
||||
DeprecatedString completion;
|
||||
ByteString completion;
|
||||
size_t partial_input_length { 0 };
|
||||
// TODO: Actually assign the value of this field in more places (when applicable).
|
||||
Language language { Language::Unspecified };
|
||||
DeprecatedString display_text {};
|
||||
ByteString display_text {};
|
||||
|
||||
enum class HideAutocompleteAfterApplying {
|
||||
No,
|
||||
|
@ -30,7 +30,7 @@ struct AutocompleteResultEntry {
|
|||
};
|
||||
|
||||
struct ProjectLocation {
|
||||
DeprecatedString file;
|
||||
ByteString file;
|
||||
size_t line { 0 };
|
||||
size_t column { 0 };
|
||||
|
||||
|
@ -51,10 +51,10 @@ enum class DeclarationType {
|
|||
};
|
||||
|
||||
struct Declaration {
|
||||
DeprecatedString name;
|
||||
ByteString name;
|
||||
ProjectLocation position;
|
||||
DeclarationType type;
|
||||
DeprecatedString scope;
|
||||
ByteString scope;
|
||||
|
||||
bool operator==(Declaration const& other) const
|
||||
{
|
||||
|
@ -109,8 +109,8 @@ struct TokenInfo {
|
|||
};
|
||||
|
||||
struct TodoEntry {
|
||||
DeprecatedString content;
|
||||
DeprecatedString filename;
|
||||
ByteString content;
|
||||
ByteString filename;
|
||||
size_t line { 0 };
|
||||
size_t column { 0 };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue