mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-10-31 12:42:34 +00:00 
			
		
		
		
	Add structures to support document formatting
This commit is contained in:
		
							parent
							
								
									5680ff2592
								
							
						
					
					
						commit
						abc2edf05f
					
				| @ -34,6 +34,8 @@ const char* IpcIdToString(IpcId id) { | |||||||
|       return "textDocument/documentHighlight"; |       return "textDocument/documentHighlight"; | ||||||
|     case IpcId::TextDocumentHover: |     case IpcId::TextDocumentHover: | ||||||
|       return "textDocument/hover"; |       return "textDocument/hover"; | ||||||
|  |     case IpcId::TextDocumentFormatting: | ||||||
|  |       return "textDocument/formatting"; | ||||||
|     case IpcId::TextDocumentReferences: |     case IpcId::TextDocumentReferences: | ||||||
|       return "textDocument/references"; |       return "textDocument/references"; | ||||||
|     case IpcId::TextDocumentDocumentSymbol: |     case IpcId::TextDocumentDocumentSymbol: | ||||||
|  | |||||||
| @ -22,6 +22,7 @@ enum class IpcId : int { | |||||||
|   TextDocumentDefinition, |   TextDocumentDefinition, | ||||||
|   TextDocumentDocumentHighlight, |   TextDocumentDocumentHighlight, | ||||||
|   TextDocumentHover, |   TextDocumentHover, | ||||||
|  |   TextDocumentFormatting, | ||||||
|   TextDocumentReferences, |   TextDocumentReferences, | ||||||
|   TextDocumentDocumentSymbol, |   TextDocumentDocumentSymbol, | ||||||
|   TextDocumentDocumentLink, |   TextDocumentDocumentLink, | ||||||
|  | |||||||
| @ -273,6 +273,25 @@ struct lsTextDocumentPositionParams { | |||||||
| }; | }; | ||||||
| MAKE_REFLECT_STRUCT(lsTextDocumentPositionParams, textDocument, position); | MAKE_REFLECT_STRUCT(lsTextDocumentPositionParams, textDocument, position); | ||||||
| 
 | 
 | ||||||
|  | struct lsFormattingOptions { | ||||||
|  |   // Size of a tab in spaces.
 | ||||||
|  |   int tabSize; | ||||||
|  |   // Prefer spaces over tabs.
 | ||||||
|  |   bool insertSpaces; | ||||||
|  | }; | ||||||
|  | MAKE_REFLECT_STRUCT(lsFormattingOptions, tabSize, insertSpaces); | ||||||
|  | 
 | ||||||
|  | struct lsTextDocumentFormattingParams { | ||||||
|  |   // The text document.
 | ||||||
|  |   lsTextDocumentIdentifier textDocument; | ||||||
|  | 
 | ||||||
|  |   // The format options, like tabs or spaces.
 | ||||||
|  |   lsFormattingOptions formattingOptions; | ||||||
|  | }; | ||||||
|  | MAKE_REFLECT_STRUCT(lsTextDocumentFormattingParams, | ||||||
|  |                     textDocument, | ||||||
|  |                     formattingOptions); | ||||||
|  | 
 | ||||||
| struct lsTextEdit { | struct lsTextEdit { | ||||||
|   // The range of the text document to be manipulated. To insert
 |   // The range of the text document to be manipulated. To insert
 | ||||||
|   // text into a document create a range where start === end.
 |   // text into a document create a range where start === end.
 | ||||||
|  | |||||||
							
								
								
									
										20
									
								
								src/messages/text_document_formatting.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/messages/text_document_formatting.cc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | |||||||
|  | #include "message_handler.h" | ||||||
|  | 
 | ||||||
|  | namespace { | ||||||
|  | struct Ipc_TextDocumentFormatting | ||||||
|  |     : public IpcMessage<Ipc_TextDocumentFormatting> { | ||||||
|  |   const static IpcId kIpcId = IpcId::TextDocumentFormatting; | ||||||
|  | 
 | ||||||
|  |   lsRequestId id; | ||||||
|  |   lsTextDocumentFormattingParams params; | ||||||
|  | }; | ||||||
|  | MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting, id, params); | ||||||
|  | REGISTER_IPC_MESSAGE(Ipc_TextDocumentFormatting); | ||||||
|  | 
 | ||||||
|  | struct Out_TextDocumentFormatting | ||||||
|  |     : public lsOutMessage<Out_TextDocumentFormatting> { | ||||||
|  |   lsRequestId id; | ||||||
|  |   std::vector<lsTextEdit> edits; | ||||||
|  | }; | ||||||
|  | MAKE_REFLECT_STRUCT(Out_TextDocumentFormatting, jsonrpc, id, edits); | ||||||
|  | }  // namespace
 | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user