This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Implement typeHierarchy/resolve for subtypes
ClosedPublic

Authored by nridge on Jul 7 2019, 10:18 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

nridge created this revision.Jul 7 2019, 10:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2019, 10:18 PM

This was an oversight on my part: I forgot that, when we didn't implement typeHierarchy/resolve, it was only supertypes that didn't need it; subtypes do.

sammccall accepted this revision.Jul 11 2019, 11:44 AM

Thanks, I forgot we hadn't hooked this part up!

clang-tools-extra/clangd/XRefs.cpp
1222 ↗(On Diff #208318)

I think this should just return Item.
We're supposed to return null if the item is no longer valid, but AFAICT not if it's valid but already fully resolved.

Since we don't actually detect invalidity (e.g. when the location is no longer valid), I'd suggest just making all the functions here return TypeHierarchyItem rather than Optional (or take a mutable reference for this one, which is synchronous)

clang-tools-extra/clangd/XRefs.h
144 ↗(On Diff #208318)

const TypeHierarchyItem &Item

(or mutable ref as suggested in the other comment, and return void)

clang-tools-extra/clangd/test/type-hierarchy.test
1 ↗(On Diff #208318)

Please add a unit test to TypeHierarchyTests.

I'm on the fence about having a lit test: it's a new LSP method, though the binding is pretty simple.
But features that are only covered by lit tests are too painful to maintain.

This revision is now accepted and ready to land.Jul 11 2019, 11:44 AM
This revision was automatically updated to reflect the committed changes.
nridge marked 3 inline comments as done.
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2019, 8:26 PM
nridge marked an inline comment as done.Jul 11 2019, 8:29 PM
nridge added inline comments.
clang-tools-extra/clangd/test/type-hierarchy.test
1 ↗(On Diff #208318)

As I've already written the lit test, I think there's little harm in keeping it.

nridge reopened this revision.Jul 12 2019, 10:33 AM
nridge marked an inline comment as done.

This was backed out due to a Windows test failure. Seems to be related to the hint path having a different format on Windows. I guess I should not hard-code it, but get it from the TestTU.

This revision is now accepted and ready to land.Jul 12 2019, 10:33 AM
sammccall added inline comments.Jul 12 2019, 12:51 PM
clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp
629

yes, this should be testPath(TU.Filename)

(TU.Filename is always unix-style relative path, testPath() makes it an OS-style absolute path)

(Thanks for writing the test, and sorry for the hassle it caused!)

nridge updated this revision to Diff 209666.Jul 12 2019, 7:46 PM

Fix Windows test failure

This revision was automatically updated to reflect the committed changes.