mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +00:00 
			
		
		
		
	Strongly typed semantic highlighting kind
This commit is contained in:
		
							parent
							
								
									5ff7d165f9
								
							
						
					
					
						commit
						67834ca783
					
				
							
								
								
									
										46
									
								
								src/clang_symbol_kind.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								src/clang_symbol_kind.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "serializer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO Rename query.h:SymbolKind to another name
 | 
				
			||||||
 | 
					// clang/Index/IndexSymbol.h clang::index::SymbolKind
 | 
				
			||||||
 | 
					enum class ClangSymbolKind : uint8_t {
 | 
				
			||||||
 | 
					  Unknown,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Module = 1,
 | 
				
			||||||
 | 
					  Namespace,
 | 
				
			||||||
 | 
					  NamespaceAlias,
 | 
				
			||||||
 | 
					  Macro,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Enum = 5,
 | 
				
			||||||
 | 
					  Struct,
 | 
				
			||||||
 | 
					  Class,
 | 
				
			||||||
 | 
					  Protocol,
 | 
				
			||||||
 | 
					  Extension,
 | 
				
			||||||
 | 
					  Union,
 | 
				
			||||||
 | 
					  TypeAlias,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Function = 12,
 | 
				
			||||||
 | 
					  Variable,
 | 
				
			||||||
 | 
					  Field,
 | 
				
			||||||
 | 
					  EnumConstant,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  InstanceMethod = 16,
 | 
				
			||||||
 | 
					  ClassMethod,
 | 
				
			||||||
 | 
					  StaticMethod,
 | 
				
			||||||
 | 
					  InstanceProperty,
 | 
				
			||||||
 | 
					  ClassProperty,
 | 
				
			||||||
 | 
					  StaticProperty,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Constructor = 22,
 | 
				
			||||||
 | 
					  Destructor,
 | 
				
			||||||
 | 
					  ConversionFunction,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Parameter = 25,
 | 
				
			||||||
 | 
					  Using,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					MAKE_REFLECT_TYPE_PROXY(ClangSymbolKind,
 | 
				
			||||||
 | 
					                        std::underlying_type<ClangSymbolKind>::type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2,6 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "clang_cursor.h"
 | 
					#include "clang_cursor.h"
 | 
				
			||||||
#include "clang_index.h"
 | 
					#include "clang_index.h"
 | 
				
			||||||
 | 
					#include "clang_symbol_kind.h"
 | 
				
			||||||
#include "clang_translation_unit.h"
 | 
					#include "clang_translation_unit.h"
 | 
				
			||||||
#include "clang_utils.h"
 | 
					#include "clang_utils.h"
 | 
				
			||||||
#include "file_consumer.h"
 | 
					#include "file_consumer.h"
 | 
				
			||||||
@ -77,46 +78,6 @@ using IndexVarId = Id<IndexVar>;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
struct IdCache;
 | 
					struct IdCache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO Rename query.h:SymbolKind to another name
 | 
					 | 
				
			||||||
// clang/Index/IndexSymbol.h clang::index::SymbolKind
 | 
					 | 
				
			||||||
enum class ClangSymbolKind : uint8_t {
 | 
					 | 
				
			||||||
  Unknown,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Module = 1,
 | 
					 | 
				
			||||||
  Namespace,
 | 
					 | 
				
			||||||
  NamespaceAlias,
 | 
					 | 
				
			||||||
  Macro,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Enum = 5,
 | 
					 | 
				
			||||||
  Struct,
 | 
					 | 
				
			||||||
  Class,
 | 
					 | 
				
			||||||
  Protocol,
 | 
					 | 
				
			||||||
  Extension,
 | 
					 | 
				
			||||||
  Union,
 | 
					 | 
				
			||||||
  TypeAlias,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Function = 12,
 | 
					 | 
				
			||||||
  Variable,
 | 
					 | 
				
			||||||
  Field,
 | 
					 | 
				
			||||||
  EnumConstant,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  InstanceMethod = 16,
 | 
					 | 
				
			||||||
  ClassMethod,
 | 
					 | 
				
			||||||
  StaticMethod,
 | 
					 | 
				
			||||||
  InstanceProperty,
 | 
					 | 
				
			||||||
  ClassProperty,
 | 
					 | 
				
			||||||
  StaticProperty,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Constructor = 22,
 | 
					 | 
				
			||||||
  Destructor,
 | 
					 | 
				
			||||||
  ConversionFunction,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Parameter = 25,
 | 
					 | 
				
			||||||
  Using,
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
MAKE_REFLECT_TYPE_PROXY(ClangSymbolKind,
 | 
					 | 
				
			||||||
                        std::underlying_type<ClangSymbolKind>::type);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct IndexFuncRef {
 | 
					struct IndexFuncRef {
 | 
				
			||||||
  // NOTE: id can be -1 if the function call is not coming from a function.
 | 
					  // NOTE: id can be -1 if the function call is not coming from a function.
 | 
				
			||||||
  IndexFuncId id;
 | 
					  IndexFuncId id;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "clang_symbol_kind.h"
 | 
				
			||||||
#include "config.h"
 | 
					#include "config.h"
 | 
				
			||||||
#include "ipc.h"
 | 
					#include "ipc.h"
 | 
				
			||||||
#include "serializer.h"
 | 
					#include "serializer.h"
 | 
				
			||||||
@ -1086,7 +1087,7 @@ struct Out_CqueryPublishSemanticHighlighting
 | 
				
			|||||||
    int stableId = 0;
 | 
					    int stableId = 0;
 | 
				
			||||||
    // TODO Deprecate |type| in favor of fine-grained |kind|.
 | 
					    // TODO Deprecate |type| in favor of fine-grained |kind|.
 | 
				
			||||||
    SymbolType type = SymbolType::Type;
 | 
					    SymbolType type = SymbolType::Type;
 | 
				
			||||||
    int kind;
 | 
					    ClangSymbolKind kind;
 | 
				
			||||||
    bool isTypeMember = false;
 | 
					    bool isTypeMember = false;
 | 
				
			||||||
    std::vector<lsRange> ranges;
 | 
					    std::vector<lsRange> ranges;
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
				
			|||||||
@ -187,7 +187,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
 | 
				
			|||||||
        Out_CqueryPublishSemanticHighlighting::Symbol symbol;
 | 
					        Out_CqueryPublishSemanticHighlighting::Symbol symbol;
 | 
				
			||||||
        symbol.stableId =
 | 
					        symbol.stableId =
 | 
				
			||||||
            semantic_cache_for_file->GetStableId(sym.idx.kind, detailed_name);
 | 
					            semantic_cache_for_file->GetStableId(sym.idx.kind, detailed_name);
 | 
				
			||||||
        symbol.kind = static_cast<int>(kind);
 | 
					        symbol.kind = kind;
 | 
				
			||||||
        symbol.type = map_symbol_kind_to_symbol_type(sym.idx.kind);
 | 
					        symbol.type = map_symbol_kind_to_symbol_type(sym.idx.kind);
 | 
				
			||||||
        symbol.isTypeMember = is_type_member;
 | 
					        symbol.isTypeMember = is_type_member;
 | 
				
			||||||
        symbol.ranges.push_back(*loc);
 | 
					        symbol.ranges.push_back(*loc);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user