Skip to content

Commit

Permalink
Add diag kind to /detailed_diagnostic response
Browse files Browse the repository at this point in the history
  • Loading branch information
bstaletic committed Nov 5, 2023
1 parent 62cfc45 commit 90f85b5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ycmd/completers/language_server/language_server_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,12 @@ def GetDetailedDiagnostic( self, request_data ):
distance = _DistanceOfPointToRange( point, diagnostic[ 'range' ] )
if minimum_distance is None or distance < minimum_distance:
message = diagnostic[ 'message' ]
try:
code = diagnostic[ 'code' ]
message += f' [{ code }]'
except KeyError:
pass

Check warning on line 1677 in ycmd/completers/language_server/language_server_completer.py

View check run for this annotation

Codecov / codecov/patch

ycmd/completers/language_server/language_server_completer.py#L1676-L1677

Added lines #L1676 - L1677 were not covered by tests

if distance == 0:
break
minimum_distance = distance
Expand Down
3 changes: 2 additions & 1 deletion ycmd/tests/go/diagnostics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def test_Diagnostics_DetailedDiags( self, app ):
any_of( has_entry( 'message',
'undeclared name: diagnostics_test' ),
has_entry( 'message',
'undefined: diagnostics_test' ) ) )
'undefined: diagnostics_test'
' [UndeclaredName]' ) ) )


@WithRetry()
Expand Down
3 changes: 2 additions & 1 deletion ycmd/tests/java/diagnostics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ def test_Diagnostics_DetailedDiags( self, app ):
results = app.post_json( '/detailed_diagnostic', request_data ).json
assert_that( results, has_entry(
'message',
'The value of the field TestFactory.Bar.testString is not used' ) )
'The value of the field TestFactory.Bar.testString '
'is not used [570425421]' ) )


@WithRetry()
Expand Down
2 changes: 1 addition & 1 deletion ycmd/tests/rust/diagnostics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_Diagnostics_DetailedDiags( self, app ):
results = app.post_json( '/detailed_diagnostic', request_data ).json
assert_that( results, has_entry(
'message',
'no field `build_` on type `test::Builder`\nunknown field' ) )
'no field `build_` on type `test::Builder`\nunknown field [E0609]' ) )


@WithRetry()
Expand Down

0 comments on commit 90f85b5

Please sign in to comment.