#NEWLINE# def _goto( self , add_import_name = False ) : #NEWLINE# #INDENT# '\n        Used for goto_assignments and usages.\n\n        :param add_import_name: Add the the name (if import) to the result.\n        ' #NEWLINE# def follow_inexistent_imports( defs ) : #NEWLINE# #INDENT# " Imports can be generated, e.g. following\n            `multiprocessing.dummy` generates an import dummy in the\n            multiprocessing module. The Import doesn't exist -> follow.\n            " #NEWLINE# definitions = set ( defs ) #NEWLINE# for d in defs : #NEWLINE# #INDENT# if ( isinstance ( d . parent , tree . Import ) and ( d . start_pos == ( 0 , 0 ) ) ) : #NEWLINE# #INDENT# i = imports . ImportWrapper ( self . _evaluator , d . parent ) . follow ( is_goto = True ) #NEWLINE# definitions . remove ( d ) #NEWLINE# definitions |= follow_inexistent_imports ( i ) #NEWLINE# #UNINDENT# #UNINDENT# return definitions #NEWLINE# #UNINDENT# goto_path = self . _user_context . get_path_under_cursor ( ) #NEWLINE# context = self . _user_context . get_context ( ) #NEWLINE# user_stmt = self . _parser . user_stmt ( ) #NEWLINE# user_scope = self . _parser . user_scope ( ) #NEWLINE# stmt = self . _get_under_cursor_stmt ( goto_path ) #NEWLINE# if ( stmt is None ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# if ( user_scope is None ) : #NEWLINE# #INDENT# last_name = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# last_name = user_scope . name_for_position ( self . _pos ) #NEWLINE# #UNINDENT# if ( last_name is None ) : #NEWLINE# #INDENT# last_name = stmt #NEWLINE# while ( not isinstance ( last_name , tree . Name ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# last_name = last_name . children [ ( - 1 ) ] #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( next ( context ) in ( 'class' , 'def' ) ) : #NEWLINE# #INDENT# user_scope = self . _parser . user_scope ( ) #NEWLINE# definitions = set ( [ user_scope . name ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( user_stmt , tree . Import ) : #NEWLINE# #INDENT# ( s , name ) = helpers . get_on_import_stmt ( self . _evaluator , self . _user_context , user_stmt ) #NEWLINE# definitions = self . _evaluator . goto ( name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( user_stmt , tree . ExprStmt ) and isinstance ( last_name . parent , tree . ExprStmt ) ) : #NEWLINE# #INDENT# for name in user_stmt . get_defined_names ( ) : #NEWLINE# #INDENT# if ( name . start_pos <= self . _pos <= defs . end_pos ) : #NEWLINE# #INDENT# return [ name ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# defs = self . _evaluator . goto ( last_name ) #NEWLINE# definitions = follow_inexistent_imports ( defs ) #NEWLINE# #UNINDENT# #UNINDENT# return definitions