[PATCH] D64391: [CodeComplete] an option to suppress endings for header completion

Cai Rijun via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 9 01:14:22 PDT 2019


richard9404 created this revision.
richard9404 added reviewers: sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous.
Herald added a project: clang.

Header completion in clang always apppends endings to the results, i.e. `/` for folders and `"` (or `>`) for files. But a language-neutral client (like many vim lsp plugins) does not know a subsequent completion is expected, while the auto-inserted `/` prevents the user from triggering one by manually typing a `/`. And `"`/`>` might collide with auto pair insertion in some clients.

  #include "f"
            ^ completion triggered here
         => folder/  <- client is not aware that another completion is expected
         => file.h"  <- '"' collides with the ending '"' inserted by the client

This commit adds an option to suppress the endings, and adds `/` as a completion trigger in clangd, which makes header completion more similar to object member completion. The downside is that clangd will not be able to distinguish folders from files when setting the completion item kinds.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64391

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/CodeCompleteOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/included-files-endings.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64391.208607.patch
Type: text/x-patch
Size: 10848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190709/ece1c72f/attachment-0001.bin>


More information about the cfe-commits mailing list