This is an LSP extension proposed here:
https://github.com/Microsoft/vscode-languageserver-node/pull/426
An example client implementation can be found here:
https://github.com/theia-ide/theia/pull/3802
Differential D56370
[clangd] Add support for type hierarchy (super types only for now) nridge on Jan 6 2019, 4:32 PM. Authored by
Details This is an LSP extension proposed here: An example client implementation can be found here:
Diff Detail
Event TimelineThere are a very large number of changes, so older changes are hidden. Show Older Changes This comment was removed by nridge. Comment Actions Please see also the clangd-dev discussion about this feature. A particular question that I could use some feedback on from reviewers: the patch takes several functions that were previously file-local, such as declToSym() in FindSymbols.cpp and toURI() in SymbolCollector.cpp, and promotes them to functions declared in the corresponding header, so that they can be used from elsewhere (e.g. declToSym() from XRefs.cpp). Should these functions be moved to a dedicated file for utilities used for converting from internal representations (e.g. AST nodes) to protocol structures? Comment Actions Hi Nate, thanks for the patch! I am just wondering which data structure fits the best here. Do you have any thoughts on support for virtual inheritance? In other words - should we use a tree or a DAG?
Comment Actions All the editors I know of that support a type hierarchy view, use a tree view of some sort to display it, so I think having a tree data structure at the protocol level makes sense. We could potentially annotate virtual bases with a flag (perhaps visualized as an icon / decoration) to draw attention to them.
Comment Actions This is a partial implementation of the revised spec for type hierarchy. Things that still need to be done:
Comment Actions Implementation LG, but I am not sure about adding a functionality on a proposal that might change. WDYT @sammccall ?
Comment Actions We discussed this a bit on the thread, I think we should follow the proposed spec, but with some useful hedges:
So on a concrete but still high-level:
Comment Actions Updated reviewers line to reflect (I think) current reality so this doesn't get lost, but feel free to reassign as you'd prefer. Comment Actions Add tests for scenarios involving class template specializations Also improve support for dependent bases Comment Actions (This update is unrelated to the review comments, it's just improvements I had in the queue already. Another update to address review comments will come next.) Comment Actions Thank you for the reviews!
Comment Actions A hypothetical client could always ask for one level at a time, and ignore any levels it didn't ask for; such a client would break if we did this. I think the implementation of resolve is straightforward enough that we might as well keep it.
This sounds nice and clean, thanks for the suggestion! I will give it a try. Comment Actions In the latest update I introduced these helpers. I made the first one findRecordTypeAt() instead of findTypeAt(), since findTypeAt() suggests it also works for built-in types like int, but I don't think we can get a Decl* for int. As far as reworking the tests to use these functions, I've thought about that a bit:
Comment Actions See findDecl in ASTUnit.h
Yes, please do.
Comment Actions
Comment Actions Hi Nathan, @kadircet, can you finish the review here so we can get this landed?
Comment Actions Thanks for picking this up... just wanted to leave one last comment as I'd been thinking about the recursive template case too.
Comment Actions Address most of the latest review comments. The infinite recursion issue remains to be fixed.
Comment Actions The updated patch addresses the infinite recursion issue by bailing on dependent bases for now, as Sam suggested. I will implement the more comprehensive suggested fix ("bail out once we see instantiations of the same template decl twice in a parent chain") in a follow-up patch. I did add all three testcases that have come up during discussion. I believe all review comments to date are addressed now.
Comment Actions Fix a (somewhat amusing) typo where I wrote '0' instead of 'O' in a fromJSON() implementation (Does the fact that this didn't cause any test failures suggest that the fromJSON() functions aren't exercised by any tests?) Comment Actions Unfortunately, there is a further problem: the Theia client-side implementation of type hierarchy has recently merged, and their code has changed so that they do require typeHierarchy/resolve to be supported. They ask for 1 level in the initial request, ignore any extra levels the server might send, and ask for extra levels using typeHierarchy/resolve instead. What should we do here -- seek to change Theia, or implement typeHierachy/resolve for supertypes after all? Comment Actions Unfortunately we usually test LSP layer with lit tests, and since we don't have any lit tests for this use-case it wasn't caught. Could you add a lit test for overall use case? You can see examples inside clang-tools-extra/test/clangd/ folder. Looking at https://github.com/theia-ide/theia/pull/3802#issuecomment-455992523 inside theia's implementation of this feature, I believe these are all subject to change.
Comment Actions
Note, that is a fairly old comment, and as mentioned the PR in question has recently merged.
Ok, I filed a Theia issue about it for now. Comment Actions Thanks! Yes unfortunately :( Thanks for moving the tests!
Comment Actions just a few drive-by comments ;)
Comment Actions A few small NITs
|