-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[READY] Add support for DocumentSymbol in document outline requests #1757
Conversation
77d333a
to
936a5b6
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1757 +/- ##
==========================================
+ Coverage 95.90% 95.92% +0.01%
==========================================
Files 84 84
Lines 8450 8462 +12
Branches 163 163
==========================================
+ Hits 8104 8117 +13
+ Misses 296 295 -1
Partials 50 50 |
936a5b6
to
8588089
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 LGTMs obtained
ycmd/completers/language_server/language_server_completer.py
line 2659 at r1 (raw file):
if any( 'range' in s for s in result ): LOGGER.debug( 'Hierarchical DocumentSymbol not supported.' )
I'm still logging this, to maybe catch another non-conforming server.
ycmd/tests/language_server/language_server_completer_test.py
line 107 at r1 (raw file):
class LanguageServerCompleterTest( TestCase ): @IsolatedYcmd() def test_LanguageServerCompleter_DocumentSymbol_Hierarchical( self, app ):
This test was added just because we don't yet have a naughty server. Omnisharp would exercise this codepath properly.
0ed683b
to
facffef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some bike shed comments included.
Reviewed 1 of 2 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: 1 of 2 LGTMs obtained (waiting on @bstaletic)
ycmd/completers/language_server/language_server_completer.py
line 3433 at r2 (raw file):
result = [] for s in symbols: partial_results = [ s ]
if I' reading this right, partial_results
doesn't do antything that results
doesn't.
as in, is this not equivalent?
result = []
for s in symbols:
result.append(s)
result.extend(_FlattenDocumentSymbolHierarchy( s.get('children', [] ) ) )
maybe I just don't brain today.
ycmd/completers/language_server/language_server_completer.py
line 3444 at r2 (raw file):
"""Convert a list of LSP DocumentSymbol into a YCM GoTo response""" def BuildGoToLocationFromSymbol( symbol ):
This is so similar to the same def in _SymbolListToGoTo
that the diff algorithm confused the hell out of me.
Perhaps it's time to pull this out to a top-level function and save some duplication?
ycmd/tests/language_server/language_server_completer_test.py
line 107 at r1 (raw file):
Previously, bstaletic (Boris Staletic) wrote…
This test was added just because we don't yet have a naughty server. Omnisharp would exercise this codepath properly.
nice. integration tests are great, but unit tests have their place too!
facffef
to
3027d22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 LGTMs obtained (and 1 stale) (waiting on @puremourning)
ycmd/completers/language_server/language_server_completer.py
line 3433 at r2 (raw file):
Previously, puremourning (Ben Jackson) wrote…
if I' reading this right,
partial_results
doesn't do antything thatresults
doesn't.as in, is this not equivalent?
result = [] for s in symbols: result.append(s) result.extend(_FlattenDocumentSymbolHierarchy( s.get('children', [] ) ) )
maybe I just don't brain today.
You're right. My brain just prefers to work with partial results when writing a recursive algorithm.
Fixed.
ycmd/completers/language_server/language_server_completer.py
line 3444 at r2 (raw file):
Previously, puremourning (Ben Jackson) wrote…
This is so similar to the same def in
_SymbolListToGoTo
that the diff algorithm confused the hell out of me.Perhaps it's time to pull this out to a top-level function and save some duplication?
Yes, the diff was confused.
Hmm... if I pull that out, then _DocumentSymbolListToGoTo
and _SymbolInfoListToGoTo
are exactly the same.
Please double check my implementation and the specs, because workspace symbol is also quite similar.
I did deduplicate, like you suggested.
We are intentionally not advertising the capability. We do want a flat response, so receiving a DocumentSymbol is a pessimisation. Not advertising the capability means that conforming servers take the faster code path and the likes of OmniSharp, that assume capabilities, still work. Yes, it's messy, but so is LSP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 LGTMs obtained (and 1 stale) (waiting on @puremourning)
ycmd/completers/language_server/language_server_completer.py
line 3444 at r2 (raw file):
Previously, bstaletic (Boris Staletic) wrote…
Yes, the diff was confused.
Hmm... if I pull that out, then
_DocumentSymbolListToGoTo
and_SymbolInfoListToGoTo
are exactly the same.Please double check my implementation and the specs, because workspace symbol is also quite similar.
I did deduplicate, like you suggested.
Well, all the tests are passing, which gives me more confidence in the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 LGTMs obtained (and 1 stale) (waiting on @puremourning)
ycmd/completers/language_server/language_server_completer.py
line 3444 at r2 (raw file):
Previously, bstaletic (Boris Staletic) wrote…
Well, all the tests are passing, which gives me more confidence in the changes.
I have rechecked the LSP specs. This implementation is fine.
I'll merge this, to progress the C# stuff. |
I'm not too happy about this.
Omnisharp LSP assumes clients support this.
We could, but it comes at the cost of manually flattening the hierarchy. That's what this pull request does.
Alternatives include:
LanguageServerCompleter
class and only add this hack into the LSP Omnisharp completer. This was done in [RFC] Switch C# completer to LSP #1752EDIT: Switched to the first alternative, as discussed in gitter.
This change is