<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 27, 2018, 22:22 Simon Marchi via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org">clangd-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
There is no request to obtain the type hierarchy starting from a <br>
particular type in the LSP specification yet, but there are some <br>
proposals [1] and some other language servers have their own extension <br>
to the protocol to support that.  I thought I would start prototyping <br>
the feature in clangd to see how we can retrieve this information, so <br>
that once the specification is modified to include such a request, we <br>
are not too far from supporting it.  It can also help steer the proposed <br>
changes to the specification to make sure it supports what we need for <br>
the C++ language.<br>
<br>
The scope of my prototype is: given a type or variable, recursively find <br>
the base classes of that type (or the type of that variable).  I am not <br>
considering derived classes right now, because it would require dealing <br>
with the index.  Here is my work so far:<br>
<br>
<a href="https://reviews.llvm.org/D51311" rel="noreferrer noreferrer" target="_blank">https://reviews.llvm.org/D51311</a></blockquote></div></div><div dir="auto">Haven't looked at the patch yet, but this sounds awesome and you're right about the index needing work to support this. </div><div dir="auto">One approach would be to use the XRefs APIs that are landing, make "overrides" a role, and allow the payload to be a symbol ID rather than a location.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
One extra feature I would really like to have is to be able to use the <br>
"type hierarchy" request on a method (definition, declaration or call).  <br>
The result would tell you which nodes of the type hierarchy have an <br>
implementation of this method (possibly with some more details, is it <br>
virtual, is it pure, etc).  It would allow implementing UIs such as the <br>
one in this screenshot, which I find very useful:<br>
<br>
<a href="https://github.com/Microsoft/vscode-languageserver-node/pull/346#issuecomment-416256239" rel="noreferrer noreferrer" target="_blank">https://github.com/Microsoft/vscode-languageserver-node/pull/346#issuecomment-416256239</a><br>
<br>
I'm a bit stuck at this point: given a CXXMethodDecl representing the <br>
method the user targeted, how can I tell if some base class (a <br>
CXXRecordDecl) has a method matching this one.  I saw <br>
CXXMethodDecl::overridden_methods, but it only concerns virtual methods, <br>
whereas for type hierarchy we would also want non-virtual overrides.<br></blockquote></div></div><div dir="auto">Dumb question, what are non-virtual overrides? I'm thinking CRTP, but I'm probably overthinking this :-)</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Does anybody have any pointers on how I could do this?<br>
<br>
Simon<br>
<br>
[1] <a href="https://github.com/Microsoft/vscode-languageserver-node/pull/346" rel="noreferrer noreferrer" target="_blank">https://github.com/Microsoft/vscode-languageserver-node/pull/346</a><br>
_______________________________________________<br>
clangd-dev mailing list<br>
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank" rel="noreferrer">clangd-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
</blockquote></div></div></div>