This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Switch xrefs and documenthighlight to annotated-code unit tests. NFC
ClosedPublic

Authored by sammccall on Dec 20 2017, 2:11 AM.

Details

Summary

The goal here is again to make it easier to read and write the tests.
The existing lit tests are replaced with a (relatively) tiny smoke test (xrefs.test).

I've extracted parseTextMarker from CodeCompleteTests into an Annotations
class, adding features to it:

  • as well as points ^ it allows ranges [[...]]
  • multiple points and ranges are supported
  • points and ranges may be named: $name^ and $name[[...]]

These features are used for the xrefs tests. This also paves the way for
replacing the lit diagnostics.test with more readable unit tests, using named
ranges.

Alternative considered: TestSelectionRange in clang-refactor/TestSupport
Main problems were:

  • delimiting the end of ranges is awkward, requiring counting
  • comment syntax is long and at least as cryptic for most cases
  • no separate syntax for point vs range, which keeps xrefs tests concise
  • Still need to convert to Position everywhere
  • Still need helpers for common case of expecting exactly one point/range

Event Timeline

sammccall created this revision.Dec 20 2017, 2:11 AM
sammccall edited the summary of this revision. (Show Details)Dec 20 2017, 2:14 AM
sammccall updated this revision to Diff 127674.Dec 20 2017, 2:29 AM

Remove test PrintTos for basic types after r321161.

sammccall edited the summary of this revision. (Show Details)Dec 20 2017, 2:30 AM
ioeric accepted this revision.Dec 20 2017, 3:10 AM

lgtm! This is amazing!

unittests/clangd/Annotations.h
12

Does this support overlapping annotations like (named) points in (named) ranges?

45

Is this the position in the stripped code or the original text?

This revision is now accepted and ready to land.Dec 20 2017, 3:10 AM
sammccall marked 2 inline comments as done.Dec 20 2017, 8:03 AM
sammccall added inline comments.
unittests/clangd/Annotations.h
12

Yes - ranges can be nested, but not "overlapping" like [a(b]c).
Added a comment.

45

In the stripped code, which is what you'll feed to the compiler. Added a comment.

This revision was automatically updated to reflect the committed changes.
sammccall marked 2 inline comments as done.