mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-10-30 20:22:38 +00:00 
			
		
		
		
	$ccls/publishSemanticHighlighting: support both line/character-style and position-style ranges
This commit is contained in:
		
							parent
							
								
									d604fc38dc
								
							
						
					
					
						commit
						4612aa062b
					
				| @ -144,6 +144,9 @@ struct Config { | |||||||
| 
 | 
 | ||||||
|   // Semantic highlighting
 |   // Semantic highlighting
 | ||||||
|   struct Highlight { |   struct Highlight { | ||||||
|  |     // true: LSP line/character; false: position
 | ||||||
|  |     bool lsRanges = false; | ||||||
|  | 
 | ||||||
|     // Like index.{whitelist,blacklist}, don't publish semantic highlighting to
 |     // Like index.{whitelist,blacklist}, don't publish semantic highlighting to
 | ||||||
|     // blacklisted files.
 |     // blacklisted files.
 | ||||||
|     std::vector<std::string> blacklist; |     std::vector<std::string> blacklist; | ||||||
| @ -230,7 +233,7 @@ MAKE_REFLECT_STRUCT(Config::Diagnostics, | |||||||
|                     onParse, |                     onParse, | ||||||
|                     onType, |                     onType, | ||||||
|                     whitelist) |                     whitelist) | ||||||
| MAKE_REFLECT_STRUCT(Config::Highlight, blacklist, whitelist) | MAKE_REFLECT_STRUCT(Config::Highlight, lsRanges, blacklist, whitelist) | ||||||
| MAKE_REFLECT_STRUCT(Config::Index, | MAKE_REFLECT_STRUCT(Config::Index, | ||||||
|                     attributeMakeCallsToCtor, |                     attributeMakeCallsToCtor, | ||||||
|                     blacklist, |                     blacklist, | ||||||
|  | |||||||
| @ -336,12 +336,14 @@ void EmitSemanticHighlighting(DB *db, | |||||||
|   Out_CclsPublishSemanticHighlighting out; |   Out_CclsPublishSemanticHighlighting out; | ||||||
|   out.params.uri = lsDocumentUri::FromPath(wfile->filename); |   out.params.uri = lsDocumentUri::FromPath(wfile->filename); | ||||||
|   // Transform lsRange into pair<int, int> (offset pairs)
 |   // Transform lsRange into pair<int, int> (offset pairs)
 | ||||||
|   { |   if (!g_config->highlight.lsRanges) { | ||||||
|     std::vector<std::pair<lsRange, Out_CclsPublishSemanticHighlighting::Symbol *>> |     std::vector<std::pair<lsRange, Out_CclsPublishSemanticHighlighting::Symbol *>> | ||||||
|       scratch; |       scratch; | ||||||
|     for (auto &entry : grouped_symbols) |     for (auto &entry : grouped_symbols) { | ||||||
|       for (auto &range : entry.second.lsRanges) |       for (auto &range : entry.second.lsRanges) | ||||||
|         scratch.emplace_back(range, &entry.second); |         scratch.emplace_back(range, &entry.second); | ||||||
|  |       entry.second.lsRanges.clear(); | ||||||
|  |     } | ||||||
|     std::sort(scratch.begin(), scratch.end(), |     std::sort(scratch.begin(), scratch.end(), | ||||||
|       [](auto &l, auto &r) { return l.first.start < r.first.start; }); |       [](auto &l, auto &r) { return l.first.start < r.first.start; }); | ||||||
|     const auto &buf = wfile->buffer_content; |     const auto &buf = wfile->buffer_content; | ||||||
| @ -375,7 +377,7 @@ void EmitSemanticHighlighting(DB *db, | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   for (auto &entry : grouped_symbols) |   for (auto &entry : grouped_symbols) | ||||||
|     if (entry.second.ranges.size()) |     if (entry.second.ranges.size() || entry.second.lsRanges.size()) | ||||||
|       out.params.symbols.push_back(std::move(entry.second)); |       out.params.symbols.push_back(std::move(entry.second)); | ||||||
|   pipeline::WriteStdout(kMethodType_CclsPublishSemanticHighlighting, out); |   pipeline::WriteStdout(kMethodType_CclsPublishSemanticHighlighting, out); | ||||||
| } | } | ||||||
|  | |||||||
| @ -76,15 +76,9 @@ struct Out_CclsPublishSemanticHighlighting | |||||||
|   std::string method = "$ccls/publishSemanticHighlighting"; |   std::string method = "$ccls/publishSemanticHighlighting"; | ||||||
|   Params params; |   Params params; | ||||||
| }; | }; | ||||||
| MAKE_REFLECT_STRUCT(Out_CclsPublishSemanticHighlighting::Symbol, | MAKE_REFLECT_STRUCT(Out_CclsPublishSemanticHighlighting::Symbol, stableId, | ||||||
|                     stableId, |                     parentKind, kind, storage, ranges, lsRanges); | ||||||
|                     parentKind, | MAKE_REFLECT_STRUCT(Out_CclsPublishSemanticHighlighting::Params, uri, symbols); | ||||||
|                     kind, |  | ||||||
|                     storage, |  | ||||||
|                     ranges); |  | ||||||
| MAKE_REFLECT_STRUCT(Out_CclsPublishSemanticHighlighting::Params, |  | ||||||
|                     uri, |  | ||||||
|                     symbols); |  | ||||||
| MAKE_REFLECT_STRUCT(Out_CclsPublishSemanticHighlighting, | MAKE_REFLECT_STRUCT(Out_CclsPublishSemanticHighlighting, | ||||||
|                     jsonrpc, |                     jsonrpc, | ||||||
|                     method, |                     method, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user