def event_classifier(data): if is_errors_response(data): params = AnalysisErrorsParams.from_json(data["params"]) return params.to_notification() if is_navigation_notification(data): result = AnalysisNavigationParams.from_json(data["params"]) return result.to_notification() if is_completion_results(data): result = CompletionResultsParams.from_json(data["params"]) return result.to_notification() return None
def event_classifier(data): if is_errors_response(data): params = AnalysisErrorsParams.from_json(data['params']) return params.to_notification() if is_navigation_notification(data): result = AnalysisNavigationParams.from_json(data['params']) return result.to_notification() if is_completion_results(data): result = CompletionResultsParams.from_json(data['params']) return result.to_notification() return None
def response_classifier(data): # XXX: replace here XXX if is_errors_response(data): params = AnalysisErrorsParams.from_json(data['params']) return params.to_notification() if is_server_version_response(data): result = ServerGetVersionResult.from_json(data['result']) return result.to_response(data['id']) if is_navigation_notification(data): result = AnalysisNavigationParams.from_json(data['params']) return result.to_notification() return None
def run(self): _logger.info('starting ResponseHandler') try: # Awaiting other threads... self.server.ready_barrier.wait() except threading.BrokenBarrierError: _logger.error('could not start ResponseHandler properly') return response_maker = ResponseMaker(self.server.responses) try: for resp in response_maker.make(): if resp is None: continue if isinstance(resp, dict): if resp.get('_internal') == _SIGNAL_STOP: _logger.info('ResponseHandler exiting by internal request.') return if isinstance(resp, Notification): if isinstance(resp.params, AnalysisErrorsParams): # Make sure the right type is passed to the async # code. `resp` may point to a different object when # the async code finally has a chance to run. after(0, actions.show_errors, AnalysisErrorsParams.from_json(resp.params.to_json().copy()) ) continue if isinstance(resp.params, AnalysisNavigationParams): after(0, actions.handle_navigation_data, AnalysisNavigationParams.from_json(resp.params.to_json().copy()) ) continue if isinstance(resp, Response): if isinstance(resp.result, ServerGetVersionResult): print('Dart: Analysis Server version:', resp.result.version) continue except Exception as e: msg = 'error in thread' + self.name + '\n' msg += str(e) _logger.error(msg)
def run(self): _logger.info('starting ResponseHandler') response_maker = ResponseMaker(self.server) try: for resp in response_maker.make(): if resp is None: continue if isinstance(resp, dict): if resp.get('_internal') == _SIGNAL_STOP: _logger.info( 'ResponseHandler exiting by internal request.') return if isinstance(resp, Notification): if isinstance(resp.params, AnalysisErrorsParams): # Make sure the right type is passed to the async # code. `resp` may point to a different object when # the async code finally has a chance to run. after( 0, actions.show_errors, AnalysisErrorsParams.from_json( resp.params.to_json().copy())) continue if isinstance(resp.params, AnalysisNavigationParams): after( 0, actions.handle_navigation_data, AnalysisNavigationParams.from_json( resp.params.to_json().copy())) continue if isinstance(resp.params, CompletionResultsParams): with editor_context.autocomplete_context as actx: if actx.request_id or (resp.params.id != actx.id): actx.invalidate_results() continue after( 0, actions.handle_completions, CompletionResultsParams.from_json( resp.params.to_json().copy())) if isinstance(resp, Response): if isinstance(resp.result, ServerGetVersionResult): print('Dart: Running analysis server version', resp.result.version) continue if isinstance(resp.result, CompletionGetSuggestionsResult): with editor_context.autocomplete_context as actx: if resp.id != actx.request_id: continue actx.id = resp.result.id actx.request_id = None if isinstance(resp.result, EditFormatResult): after( 0, actions.handle_formatting, EditFormatResult.from_json( resp.result.to_json().copy())) continue except Exception as e: msg = 'error in thread' + self.name + '\n' msg += str(e) _logger.error(msg)
def run(self): _logger.info('starting ResponseHandler') response_maker = ResponseMaker(self.server) try: for resp in response_maker.make(): if resp is None: continue if isinstance(resp, dict): if resp.get('_internal') == _SIGNAL_STOP: _logger.info('ResponseHandler exiting by internal request.') return if isinstance(resp, Notification): if isinstance(resp.params, AnalysisErrorsParams): # Make sure the right type is passed to the async # code. `resp` may point to a different object when # the async code finally has a chance to run. after(0, actions.show_errors, AnalysisErrorsParams.from_json(resp.params.to_json().copy()) ) continue if isinstance(resp.params, AnalysisNavigationParams): after(0, actions.handle_navigation_data, AnalysisNavigationParams.from_json(resp.params.to_json().copy()) ) continue if isinstance(resp.params, CompletionResultsParams): with editor_context.autocomplete_context as actx: if actx.request_id or (resp.params.id != actx.id): actx.invalidate_results() continue after(0, actions.handle_completions, CompletionResultsParams.from_json(resp.params.to_json().copy()) ) if isinstance(resp, Response): if isinstance(resp.result, ServerGetVersionResult): print('Dart: Running analysis server version', resp.result.version) continue if isinstance(resp.result, CompletionGetSuggestionsResult): with editor_context.autocomplete_context as actx: if resp.id != actx.request_id: continue actx.id = resp.result.id actx.request_id = None if isinstance(resp.result, EditFormatResult): after(0, actions.handle_formatting, EditFormatResult.from_json(resp.result.to_json().copy())) continue except Exception as e: msg = 'error in thread' + self.name + '\n' msg += str(e) _logger.error(msg)