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

Nikolai Kosjar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 6 03:28:26 PDT 2018


nik requested changes to this revision.
nik added inline comments.
This revision now requires changes to proceed.


================
Comment at: include/clang-c/Index.h:5264
+ * FixIts that *must* be applied before inserting the text for the
+ * corresponding completion item.
+ *
----------------
yvvan wrote:
> nik wrote:
> > * Please use proper documentation style, e.g. make use of "\brief", "\param", "\returns". Currently one has to somewhat guess that the returned string is related to the replacement_range parameter.
> > 
> > * Is this a behavior change now? What happens to old code not aware of this function?
> '\brief' is not used anymore.
> 
> > Is this a behavior change now?
> 
> No, without CXCodeComplete_IncludeFixIts set you won't event have extra completions. And existing ones won't get any fix-its (because why would they?)
Still \param and \returns are useful since there the range is an output argument.


================
Comment at: include/clang-c/Index.h:4747
+ * Tokenize the source code starting with the given location into raw lexical
+ * token.
+ *
----------------
"Tokenize the source code" sounds as if more than one token will be handled.

Suggestion: Reduce to "Get the raw lexical token starting with the given location".


================
Comment at: include/clang-c/Index.h:5256
 /**
+ * Retrieve the number of fix-its for the given completion index.
+ */
----------------
Indicate that calling this makes only sense if CXCodeComplete_IncludeFixIts was set.


================
Comment at: include/clang-c/Index.h:5266
+ *
+ * Only completion items with empty fixits will be returned by default.
+ * Extra completion items with non-empty fixits should be explicitly requested
----------------
Clarify that you refer to clang_codeCompleteAt here.

Suggestion: By default, clang_codeCompleteAt()....


================
Comment at: include/clang-c/Index.h:5268
+ * Extra completion items with non-empty fixits should be explicitly requested
+ * by setting CXCodeComplete_IncludeFixIts. For the clients to be able to
+ * compute position of the cursor for the completion item itself, the following
----------------
Add empty line before "For the client..." for readability.


================
Comment at: include/clang-c/Index.h:5269
+ * by setting CXCodeComplete_IncludeFixIts. For the clients to be able to
+ * compute position of the cursor for the completion item itself, the following
+ * conditions are guaranteed to hold for replacement_range of the stored fixits:
----------------
...of the cursor after applying the fixits


================
Comment at: include/clang-c/Index.h:5277
+ *  least one character. It allows to unambiguously recompute completion
+ *  point after applying the fixit.
+ * The intuition is that provided fixits change code around the identifier we
----------------
new line


================
Comment at: include/clang-c/Index.h:5281
+ * completion point. One example of completion items with corrections are the
+ * ones replacing '.' with '->' and vice versa:
+ * std::unique_ptr<std::vector<int>> vec_ptr;
----------------
new line


================
Comment at: include/clang-c/Index.h:5283
+ * std::unique_ptr<std::vector<int>> vec_ptr;
+ * In 'vec_ptr.^', one of completion items is 'push_back', it requires
+ * replacing '.' with '->'.
----------------
"one of the ...", same below.


================
Comment at: include/clang-c/Index.h:5329
+   */
+  CXCodeComplete_IncludeFixIts = 0x10
 };
----------------
Suggestion: CXCodeComplete_IncludeCompletionsWithFixIts 


https://reviews.llvm.org/D46862





More information about the cfe-commits mailing list