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

LibGUI: Remove GUI::AutocompleteProvider::Entry::kind

The only code using it was removed in the previous commit.
This commit is contained in:
thislooksfun 2021-10-26 21:53:49 -05:00 committed by Andreas Kling
parent f699dbdc3f
commit f7f9d09e72
4 changed files with 11 additions and 23 deletions

View file

@ -20,7 +20,6 @@ inline bool encode(IPC::Encoder& encoder, const GUI::AutocompleteProvider::Entry
{
encoder << response.completion;
encoder << (u64)response.partial_input_length;
encoder << (u32)response.kind;
encoder << (u32)response.language;
encoder << response.display_text;
return true;
@ -29,17 +28,14 @@ inline bool encode(IPC::Encoder& encoder, const GUI::AutocompleteProvider::Entry
template<>
inline bool decode(IPC::Decoder& decoder, GUI::AutocompleteProvider::Entry& response)
{
u32 kind = 0;
u32 language = 0;
u64 partial_input_length = 0;
bool ok = decoder.decode(response.completion)
&& decoder.decode(partial_input_length)
&& decoder.decode(kind)
&& decoder.decode(language)
&& decoder.decode(response.display_text);
if (ok) {
response.kind = static_cast<GUI::AutocompleteProvider::CompletionKind>(kind);
response.language = static_cast<GUI::AutocompleteProvider::Language>(language);
response.partial_input_length = partial_input_length;
}

View file

@ -165,13 +165,13 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_na
Vector<GUI::AutocompleteProvider::Entry> suggestions;
for (auto& symbol : matches) {
suggestions.append({ symbol.name.name, partial_text.length(), GUI::AutocompleteProvider::CompletionKind::Identifier });
suggestions.append({ symbol.name.name, partial_text.length() });
}
if (reference_scope.is_empty()) {
for (auto& preprocessor_name : document.preprocessor().definitions().keys()) {
if (preprocessor_name.starts_with(partial_text)) {
suggestions.append({ preprocessor_name, partial_text.length(), GUI::AutocompleteProvider::CompletionKind::PreprocessorDefinition });
suggestions.append({ preprocessor_name, partial_text.length() });
}
}
}
@ -215,7 +215,7 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_pr
Vector<GUI::AutocompleteProvider::Entry> suggestions;
for (auto& prop : properties_of_type(document, type)) {
if (prop.name.name.starts_with(partial_text)) {
suggestions.append({ prop.name.name, partial_text.length(), GUI::AutocompleteProvider::CompletionKind::Identifier });
suggestions.append({ prop.name.name, partial_text.length() });
}
}
return suggestions;
@ -642,11 +642,15 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a
VERIFY(include_path_token.type() == Token::Type::IncludePath);
auto partial_include = include_path_token.text().trim_whitespace();
enum IncludeType {
Project,
System,
} include_type { Project };
String include_root;
auto include_type = GUI::AutocompleteProvider::CompletionKind::ProjectInclude;
if (partial_include.starts_with("<")) {
include_root = "/usr/include/";
include_type = GUI::AutocompleteProvider::CompletionKind::SystemInclude;
include_type = System;
} else if (partial_include.starts_with("\"")) {
include_root = filedb().project_root();
} else
@ -670,8 +674,8 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a
if (!(path.ends_with(".h") || Core::File::is_directory(LexicalPath::join(full_dir, path).string())))
continue;
if (path.starts_with(partial_basename)) {
auto completion = include_type == GUI::AutocompleteProvider::CompletionKind::ProjectInclude ? String::formatted("<{}>", path) : String::formatted("\"{}\"", path);
options.append({ completion, partial_basename.length() + 1, include_type, GUI::AutocompleteProvider::Language::Cpp, path });
auto completion = include_type == System ? String::formatted("<{}>", path) : String::formatted("\"{}\"", path);
options.append({ completion, partial_basename.length() + 1, GUI::AutocompleteProvider::Language::Cpp, path });
}
}

View file

@ -32,7 +32,6 @@ public:
enum InternalRole {
__ModelRoleCustom = (int)GUI::ModelRole::Custom,
PartialInputLength,
Kind,
Completion,
};
@ -65,9 +64,6 @@ public:
}
}
if ((int)role == InternalRole::Kind)
return (u32)suggestion.kind;
if ((int)role == InternalRole::PartialInputLength)
return (i64)suggestion.partial_input_length;

View file

@ -20,13 +20,6 @@ class AutocompleteProvider {
public:
virtual ~AutocompleteProvider() { }
enum class CompletionKind {
Identifier,
PreprocessorDefinition,
SystemInclude,
ProjectInclude,
};
enum class Language {
Unspecified,
Cpp,
@ -35,7 +28,6 @@ public:
struct Entry {
String completion;
size_t partial_input_length { 0 };
CompletionKind kind { CompletionKind::Identifier };
Language language { Language::Unspecified };
String display_text {};
};