@@ -268,6 +268,47 @@ def __init__( self, location: Location, chunks, text = '', kind = None ):
268268 self .kind = kind
269269
270270
271+ class DeleteChunk :
272+ def __init__ ( self , filepath , options ):
273+ self .filepath = filepath
274+ self .options = options
275+
276+ def ToYcmdProtocol ( self ):
277+ return {
278+ 'filepath' : self .filepath ,
279+ 'kind' : 'delete' ,
280+ 'options' : self .options
281+ }
282+
283+
284+ class CreateChunk :
285+ def __init__ ( self , filepath , options ):
286+ self .filepath = filepath
287+ self .options = options
288+
289+ def ToYcmdProtocol ( self ):
290+ return {
291+ 'filepath' : self .filepath ,
292+ 'kind' : 'create' ,
293+ 'options' : self .options
294+ }
295+
296+
297+ class RenameChunk :
298+ def __init__ ( self , old_filepath , new_filepath , options ):
299+ self .old_filepath = old_filepath
300+ self .new_filepath = new_filepath
301+ self .options = options
302+
303+ def ToYcmdProtocol ( self ):
304+ return {
305+ 'new_filepath' : self .new_filepath ,
306+ 'old_filepath' : self .old_filepath ,
307+ 'kind' : 'rename' ,
308+ 'options' : self .options
309+ }
310+
311+
271312class FixItChunk :
272313 """An individual replacement within a FixIt (aka Refactor)"""
273314
@@ -276,6 +317,13 @@ def __init__( self, replacement_text: str, range: Range ):
276317 self .replacement_text = replacement_text
277318 self .range = range
278319
320+ def ToYcmdProtocol ( self ):
321+ return {
322+ 'replacement_text' : self .replacement_text ,
323+ 'range' : BuildRangeData ( self .range ),
324+ 'kind' : 'change'
325+ }
326+
279327
280328def BuildDiagnosticData ( diagnostic ):
281329 kind = ( diagnostic .kind_ .name if hasattr ( diagnostic .kind_ , 'name' )
@@ -314,12 +362,6 @@ def BuildFixItResponse( fixits ):
314362 can be used to apply arbitrary changes to arbitrary files and is suitable for
315363 both quick fix and refactor operations"""
316364
317- def BuildFixitChunkData ( chunk ):
318- return {
319- 'replacement_text' : chunk .replacement_text ,
320- 'range' : BuildRangeData ( chunk .range ),
321- }
322-
323365 def BuildFixItData ( fixit ):
324366 if hasattr ( fixit , 'resolve' ):
325367 result = {
@@ -331,7 +373,7 @@ def BuildFixItData( fixit ):
331373 else :
332374 result = {
333375 'location' : BuildLocationData ( fixit .location ),
334- 'chunks' : [ BuildFixitChunkData ( x ) for x in fixit .chunks ],
376+ 'chunks' : [ x . ToYcmdProtocol ( ) for x in fixit .chunks ],
335377 'text' : fixit .text ,
336378 'kind' : fixit .kind ,
337379 'resolve' : False
0 commit comments