[PATCH] D63098: [CodeComplete] Allow completing enum values within case statements, and insert 'case' as a fixit.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 10 14:14:29 PDT 2019


sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There are a few alternative ways to expose this.
The most obvious is a RK_Pattern, but it seems to have some triggering problems.
Consider a completion "case Color::Red"

- we want the user input to match Red
- we *don't* want the user input to match Color::
- if "case" is displayed, users will expect to be able to match it.

It's not possible to satisfy all of these:

- [TypedText:case] [Text:Color::][TypedText:Red] has a bad getTypedText()
- [Text:case] [Text:Color::][TypedText:Red] shows "case" but you can't type it
- [TypedText:case Color::TypedText:Red] will match against the qualifier

(I suspect the third is the least bad here)

The option explored here is to provide a regular Declaration completion, but
with "case" inserted as a fix-it. This results in "case" being neither displayed
or matched, but inserted. (If the user types "case", the existing completions
kick in.)

Curious what you think. I'm biased as I'm working on an integration that
supports fixits but not patterns :-)


Repository:
  rC Clang

https://reviews.llvm.org/D63098

Files:
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/enum-switch-case.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63098.203898.patch
Type: text/x-patch
Size: 9882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190610/29836926/attachment.bin>


More information about the cfe-commits mailing list