Skip to content

Commit

Permalink
Compute whether or not to resolve completions statically
Browse files Browse the repository at this point in the history
  • Loading branch information
puremourning committed Oct 26, 2017
1 parent 134b581 commit f1d8a59
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ycmd/completers/language_server/language_server_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ):
Expand Down Expand Up @@ -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',
Expand All @@ -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:
#
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit f1d8a59

Please sign in to comment.