mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
LibGUI: Remove GUI::AutocompleteProvider::Entry::kind
The only code using it was removed in the previous commit.
This commit is contained in:
parent
f699dbdc3f
commit
f7f9d09e72
4 changed files with 11 additions and 23 deletions
|
@ -20,7 +20,6 @@ inline bool encode(IPC::Encoder& encoder, const GUI::AutocompleteProvider::Entry
|
||||||
{
|
{
|
||||||
encoder << response.completion;
|
encoder << response.completion;
|
||||||
encoder << (u64)response.partial_input_length;
|
encoder << (u64)response.partial_input_length;
|
||||||
encoder << (u32)response.kind;
|
|
||||||
encoder << (u32)response.language;
|
encoder << (u32)response.language;
|
||||||
encoder << response.display_text;
|
encoder << response.display_text;
|
||||||
return true;
|
return true;
|
||||||
|
@ -29,17 +28,14 @@ inline bool encode(IPC::Encoder& encoder, const GUI::AutocompleteProvider::Entry
|
||||||
template<>
|
template<>
|
||||||
inline bool decode(IPC::Decoder& decoder, GUI::AutocompleteProvider::Entry& response)
|
inline bool decode(IPC::Decoder& decoder, GUI::AutocompleteProvider::Entry& response)
|
||||||
{
|
{
|
||||||
u32 kind = 0;
|
|
||||||
u32 language = 0;
|
u32 language = 0;
|
||||||
u64 partial_input_length = 0;
|
u64 partial_input_length = 0;
|
||||||
bool ok = decoder.decode(response.completion)
|
bool ok = decoder.decode(response.completion)
|
||||||
&& decoder.decode(partial_input_length)
|
&& decoder.decode(partial_input_length)
|
||||||
&& decoder.decode(kind)
|
|
||||||
&& decoder.decode(language)
|
&& decoder.decode(language)
|
||||||
&& decoder.decode(response.display_text);
|
&& decoder.decode(response.display_text);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
response.kind = static_cast<GUI::AutocompleteProvider::CompletionKind>(kind);
|
|
||||||
response.language = static_cast<GUI::AutocompleteProvider::Language>(language);
|
response.language = static_cast<GUI::AutocompleteProvider::Language>(language);
|
||||||
response.partial_input_length = partial_input_length;
|
response.partial_input_length = partial_input_length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,13 +165,13 @@ Vector<GUI::AutocompleteProvider::Entry> CppComprehensionEngine::autocomplete_na
|
||||||
|
|
||||||
Vector<GUI::AutocompleteProvider::Entry> suggestions;
|
Vector<GUI::AutocompleteProvider::Entry> suggestions;
|
||||||
for (auto& symbol : matches) {
|
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()) {
|
if (reference_scope.is_empty()) {
|
||||||
for (auto& preprocessor_name : document.preprocessor().definitions().keys()) {
|
for (auto& preprocessor_name : document.preprocessor().definitions().keys()) {
|
||||||
if (preprocessor_name.starts_with(partial_text)) {
|
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;
|
Vector<GUI::AutocompleteProvider::Entry> suggestions;
|
||||||
for (auto& prop : properties_of_type(document, type)) {
|
for (auto& prop : properties_of_type(document, type)) {
|
||||||
if (prop.name.name.starts_with(partial_text)) {
|
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;
|
return suggestions;
|
||||||
|
@ -642,11 +642,15 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a
|
||||||
VERIFY(include_path_token.type() == Token::Type::IncludePath);
|
VERIFY(include_path_token.type() == Token::Type::IncludePath);
|
||||||
auto partial_include = include_path_token.text().trim_whitespace();
|
auto partial_include = include_path_token.text().trim_whitespace();
|
||||||
|
|
||||||
|
enum IncludeType {
|
||||||
|
Project,
|
||||||
|
System,
|
||||||
|
} include_type { Project };
|
||||||
|
|
||||||
String include_root;
|
String include_root;
|
||||||
auto include_type = GUI::AutocompleteProvider::CompletionKind::ProjectInclude;
|
|
||||||
if (partial_include.starts_with("<")) {
|
if (partial_include.starts_with("<")) {
|
||||||
include_root = "/usr/include/";
|
include_root = "/usr/include/";
|
||||||
include_type = GUI::AutocompleteProvider::CompletionKind::SystemInclude;
|
include_type = System;
|
||||||
} else if (partial_include.starts_with("\"")) {
|
} else if (partial_include.starts_with("\"")) {
|
||||||
include_root = filedb().project_root();
|
include_root = filedb().project_root();
|
||||||
} else
|
} 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())))
|
if (!(path.ends_with(".h") || Core::File::is_directory(LexicalPath::join(full_dir, path).string())))
|
||||||
continue;
|
continue;
|
||||||
if (path.starts_with(partial_basename)) {
|
if (path.starts_with(partial_basename)) {
|
||||||
auto completion = include_type == GUI::AutocompleteProvider::CompletionKind::ProjectInclude ? String::formatted("<{}>", path) : String::formatted("\"{}\"", path);
|
auto completion = include_type == System ? String::formatted("<{}>", path) : String::formatted("\"{}\"", path);
|
||||||
options.append({ completion, partial_basename.length() + 1, include_type, GUI::AutocompleteProvider::Language::Cpp, path });
|
options.append({ completion, partial_basename.length() + 1, GUI::AutocompleteProvider::Language::Cpp, path });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ public:
|
||||||
enum InternalRole {
|
enum InternalRole {
|
||||||
__ModelRoleCustom = (int)GUI::ModelRole::Custom,
|
__ModelRoleCustom = (int)GUI::ModelRole::Custom,
|
||||||
PartialInputLength,
|
PartialInputLength,
|
||||||
Kind,
|
|
||||||
Completion,
|
Completion,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -65,9 +64,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int)role == InternalRole::Kind)
|
|
||||||
return (u32)suggestion.kind;
|
|
||||||
|
|
||||||
if ((int)role == InternalRole::PartialInputLength)
|
if ((int)role == InternalRole::PartialInputLength)
|
||||||
return (i64)suggestion.partial_input_length;
|
return (i64)suggestion.partial_input_length;
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,6 @@ class AutocompleteProvider {
|
||||||
public:
|
public:
|
||||||
virtual ~AutocompleteProvider() { }
|
virtual ~AutocompleteProvider() { }
|
||||||
|
|
||||||
enum class CompletionKind {
|
|
||||||
Identifier,
|
|
||||||
PreprocessorDefinition,
|
|
||||||
SystemInclude,
|
|
||||||
ProjectInclude,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class Language {
|
enum class Language {
|
||||||
Unspecified,
|
Unspecified,
|
||||||
Cpp,
|
Cpp,
|
||||||
|
@ -35,7 +28,6 @@ public:
|
||||||
struct Entry {
|
struct Entry {
|
||||||
String completion;
|
String completion;
|
||||||
size_t partial_input_length { 0 };
|
size_t partial_input_length { 0 };
|
||||||
CompletionKind kind { CompletionKind::Identifier };
|
|
||||||
Language language { Language::Unspecified };
|
Language language { Language::Unspecified };
|
||||||
String display_text {};
|
String display_text {};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue