Renamed GoToDefinitionElseDeclaration to GoTo
The old name still works for the sake of backwards compatibility.
This commit is contained in:
parent
f0bbe22fe4
commit
9cf566bd8f
11
README.md
11
README.md
@ -594,7 +594,7 @@ Python one and on the Clang completer if the currently active file is a
|
|||||||
C/C++/Objective-C one.
|
C/C++/Objective-C one.
|
||||||
|
|
||||||
You may also want to map the subcommands to something less verbose; for
|
You may also want to map the subcommands to something less verbose; for
|
||||||
instance, `nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>`
|
instance, `nnoremap <leader>jd :YcmCompleter GoTo<CR>`
|
||||||
maps the `<leader>jd` sequence to the longer subcommand invocation.
|
maps the `<leader>jd` sequence to the longer subcommand invocation.
|
||||||
|
|
||||||
The various `GoTo*` subcommands add entries to Vim's `jumplist` so you can use
|
The various `GoTo*` subcommands add entries to Vim's `jumplist` so you can use
|
||||||
@ -618,11 +618,12 @@ with `#include` directives (directly or indirectly) in that file.
|
|||||||
|
|
||||||
Supported in filetypes: `c, cpp, objc, objcpp, python, cs`
|
Supported in filetypes: `c, cpp, objc, objcpp, python, cs`
|
||||||
|
|
||||||
### The `GoToDefinitionElseDeclaration` subcommand
|
### The `GoTo` subcommand
|
||||||
|
|
||||||
Looks up the symbol under the cursor and jumps to its definition if possible; if
|
This command tries to perform the "most sensible" GoTo operation it can.
|
||||||
the definition is not accessible from the current translation unit, jumps to the
|
Currently, this means that it tries to look up the symbol under the cursor and
|
||||||
symbol's declaration.
|
jumps to its definition if possible; if the definition is not accessible from
|
||||||
|
the current translation unit, jumps to the symbol's declaration.
|
||||||
|
|
||||||
Supported in filetypes: `c, cpp, objc, objcpp, python, cs`
|
Supported in filetypes: `c, cpp, objc, objcpp, python, cs`
|
||||||
|
|
||||||
|
@ -22,15 +22,20 @@ from ycm.client.base_request import BaseRequest, BuildRequestData, ServerError
|
|||||||
from ycm import vimsupport
|
from ycm import vimsupport
|
||||||
from ycm.utils import ToUtf8IfNeeded
|
from ycm.utils import ToUtf8IfNeeded
|
||||||
|
|
||||||
|
def _EnsureBackwardsCompatibility( arguments ):
|
||||||
|
if arguments and arguments[ 0 ] == 'GoToDefinitionElseDeclaration':
|
||||||
|
arguments[ 0 ] = 'GoTo'
|
||||||
|
return arguments
|
||||||
|
|
||||||
|
|
||||||
class CommandRequest( BaseRequest ):
|
class CommandRequest( BaseRequest ):
|
||||||
def __init__( self, arguments, completer_target = None ):
|
def __init__( self, arguments, completer_target = None ):
|
||||||
super( CommandRequest, self ).__init__()
|
super( CommandRequest, self ).__init__()
|
||||||
self._arguments = arguments
|
self._arguments = _EnsureBackwardsCompatibility( arguments )
|
||||||
self._completer_target = ( completer_target if completer_target
|
self._completer_target = ( completer_target if completer_target
|
||||||
else 'filetype_default' )
|
else 'filetype_default' )
|
||||||
self._is_goto_command = (
|
self._is_goto_command = (
|
||||||
arguments and arguments[ 0 ].startswith( 'GoTo' ) )
|
self._arguments and self._arguments[ 0 ].startswith( 'GoTo' ) )
|
||||||
self._response = None
|
self._response = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class ClangCompleter( Completer ):
|
|||||||
def DefinedSubcommands( self ):
|
def DefinedSubcommands( self ):
|
||||||
return [ 'GoToDefinition',
|
return [ 'GoToDefinition',
|
||||||
'GoToDeclaration',
|
'GoToDeclaration',
|
||||||
'GoToDefinitionElseDeclaration',
|
'GoTo',
|
||||||
'ClearCompilationFlagCache']
|
'ClearCompilationFlagCache']
|
||||||
|
|
||||||
|
|
||||||
@ -116,8 +116,8 @@ class ClangCompleter( Completer ):
|
|||||||
return self._GoToDefinition( request_data )
|
return self._GoToDefinition( request_data )
|
||||||
elif command == 'GoToDeclaration':
|
elif command == 'GoToDeclaration':
|
||||||
return self._GoToDeclaration( request_data )
|
return self._GoToDeclaration( request_data )
|
||||||
elif command == 'GoToDefinitionElseDeclaration':
|
elif command == 'GoTo':
|
||||||
return self._GoToDefinitionElseDeclaration( request_data )
|
return self._GoTo( request_data )
|
||||||
elif command == 'ClearCompilationFlagCache':
|
elif command == 'ClearCompilationFlagCache':
|
||||||
return self._ClearCompilationFlagCache()
|
return self._ClearCompilationFlagCache()
|
||||||
raise ValueError( self.UserCommandsHelpMessage() )
|
raise ValueError( self.UserCommandsHelpMessage() )
|
||||||
@ -163,7 +163,7 @@ class ClangCompleter( Completer ):
|
|||||||
location.column_number_ - 1)
|
location.column_number_ - 1)
|
||||||
|
|
||||||
|
|
||||||
def _GoToDefinitionElseDeclaration( self, request_data ):
|
def _GoTo( self, request_data ):
|
||||||
location = self._LocationForGoTo( 'GetDefinitionLocation', request_data )
|
location = self._LocationForGoTo( 'GetDefinitionLocation', request_data )
|
||||||
if not location or not location.IsValid():
|
if not location or not location.IsValid():
|
||||||
location = self._LocationForGoTo( 'GetDeclarationLocation', request_data )
|
location = self._LocationForGoTo( 'GetDeclarationLocation', request_data )
|
||||||
|
@ -48,7 +48,7 @@ class CsharpCompleter( Completer ):
|
|||||||
'ServerReady': (lambda self, request_data: self._ServerIsReady()),
|
'ServerReady': (lambda self, request_data: self._ServerIsReady()),
|
||||||
'GoToDefinition': (lambda self, request_data: self._GoToDefinition( request_data )),
|
'GoToDefinition': (lambda self, request_data: self._GoToDefinition( request_data )),
|
||||||
'GoToDeclaration': (lambda self, request_data: self._GoToDefinition( request_data )),
|
'GoToDeclaration': (lambda self, request_data: self._GoToDefinition( request_data )),
|
||||||
'GoToDefinitionElseDeclaration': (lambda self, request_data: self._GoToDefinition( request_data ))
|
'GoTo': (lambda self, request_data: self._GoToDefinition( request_data ))
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__( self, user_options ):
|
def __init__( self, user_options ):
|
||||||
|
@ -66,7 +66,7 @@ class JediCompleter( Completer ):
|
|||||||
def DefinedSubcommands( self ):
|
def DefinedSubcommands( self ):
|
||||||
return [ 'GoToDefinition',
|
return [ 'GoToDefinition',
|
||||||
'GoToDeclaration',
|
'GoToDeclaration',
|
||||||
'GoToDefinitionElseDeclaration' ]
|
'GoTo' ]
|
||||||
|
|
||||||
|
|
||||||
def OnUserCommand( self, arguments, request_data ):
|
def OnUserCommand( self, arguments, request_data ):
|
||||||
@ -78,8 +78,8 @@ class JediCompleter( Completer ):
|
|||||||
return self._GoToDefinition( request_data )
|
return self._GoToDefinition( request_data )
|
||||||
elif command == 'GoToDeclaration':
|
elif command == 'GoToDeclaration':
|
||||||
return self._GoToDeclaration( request_data )
|
return self._GoToDeclaration( request_data )
|
||||||
elif command == 'GoToDefinitionElseDeclaration':
|
elif command == 'GoTo':
|
||||||
return self._GoToDefinitionElseDeclaration( request_data )
|
return self._GoTo( request_data )
|
||||||
raise ValueError( self.UserCommandsHelpMessage() )
|
raise ValueError( self.UserCommandsHelpMessage() )
|
||||||
|
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ class JediCompleter( Completer ):
|
|||||||
raise RuntimeError( 'Can\'t jump to declaration.' )
|
raise RuntimeError( 'Can\'t jump to declaration.' )
|
||||||
|
|
||||||
|
|
||||||
def _GoToDefinitionElseDeclaration( self, request_data ):
|
def _GoTo( self, request_data ):
|
||||||
definitions = ( self._GetDefinitionsList( request_data ) or
|
definitions = ( self._GetDefinitionsList( request_data ) or
|
||||||
self._GetDefinitionsList( request_data, declaration = True ) )
|
self._GetDefinitionsList( request_data, declaration = True ) )
|
||||||
if definitions:
|
if definitions:
|
||||||
|
@ -95,7 +95,7 @@ def DefinedSubcommands_Works_test():
|
|||||||
|
|
||||||
eq_( [ 'GoToDefinition',
|
eq_( [ 'GoToDefinition',
|
||||||
'GoToDeclaration',
|
'GoToDeclaration',
|
||||||
'GoToDefinitionElseDeclaration' ],
|
'GoTo' ],
|
||||||
app.post_json( '/defined_subcommands', subcommands_data ).json )
|
app.post_json( '/defined_subcommands', subcommands_data ).json )
|
||||||
|
|
||||||
|
|
||||||
@ -106,6 +106,6 @@ def DefinedSubcommands_WorksWhenNoExplicitCompleterTargetSpecified_test():
|
|||||||
|
|
||||||
eq_( [ 'GoToDefinition',
|
eq_( [ 'GoToDefinition',
|
||||||
'GoToDeclaration',
|
'GoToDeclaration',
|
||||||
'GoToDefinitionElseDeclaration' ],
|
'GoTo' ],
|
||||||
app.post_json( '/defined_subcommands', subcommands_data ).json )
|
app.post_json( '/defined_subcommands', subcommands_data ).json )
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user