[PATCH] D44408: Move DraftMgr from ClangdServer to ClangdLSPServer

Simon Marchi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 12 18:13:56 PDT 2018


simark created this revision.
Herald added subscribers: cfe-commits, ioeric, jkorous-apple, ilya-biryukov, mgorny, klimek.

This patch moves the draft manager closer to the edge of Clangd, from
ClangdServer to ClangdLSPServer.  This will make it easier to implement
incremental document sync, by making ClangdServer only deal with
complete documents.

As a result, DraftStore doesn't have to deal with versioning, and thus
its API can be simplified.  It is replaced by a StringMap in
ClangdServer holding a current version number for each file.

The current implementation of reparseOpenedFiles is racy.  It calls
getActiveDrafts and calls forceReparse for each of them.  forceReparse
gets the draft fromt he DraftStore.  In theory, it's possible for a file
to have been closed in the mean time.  I replaced getActiveDrafts by
forEachActiveDraft.  It has the advantage that the DraftStore lock is
held while we iterate on the drafts.

Signed-off-by: Simon Marchi <simon.marchi at ericsson.com>


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44408

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/DraftStore.cpp
  clangd/DraftStore.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/DraftStoreTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44408.138119.patch
Type: text/x-patch
Size: 37798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180313/2e803454/attachment-0001.bin>


More information about the cfe-commits mailing list