def _BuildGoToResponse( self, definition_list ): if len( definition_list ) == 1: definition = definition_list[ 0 ] if definition.in_builtin_module(): if definition.is_keyword: raise RuntimeError( 'Cannot get the definition of Python keywords.' ) else: raise RuntimeError( 'Builtin modules cannot be displayed.' ) else: return responses.BuildGoToResponse( definition.module_path, definition.line - 1, definition.column ) else: # multiple definitions defs = [] for definition in definition_list: if definition.in_builtin_module(): defs.append( responses.BuildDescriptionOnlyGoToResponse( 'Builtin ' + definition.description ) ) else: defs.append( responses.BuildGoToResponse( definition.module_path, definition.line - 1, definition.column, definition.description ) ) return defs
def _GoToDefinition(self, request_data): location = self._LocationForGoTo('GetDefinitionLocation', request_data) if not location or not location.IsValid(): raise RuntimeError('Can\'t jump to definition.') return responses.BuildGoToResponse(location.filename_, location.line_number_ - 1, location.column_number_ - 1)
def _GoToDefinition( self, request_data ): """ Jump to definition of identifier under cursor """ definition = self._GetResponse( '/gotodefinition', self._DefaultParameters( request_data ) ) if definition[ 'FileName' ] != None: return responses.BuildGoToResponse( definition[ 'FileName' ], definition[ 'Line' ], definition[ 'Column' ] ) else: raise RuntimeError( 'Can\'t jump to definition' )
def _ResponseForLocation(location): return responses.BuildGoToResponse(location.filename_, location.line_number_ - 1, location.column_number_ - 1)