From f1d8a59247a52a278d70b88b955feb9c019bc16f Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Thu, 26 Oct 2017 22:27:29 +0100 Subject: [PATCH] Compute whether or not to resolve completions statically --- .../language_server/language_server_completer.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ycmd/completers/language_server/language_server_completer.py b/ycmd/completers/language_server/language_server_completer.py index 9f93cfaa63..1d43f4414a 100644 --- a/ycmd/completers/language_server/language_server_completer.py +++ b/ycmd/completers/language_server/language_server_completer.py @@ -601,6 +601,8 @@ def ServerReset( self ): self._initialise_response = None self._initialise_event = threading.Event() self._on_initialise_complete_handlers = list() + self._server_capabilities = None + self._resolve_completion_items = False def ShutdownServer( self ): @@ -704,6 +706,9 @@ def _ResolveCompletionItem( self, item ): def _ShouldResolveCompletionItems( self ): + # We might not actually need to issue the resolve request if the server + # claims that it doesn't support it. However, we still might need to fix up + # the completion items. return ( 'completionProvider' in self._server_capabilities and self._server_capabilities[ 'completionProvider' ].get( 'resolveProvider', @@ -714,11 +719,6 @@ def _ResolveCompletionItems( self, items, request_data ): """Issue the resolve request for each completion item in |items|, then fix up the items such that a single start codepoint is used.""" - # We might not actually need to issue the resolve request if the server - # claims that it doesn't support it. However, we still might need to fix up - # the completion items. - do_resolve = self._ShouldResolveCompletionItems( ) - # # Important note on the following logic: # @@ -754,7 +754,7 @@ def _ResolveCompletionItems( self, items, request_data ): # earliest start_codepoint by borrowing text from the original line. for item in items: # First, resolve the completion. - if do_resolve: + if self._resolve_completion_items: item = self._ResolveCompletionItem( item ) try: @@ -1021,6 +1021,7 @@ def _HandleInitialiseInPollThread( self, response ): when the initialize request receives a response.""" with self._mutex: self._server_capabilities = response[ 'result' ][ 'capabilities' ] + self._resolve_completion_items = self._ShouldResolveCompletionItems() if 'textDocumentSync' in response[ 'result' ][ 'capabilities' ]: SYNC_TYPE = [