mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:32:46 +00: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), |         tokens_info.append({ get_token_semantic_type(document, token), | ||||||
|             token.start().line, token.start().column, token.end().line, token.end().column }); |             token.start().line, token.start().column, token.end().line, token.end().column }); | ||||||
|         ++i; |         ++i; | ||||||
|  |         dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "{}: {}", token.text(), GUI::AutocompleteProvider::TokenInfo::type_to_string(tokens_info.last().type)); | ||||||
|     } |     } | ||||||
|     return tokens_info; |     return tokens_info; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -69,30 +69,50 @@ public: | ||||||
| 
 | 
 | ||||||
|     virtual void provide_completions(Function<void(Vector<Entry>)>) = 0; |     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 { |     struct TokenInfo { | ||||||
|  | 
 | ||||||
|         enum class SemanticType : u32 { |         enum class SemanticType : u32 { | ||||||
|             Unknown, | #define __SEMANTIC(x) x, | ||||||
|             Regular, |             FOR_EACH_SEMANTIC_TYPE | ||||||
|             Keyword, | #undef __SEMANTIC | ||||||
|             Type, | 
 | ||||||
|             Identifier, |  | ||||||
|             String, |  | ||||||
|             Number, |  | ||||||
|             IncludePath, |  | ||||||
|             PreprocessorStatement, |  | ||||||
|             Comment, |  | ||||||
|             Whitespace, |  | ||||||
|             Function, |  | ||||||
|             Variable, |  | ||||||
|             CustomType, |  | ||||||
|             Namespace, |  | ||||||
|             Member, |  | ||||||
|             Parameter, |  | ||||||
|         } type { SemanticType::Unknown }; |         } type { SemanticType::Unknown }; | ||||||
|         size_t start_line { 0 }; |         size_t start_line { 0 }; | ||||||
|         size_t start_column { 0 }; |         size_t start_column { 0 }; | ||||||
|         size_t end_line { 0 }; |         size_t end_line { 0 }; | ||||||
|         size_t end_column { 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) |     void attach(TextEditor& editor) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Itamar
						Itamar