#NEWLINE# def on_query_completions( self , view , prefix , locations ) : #NEWLINE# #INDENT# " Sublime autocomplete event handler\n\n        Get completions depends on current cursor position and return\n        them as list of ('possible completion', 'completion type')\n\n        :param view: `sublime.View` object\n        :type view: sublime.View\n        :param prefix: string for completions\n        :type prefix: basestring\n        :param locations: offset from beginning\n        :type locations: int\n\n        :return: list of tuple(str, str)\n        " #NEWLINE# if is_repl ( view ) : #NEWLINE# #INDENT# logger . debug ( 'JEDI does not complete in SublimeREPL views' ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( not is_python_scope ( view , locations [ 0 ] ) ) : #NEWLINE# #INDENT# logger . debug ( 'JEDI completes only in python scope' ) #NEWLINE# return #NEWLINE# #UNINDENT# logger . info ( 'JEDI completion triggered' ) #NEWLINE# completion_mode = self . _get_completion_mode ( view ) #NEWLINE# if self . is_completion_ready : #NEWLINE# #INDENT# logger . debug ( 'JEDI has completion in daemon response {0}' . format ( self . completions ) ) #NEWLINE# self . is_completion_ready = None #NEWLINE# if self . completions : #NEWLINE# #INDENT# cplns = [ tuple ( i ) for i in self . completions ] #NEWLINE# self . completions = [ ] #NEWLINE# if ( completion_mode in ( 'default' , 'jedi' ) ) : #NEWLINE# #INDENT# return ( cplns , PLUGIN_ONLY_COMPLETION ) #NEWLINE# #UNINDENT# return cplns #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if ( self . is_completion_ready is None ) : #NEWLINE# #INDENT# if ( completion_mode == 'all' ) : #NEWLINE# #INDENT# self . completions = self . _get_default_completions ( view , prefix , locations [ 0 ] ) #NEWLINE# #UNINDENT# ask_daemon ( view , self . _show_completions , 'autocomplete' , locations [ 0 ] ) #NEWLINE# self . is_completion_ready = False #NEWLINE# #UNINDENT# view . run_command ( 'hide_auto_complete' ) #NEWLINE# return