Skip to content

Commit 89ed4cf

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix_lsp_server_multiple_start
2 parents adf7f7a + a51329a commit 89ed4cf

File tree

13 files changed

+214
-117
lines changed

13 files changed

+214
-117
lines changed

build.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ def Exit( self ):
8989
)$
9090
"""
9191

92-
JDTLS_MILESTONE = '1.36.0'
93-
JDTLS_BUILD_STAMP = '202405301306'
92+
JDTLS_MILESTONE = '1.40.0'
93+
JDTLS_BUILD_STAMP = '202409261450'
9494
JDTLS_SHA256 = (
95-
'028e274d06f4a61cad4ffd56f89ef414a8f65613c6d05d9467651b7fb03dae7b'
95+
'7416fc62befa450e32f06ec2b503f2eec5f22f0b1cc12f7b8ee5112bf671cf11'
9696
)
9797

98-
DEFAULT_RUST_TOOLCHAIN = 'nightly-2024-06-11'
98+
DEFAULT_RUST_TOOLCHAIN = 'nightly-2024-12-12'
9999
RUST_ANALYZER_DIR = p.join( DIR_OF_THIRD_PARTY, 'rust-analyzer' )
100100

101101
BUILD_ERROR_MESSAGE = (
@@ -964,7 +964,7 @@ def EnableGoCompleter( args ):
964964
new_env.pop( 'GOROOT', None )
965965
new_env[ 'GOBIN' ] = p.join( new_env[ 'GOPATH' ], 'bin' )
966966

967-
gopls = 'golang.org/x/tools/[email protected].1'
967+
gopls = 'golang.org/x/tools/[email protected].2'
968968
CheckCall( [ go, 'install', gopls ],
969969
env = new_env,
970970
quiet = args.quiet,

third_party/tsserver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "ycmd tsserver runtime area with required typescript version and plugins",
33
"dependencies": {
4-
"typescript": "5.4.5"
4+
"typescript": "5.7.2"
55
}
66
}

ycmd/completers/language_server/language_server_completer.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,22 +2995,29 @@ def _ResolveFixit( self, request_data, fixit ):
29952995
# provider, but send a LSP Command instead. We can not resolve those with
29962996
# codeAction/resolve!
29972997
if ( 'command' not in code_action or
2998-
isinstance( code_action[ 'command' ], str ) ):
2998+
not isinstance( code_action[ 'command' ], str ) ):
29992999
request_id = self.GetConnection().NextRequestId()
30003000
msg = lsp.CodeActionResolve( request_id, code_action )
3001-
code_action = self.GetConnection().GetResponse(
3002-
request_id,
3003-
msg,
3004-
REQUEST_TIMEOUT_COMMAND )[ 'result' ]
3001+
try:
3002+
code_action = self.GetConnection().GetResponse(
3003+
request_id,
3004+
msg,
3005+
REQUEST_TIMEOUT_COMMAND )[ 'result' ]
3006+
except ResponseFailedException:
3007+
# Even if resolving has failed, we might still be able to apply
3008+
# what we have previously received...
3009+
# See https://github.com/rust-lang/rust-analyzer/issues/18428
3010+
if not ( 'edit' in code_action or 'command' in code_action ):
3011+
raise
30053012

30063013
result = []
30073014
if 'edit' in code_action:
30083015
result.append( self.CodeActionLiteralToFixIt( request_data,
30093016
code_action ) )
30103017

3011-
if 'command' in code_action:
3018+
if command := code_action.get( 'command' ):
30123019
assert not result, 'Code actions with edit and command is not supported.'
3013-
if isinstance( code_action[ 'command' ], str ):
3020+
if isinstance( command, str ):
30143021
unresolved_command_fixit = self.CommandToFixIt( request_data,
30153022
code_action )
30163023
else:

ycmd/tests/clangd/subcommands_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ def FixIt_Check_AutoExpand_Resolved( results ):
543543
} ) )
544544

545545

546+
@WithRetry()
546547
def RunRangedFixItTest( app, rng, expected, chosen_fixit = 0 ):
547548
contents = ReadFile( PathToTestFile( 'FixIt_Clang_cpp11.cpp' ) )
548549
args = {
@@ -616,7 +617,6 @@ def test_Subcommands_DefinedSubcommands( self, app ):
616617
} )
617618

618619

619-
@WithRetry()
620620
@SharedYcmd
621621
def test_Subcommands_ServerNotInitialized( self, app ):
622622
for cmd in [
@@ -646,6 +646,7 @@ def test_Subcommands_ServerNotInitialized( self, app ):
646646
with self.subTest( cmd = cmd ):
647647
completer = handlers._server_state.GetFiletypeCompleter( [ 'cpp' ] )
648648

649+
@WithRetry()
649650
@patch.object( completer, '_ServerIsInitialized', return_value = False )
650651
def Test( app, cmd, *args ):
651652
request = {
@@ -1177,7 +1178,6 @@ def test_Subcommands_FixIt_all( self, app ):
11771178
RunFixItTest( app, line, column, language, filepath, check )
11781179

11791180

1180-
@WithRetry()
11811181
@SharedYcmd
11821182
def test_Subcommands_FixIt_Ranged( self, app ):
11831183
for test in [
@@ -1237,7 +1237,6 @@ def test_Subcommands_FixIt_AlreadyResolved( self, app ):
12371237
assert_that( actual, equal_to( expected ) )
12381238

12391239

1240-
@WithRetry()
12411240
@IsolatedYcmd( { 'clangd_args': [ '-hidden-features' ] } )
12421241
def test_Subcommands_FixIt_ClangdTweaks( self, app ):
12431242
selection = {

ycmd/tests/java/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def StartJavaCompleterServerWithFile( app, file_path ):
6262
event_name = 'FileReadyToParse',
6363
filepath = file_path,
6464
filetype = 'java' ) )
65+
WaitUntilJavaCompleterServerReady( app )
66+
67+
68+
def WaitUntilJavaCompleterServerReady( app ):
6569
WaitUntilCompleterServerReady( app, 'java', SERVER_STARTUP_TIMEOUT )
6670

6771

ycmd/tests/java/server_management_test.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
isolated_app,
3737
IsolatedYcmd,
3838
StartJavaCompleterServerInDirectory,
39-
StartJavaCompleterServerWithFile )
39+
StartJavaCompleterServerWithFile,
40+
WaitUntilJavaCompleterServerReady )
4041
from ycmd.tests.test_utils import ( BuildRequest,
4142
CompleterProjectDirectoryMatcher,
4243
LocationMatcher,
4344
MockProcessTerminationTimingOut,
4445
RangeMatcher,
4546
TemporaryTestDir,
46-
WaitForDiagnosticsToBeReady,
47-
WaitUntilCompleterServerReady )
47+
WaitForDiagnosticsToBeReady )
4848
from ycmd import utils, handlers
4949

5050

@@ -104,7 +104,7 @@ def test_ServerManagement_RestartServer( self, app ):
104104
),
105105
)
106106

107-
WaitUntilCompleterServerReady( app, 'java' )
107+
WaitUntilJavaCompleterServerReady( app )
108108

109109
app.post_json(
110110
'/event_notification',
@@ -147,7 +147,7 @@ def test_ServerManagement_WipeWorkspace_NoConfig( self ):
147147
),
148148
)
149149

150-
WaitUntilCompleterServerReady( app, 'java' )
150+
WaitUntilJavaCompleterServerReady( app )
151151

152152
assert_that(
153153
app.post_json( '/debug_info',
@@ -197,7 +197,7 @@ def test_ServerManagement_WipeWorkspace_WithConfig( self ):
197197
),
198198
)
199199

200-
WaitUntilCompleterServerReady( app, 'java' )
200+
WaitUntilJavaCompleterServerReady( app )
201201

202202
assert_that(
203203
app.post_json( '/debug_info',
@@ -509,15 +509,19 @@ def test_ServerManagement_ConnectionRaisesWhileShuttingDown( self, app ):
509509
print( f'pid: { pid }' )
510510
process = psutil.Process( pid )
511511

512-
completer = handlers._server_state.GetFiletypeCompleter( [ 'java' ] )
513-
514512
# In this test we mock out the GetResponse method, which is used to send
515513
# the shutdown request. This means we only send the exit notification. It's
516514
# possible that the server won't like this, but it seems reasonable for it
517515
# to actually exit at that point.
518-
with patch.object( completer.GetConnection(),
519-
'GetResponse',
520-
side_effect = RuntimeError ):
516+
from ycmd.completers.language_server import language_server_completer
517+
from ycmd.completers.language_server import language_server_protocol as lsp
518+
519+
def BrokenShutdown( request_id ):
520+
return lsp.BuildRequest( None, 'shutdown', None )
521+
522+
with patch.object( language_server_completer.lsp,
523+
'Shutdown',
524+
side_effect = BrokenShutdown ):
521525
app.post_json(
522526
'/run_completer_command',
523527
BuildRequest(

ycmd/tests/java/subcommands_test.py

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def RunHierarchyTest( app, kind, direction, location, expected, code ):
155155
RunTest( app, test )
156156

157157

158+
@WithRetry()
158159
def RunFixItTest( app,
159160
description,
160161
filepath,
@@ -679,7 +680,6 @@ def test_Subcommands_GoToReferences_NoReferences( self, app ):
679680
'Cannot jump to location' ) )
680681

681682

682-
@WithRetry()
683683
@IsolatedYcmd( {
684684
'extra_conf_globlist': PathToTestFile( 'multiple_projects', '*' )
685685
} )
@@ -722,14 +722,11 @@ def test_Subcommands_GoToReferences_MultipleProjects( self, app ):
722722
'com',
723723
'test',
724724
'TestWidgetImpl.java' )
725-
for desc, request, expect in [
725+
for desc, filepath, line, column, expect in [
726726
( 'GoToReferences works across multiple projects',
727-
{
728-
'command': 'GoToReferences',
729-
'filepath': utils_java,
730-
'line_num': 5,
731-
'column_num': 22,
732-
},
727+
utils_java,
728+
5,
729+
22,
733730
{
734731
'response': requests.codes.ok,
735732
'data': contains_inanyorder(
@@ -739,12 +736,9 @@ def test_Subcommands_GoToReferences_MultipleProjects( self, app ):
739736
)
740737
} ),
741738
( 'GoToReferences works in an unrelated project at the same time',
742-
{
743-
'command': 'GoToReferences',
744-
'filepath': abstract_test_widget,
745-
'line_num': 10,
746-
'column_num': 15,
747-
},
739+
abstract_test_widget,
740+
10,
741+
15,
748742
{
749743
'response': requests.codes.ok,
750744
'data': contains_inanyorder(
@@ -755,16 +749,20 @@ def test_Subcommands_GoToReferences_MultipleProjects( self, app ):
755749
)
756750
} ),
757751
]:
758-
with self.subTest( desc = desc, request = request, expect = expect ):
759-
filepath = request[ 'filepath' ]
752+
with self.subTest( desc = desc,
753+
filepath = filepath,
754+
line = line,
755+
column = column,
756+
expect = expect ):
760757
StartJavaCompleterServerWithFile( app, filepath )
761758

762-
763-
RunTest( app, {
764-
'description': desc,
765-
'request': request,
766-
'expect': expect
767-
} )
759+
RunGoToTest( app,
760+
desc,
761+
filepath,
762+
line,
763+
column,
764+
'GoToReferences',
765+
expect )
768766

769767

770768
@WithRetry()
@@ -1102,7 +1100,6 @@ def test_Subcommands_RefactorRename_Unicode( self, app ):
11021100

11031101

11041102

1105-
@WithRetry()
11061103
@SharedYcmd
11071104
def test_Subcommands_FixIt_SingleDiag_MultipleOption_Insertion( self, app ):
11081105
import os
@@ -1259,7 +1256,6 @@ def test_Subcommands_FixIt_SingleDiag_MultipleOption_Insertion( self, app ):
12591256
RunFixItTest( app, description, filepath, 19, column, fixits_for_line )
12601257

12611258

1262-
@WithRetry()
12631259
@SharedYcmd
12641260
def test_Subcommands_FixIt_SingleDiag_SingleOption_Modify( self, app ):
12651261
filepath = PathToTestFile( 'simple_eclipse_project',
@@ -1327,7 +1323,6 @@ def test_Subcommands_FixIt_SingleDiag_SingleOption_Modify( self, app ):
13271323
filepath, 27, 12, fixits )
13281324

13291325

1330-
@WithRetry()
13311326
@SharedYcmd
13321327
def test_Subcommands_FixIt_SingleDiag_MultiOption_Delete( self, app ):
13331328
filepath = PathToTestFile( 'simple_eclipse_project',
@@ -1404,7 +1399,6 @@ def test_Subcommands_FixIt_SingleDiag_MultiOption_Delete( self, app ):
14041399
filepath, 15, 29, fixits )
14051400

14061401

1407-
@WithRetry()
14081402
@SharedYcmd
14091403
def test_Subcommands_FixIt_MultipleDiags( self, app ):
14101404
for description, column, expect_fixits in [
@@ -1626,7 +1620,6 @@ def test_Subcommands_FixIt_Range( self, app ):
16261620
)
16271621

16281622

1629-
@WithRetry()
16301623
@SharedYcmd
16311624
def test_Subcommands_FixIt_NoDiagnostics( self, app ):
16321625
filepath = PathToTestFile( 'simple_eclipse_project',
@@ -1652,7 +1645,6 @@ def test_Subcommands_FixIt_NoDiagnostics( self, app ):
16521645
'chunks': instance_of( list ) } ) ) } ) )
16531646

16541647

1655-
@WithRetry()
16561648
@SharedYcmd
16571649
def test_Subcommands_FixIt_Unicode( self, app ):
16581650
fixits = has_entries( {
@@ -1720,7 +1712,6 @@ def test_Subcommands_FixIt_Unicode( self, app ):
17201712
TEST_JAVA, 13, 1, fixits )
17211713

17221714

1723-
@WithRetry()
17241715
@IsolatedYcmd()
17251716
def test_Subcommands_FixIt_InvalidURI( self, app ):
17261717
filepath = PathToTestFile( 'simple_eclipse_project',

ycmd/tests/rust/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717

1818
import functools
1919
import os
20+
import time
21+
from pprint import pformat
2022

2123
from ycmd.tests.test_utils import ( BuildRequest,
2224
ClearCompletionsCache,
2325
IgnoreExtraConfOutsideTestsFolder,
2426
IsolatedApp,
27+
PollForMessagesTimeoutException,
2528
SetUpApp,
2629
StopCompleterServer,
2730
WaitUntilCompleterServerReady )
@@ -52,6 +55,36 @@ def StartRustCompleterServerInDirectory( app, directory ):
5255
WaitUntilCompleterServerReady( app, 'rust' )
5356

5457

58+
def PollForMessages( app, request_data, timeout = 60 ):
59+
expiration = time.time() + timeout
60+
while True:
61+
if time.time() > expiration:
62+
raise PollForMessagesTimeoutException( 'Waited for diagnostics to be '
63+
f'ready for { timeout } seconds, aborting.' )
64+
65+
default_args = {
66+
'line_num' : 1,
67+
'column_num': 1,
68+
}
69+
args = dict( default_args )
70+
args.update( request_data )
71+
72+
response = app.post_json( '/receive_messages', BuildRequest( **args ) ).json
73+
74+
print( f'poll response: { pformat( response ) }' )
75+
76+
if isinstance( response, bool ):
77+
if not response:
78+
raise RuntimeError( 'The message poll was aborted by the server' )
79+
elif isinstance( response, list ):
80+
return response
81+
else:
82+
raise AssertionError(
83+
f'Message poll response was wrong type: { type( response ).__name__ }' )
84+
85+
time.sleep( 0.25 )
86+
87+
5588
def SharedYcmd( test ):
5689
global shared_app
5790

0 commit comments

Comments
 (0)