[PATCH] D41537: Optionally add code completion results for arrow instead of dot

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 3 01:59:13 PDT 2018


ilya-biryukov added a comment.

Sorry for the late response, was on vacation.



================
Comment at: include/clang/Sema/CodeCompleteConsumer.h:565
+  /// \brief For this completion result correction is required.
+  Optional<std::string> Corr = None;
+
----------------
yvvan wrote:
> yvvan wrote:
> > ilya-biryukov wrote:
> > > Having a string replacement without an actual range to replace still moves a lot of responsibility onto the clients. We should probably model corrections after the fix-its for diagnostics:
> > > - replacements need to provide a range to be replaced, alongside with a text for the replacement,
> > > - we should provide a list of edits to allow corrections that touch two separate pieces of code.
> > > 
> > > For the fix-its in the diagnostics, see [[https://reviews.llvm.org/source/clang/browse/cfe/trunk/tools/libclang/CXLoadedDiagnostic.h;327861$84 | CXLoadedDiagnostic.h]] for an interface exported via libclang and [[https://reviews.llvm.org/source/clang/browse/cfe/trunk/include/clang/Basic/Diagnostic.h;327861$947|Diagnostic.h]] for an interface exported in C++ API.
> > > WDYT?
> > I thought that fixits always exist separately from diagnostics. I will check this out, thanks.
> I've looked  into diagnostics and realized that i already use them here but the are just not forwarded to completion results which is of source possible.
> 
> I have a draft with Optional<FixItHint> instead of Optional<std::string>
> It allows to use further both string and replaced/removed range and also mostly uses the same code as already provided in this patch since I already generated FixItHint for Diagnostics (line 4117 lib/Sema/SemaCodeComplete.cpp in this patch)
> 
> Is that fine with you?
Sounds good. 
One caveat is that we should probably go with `std::vector<FixItHint>` instead of `Optional<FixItHint>`. This would mirror what `clang::Diagnostic` does.
"Dot to arrow" will only ever add one element there, but more intricate fixes might require more than a single edit.


https://reviews.llvm.org/D41537





More information about the cfe-commits mailing list