mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
LibGUI: Add AutocompleteProvider::TokenInfo::type_to_string()
This commit is contained in:
parent
3ab7388754
commit
53c6c36fba
2 changed files with 38 additions and 17 deletions
|
@ -940,6 +940,7 @@ Vector<GUI::AutocompleteProvider::TokenInfo> CppComprehensionEngine::get_tokens_
|
|||
tokens_info.append({ get_token_semantic_type(document, token),
|
||||
token.start().line, token.start().column, token.end().line, token.end().column });
|
||||
++i;
|
||||
dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "{}: {}", token.text(), GUI::AutocompleteProvider::TokenInfo::type_to_string(tokens_info.last().type));
|
||||
}
|
||||
return tokens_info;
|
||||
}
|
||||
|
|
|
@ -69,30 +69,50 @@ public:
|
|||
|
||||
virtual void provide_completions(Function<void(Vector<Entry>)>) = 0;
|
||||
|
||||
#define FOR_EACH_SEMANTIC_TYPE \
|
||||
__SEMANTIC(Unknown) \
|
||||
__SEMANTIC(Regular) \
|
||||
__SEMANTIC(Keyword) \
|
||||
__SEMANTIC(Type) \
|
||||
__SEMANTIC(Identifier) \
|
||||
__SEMANTIC(String) \
|
||||
__SEMANTIC(Number) \
|
||||
__SEMANTIC(IncludePath) \
|
||||
__SEMANTIC(PreprocessorStatement) \
|
||||
__SEMANTIC(Comment) \
|
||||
__SEMANTIC(Whitespace) \
|
||||
__SEMANTIC(Function) \
|
||||
__SEMANTIC(Variable) \
|
||||
__SEMANTIC(CustomType) \
|
||||
__SEMANTIC(Namespace) \
|
||||
__SEMANTIC(Member) \
|
||||
__SEMANTIC(Parameter) \
|
||||
__SEMANTIC(PreprocessorMacro)
|
||||
|
||||
struct TokenInfo {
|
||||
|
||||
enum class SemanticType : u32 {
|
||||
Unknown,
|
||||
Regular,
|
||||
Keyword,
|
||||
Type,
|
||||
Identifier,
|
||||
String,
|
||||
Number,
|
||||
IncludePath,
|
||||
PreprocessorStatement,
|
||||
Comment,
|
||||
Whitespace,
|
||||
Function,
|
||||
Variable,
|
||||
CustomType,
|
||||
Namespace,
|
||||
Member,
|
||||
Parameter,
|
||||
#define __SEMANTIC(x) x,
|
||||
FOR_EACH_SEMANTIC_TYPE
|
||||
#undef __SEMANTIC
|
||||
|
||||
} type { SemanticType::Unknown };
|
||||
size_t start_line { 0 };
|
||||
size_t start_column { 0 };
|
||||
size_t end_line { 0 };
|
||||
size_t end_column { 0 };
|
||||
|
||||
static constexpr const char* type_to_string(SemanticType t)
|
||||
{
|
||||
switch (t) {
|
||||
#define __SEMANTIC(x) \
|
||||
case SemanticType::x: \
|
||||
return #x;
|
||||
FOR_EACH_SEMANTIC_TYPE
|
||||
#undef __SEMANTIC
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
};
|
||||
};
|
||||
|
||||
void attach(TextEditor& editor)
|
||||
|
|
Loading…
Add table
Reference in a new issue