mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-03 22:04:24 +00:00 
			
		
		
		
	Reflect string_view and fix workspace/symbol
This commit is contained in:
		
							parent
							
								
									0d715e7bcf
								
							
						
					
					
						commit
						642975ea17
					
				@ -124,8 +124,8 @@ gap_penalty(k+1, j) + score[j] : k < j))
 | 
				
			|||||||
The first dimension can be suppressed since we do not need a matching scheme,
 | 
					The first dimension can be suppressed since we do not need a matching scheme,
 | 
				
			||||||
which reduces the space complexity from O(N*M) to O(M)
 | 
					which reduces the space complexity from O(N*M) to O(M)
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
int FuzzyEvaluate(std::string_view pattern,
 | 
					int FuzzyEvaluate(const std::string& pattern,
 | 
				
			||||||
                  std::string_view str,
 | 
					                  const std::string& str,
 | 
				
			||||||
                  std::vector<int>& score,
 | 
					                  std::vector<int>& score,
 | 
				
			||||||
                  std::vector<int>& dp) {
 | 
					                  std::vector<int>& dp) {
 | 
				
			||||||
  bool pfirst = true,  // aligning the first character of pattern
 | 
					  bool pfirst = true,  // aligning the first character of pattern
 | 
				
			||||||
@ -204,7 +204,7 @@ struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
 | 
				
			|||||||
    for (int i = 0; i < db->detailed_names.size(); ++i) {
 | 
					    for (int i = 0; i < db->detailed_names.size(); ++i) {
 | 
				
			||||||
      if (db->detailed_names[i].find(query) != std::string::npos) {
 | 
					      if (db->detailed_names[i].find(query) != std::string::npos) {
 | 
				
			||||||
        // Do not show the same entry twice.
 | 
					        // Do not show the same entry twice.
 | 
				
			||||||
        if (!inserted_results.insert(std::string(db->detailed_names[i])).second)
 | 
					        if (!inserted_results.insert(db->detailed_names[i]).second)
 | 
				
			||||||
          continue;
 | 
					          continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (InsertSymbolIntoResult(db, working_files, db->symbols[i],
 | 
					        if (InsertSymbolIntoResult(db, working_files, db->symbols[i],
 | 
				
			||||||
@ -227,7 +227,7 @@ struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
 | 
				
			|||||||
      for (int i = 0; i < db->short_names.size(); ++i) {
 | 
					      for (int i = 0; i < db->short_names.size(); ++i) {
 | 
				
			||||||
        if (SubsequenceMatch(query_without_space, db->short_names[i])) {
 | 
					        if (SubsequenceMatch(query_without_space, db->short_names[i])) {
 | 
				
			||||||
          // Do not show the same entry twice.
 | 
					          // Do not show the same entry twice.
 | 
				
			||||||
          if (!inserted_results.insert(std::string(db->detailed_names[i])).second)
 | 
					          if (!inserted_results.insert(db->detailed_names[i]).second)
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (InsertSymbolIntoResult(db, working_files, db->symbols[i],
 | 
					          if (InsertSymbolIntoResult(db, working_files, db->symbols[i],
 | 
				
			||||||
 | 
				
			|||||||
@ -943,8 +943,8 @@ void QueryDatabase::ImportOrUpdate(
 | 
				
			|||||||
void QueryDatabase::UpdateDetailedNames(size_t* qualified_name_index,
 | 
					void QueryDatabase::UpdateDetailedNames(size_t* qualified_name_index,
 | 
				
			||||||
                                        SymbolKind kind,
 | 
					                                        SymbolKind kind,
 | 
				
			||||||
                                        size_t symbol_index,
 | 
					                                        size_t symbol_index,
 | 
				
			||||||
                                        std::string_view short_name,
 | 
					                                        const std::string& short_name,
 | 
				
			||||||
                                        std::string_view detailed_name) {
 | 
					                                        const std::string& detailed_name) {
 | 
				
			||||||
  if (*qualified_name_index == -1) {
 | 
					  if (*qualified_name_index == -1) {
 | 
				
			||||||
    short_names.push_back(short_name);
 | 
					    short_names.push_back(short_name);
 | 
				
			||||||
    detailed_names.push_back(detailed_name);
 | 
					    detailed_names.push_back(detailed_name);
 | 
				
			||||||
 | 
				
			|||||||
@ -363,8 +363,8 @@ MAKE_HASHABLE(NormalizedPath, t.path);
 | 
				
			|||||||
struct QueryDatabase {
 | 
					struct QueryDatabase {
 | 
				
			||||||
  // Indicies between lookup vectors are related to symbols, ie, index 5 in
 | 
					  // Indicies between lookup vectors are related to symbols, ie, index 5 in
 | 
				
			||||||
  // |detailed_names| matches index 5 in |symbols|.
 | 
					  // |detailed_names| matches index 5 in |symbols|.
 | 
				
			||||||
  std::vector<std::string_view> detailed_names;
 | 
					  std::vector<std::string> detailed_names;
 | 
				
			||||||
  std::vector<std::string_view> short_names;
 | 
					  std::vector<std::string> short_names;
 | 
				
			||||||
  std::vector<SymbolIdx> symbols;
 | 
					  std::vector<SymbolIdx> symbols;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Raw data storage. Accessible via SymbolIdx instances.
 | 
					  // Raw data storage. Accessible via SymbolIdx instances.
 | 
				
			||||||
@ -390,8 +390,8 @@ struct QueryDatabase {
 | 
				
			|||||||
  void UpdateDetailedNames(size_t* qualified_name_index,
 | 
					  void UpdateDetailedNames(size_t* qualified_name_index,
 | 
				
			||||||
                           SymbolKind kind,
 | 
					                           SymbolKind kind,
 | 
				
			||||||
                           size_t symbol_index,
 | 
					                           size_t symbol_index,
 | 
				
			||||||
                           std::string_view short_name,
 | 
					                           const std::string& short_name,
 | 
				
			||||||
                           std::string_view detailed_name);
 | 
					                           const std::string& detailed_name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Query the indexing structure to look up symbol id for given Usr.
 | 
					  // Query the indexing structure to look up symbol id for given Usr.
 | 
				
			||||||
  optional<QueryFileId> GetQueryFileIdFromPath(const std::string& path);
 | 
					  optional<QueryFileId> GetQueryFileIdFromPath(const std::string& path);
 | 
				
			||||||
 | 
				
			|||||||
@ -119,6 +119,9 @@ void Reflect(Reader&, std::string_view&) {
 | 
				
			|||||||
  assert(0);
 | 
					  assert(0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
void Reflect(Writer& visitor, std::string_view& data) {
 | 
					void Reflect(Writer& visitor, std::string_view& data) {
 | 
				
			||||||
 | 
					  if (data.empty())
 | 
				
			||||||
 | 
					    visitor.String("");
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
    visitor.String(&data[0], (rapidjson::SizeType)data.size());
 | 
					    visitor.String(&data[0], (rapidjson::SizeType)data.size());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user