(self, request)
Accept serialized request from VSCode and write response.
Accept serialized request from VSCode and write response.
Accept serialized request from VSCode and write response .
def _process_request(self, request):
        """Accept serialized request from VSCode and write response.
        """
        request = self._deserialize(request)

        self._set_request_config(request.get('config', {}))

        self._normalize_request_path(request)
        path = self._get_top_level_module(request.get('path', ''))
        if len(path) > 0 and path not in sys.path:
            sys.path.insert(0, path)
        lookup = request.get('lookup', 'completions')

        if lookup == 'names':
            return self._serialize_definitions(
                jedi.api.names(
                    source=request.get('source', None),
                    path=request.get('path', ''),
                    all_scopes=True),
                request['id'])

        script = jedi.Script(
            source=request.get('source', None), line=request['line'] + 1,
            column=request['column'], path=request.get('path', ''),
            sys_path=sys.path, environment=self.environment)

        if lookup == 'definitions':
            defs = self._get_definitionsx(script.goto_assignments(follow_imports=True), request['id'])
            return json.dumps({'id': request['id'], 'results': defs})
        if lookup == 'tooltip':
            if jediPreview:
                defs = []
                try:
                    defs = self._get_definitionsx(script.goto_definitions(), request['id'], True)
                except:
                    pass
                try:
                    if len(defs) == 0:
                        defs = self._get_definitionsx(script.goto_assignments(), request['id'], True)
                except:
                    pass
                return json.dumps({'id': request['id'], 'results': defs})
            else:
                try:
                    return self._serialize_tooltip(script.goto_definitions(), request['id'])
                except:
                    return json.dumps({'id': request['id'], 'results': []})
        elif lookup == 'arguments':
            return self._serialize_arguments(
                script, request['id'])
        elif lookup == 'usages':
            return self._serialize_usages(
                script.usages(), request['id'])
        elif lookup == 'methods':
          return self._serialize_methods(script, request['id'],
                                      request.get('prefix', ''))
        else:
            return self._serialize_completions(script, request['id'],
                                            request.get('prefix', ''))
def _process_request ( self , request ) : request = self . _deserialize ( request ) self . _set_request_config ( request . get ( 'config' , { } ) ) self . _normalize_request_path ( request ) path = self . _get_top_level_module ( request . get ( 'path' , '' ) ) if len ( path ) > 0 and path not in sys . path : sys . path . insert ( 0 , path ) lookup = request . get ( 'lookup' , 'completions' ) if lookup == 'names' : return self . _serialize_definitions ( jedi . api . names ( source = request . get ( 'source' , None ) , path = request . get ( 'path' , '' ) , all_scopes = True ) , request [ 'id' ] ) script = jedi . Script ( source = request . get ( 'source' , None ) , line = request [ 'line' ] + 1 , column = request [ 'column' ] , path = request . get ( 'path' , '' ) , sys_path = sys . path , environment = self . environment ) if lookup == 'definitions' : defs = self . _get_definitionsx ( script . goto_assignments ( follow_imports = True ) , request [ 'id' ] ) return json . dumps ( { 'id' : request [ 'id' ] , 'results' : defs } ) if lookup == 'tooltip' : if jediPreview : defs = [ ] try : defs = self . _get_definitionsx ( script . goto_definitions ( ) , request [ 'id' ] , True ) except : pass try : if len ( defs ) == 0 : defs = self . _get_definitionsx ( script . goto_assignments ( ) , request [ 'id' ] , True ) except : pass return json . dumps ( { 'id' : request [ 'id' ] , 'results' : defs } ) else : try : return self . _serialize_tooltip ( script . goto_definitions ( ) , request [ 'id' ] ) except : return json . dumps ( { 'id' : request [ 'id' ] , 'results' : [ ] } ) elif lookup == 'arguments' : return self . _serialize_arguments ( script , request [ 'id' ] ) elif lookup == 'usages' : return self . _serialize_usages ( script . usages ( ) , request [ 'id' ] ) elif lookup == 'methods' : return self . _serialize_methods ( script , request [ 'id' ] , request . get ( 'prefix' , '' ) ) else : return self . _serialize_completions ( script , request [ 'id' ] , request . get ( 'prefix' , '' ) )