diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2019-03-27 17:47:49 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2019-03-27 17:47:49 +0000 |
| commit | a69698f45fadefd2cabba8d5aa1a8e93463a6d49 (patch) | |
| tree | 4052f9f6efd3a86a95ca6f019328d6b8ac0f50f5 /clang-tools-extra/clangd/index | |
| parent | 381188f1f39ea8980c23aecb3a0695425aaa99cc (diff) | |
| download | bcm5719-llvm-a69698f45fadefd2cabba8d5aa1a8e93463a6d49.tar.gz bcm5719-llvm-a69698f45fadefd2cabba8d5aa1a8e93463a6d49.zip | |
[clangd] Support utf-8 offsets (rather than utf-16) as a protocol extension
Summary:
Still some pieces to go here: unit tests for new SourceCode functionality and
a command-line flag to force utf-8 mode. But wanted to get early feedback.
Reviewers: hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D58275
llvm-svn: 357102
Diffstat (limited to 'clang-tools-extra/clangd/index')
| -rw-r--r-- | clang-tools-extra/clangd/index/IndexAction.cpp | 1 | ||||
| -rw-r--r-- | clang-tools-extra/clangd/index/SymbolLocation.h | 10 |
2 files changed, 8 insertions, 3 deletions
diff --git a/clang-tools-extra/clangd/index/IndexAction.cpp b/clang-tools-extra/clangd/index/IndexAction.cpp index 61db161bd5b..bda2cf44a58 100644 --- a/clang-tools-extra/clangd/index/IndexAction.cpp +++ b/clang-tools-extra/clangd/index/IndexAction.cpp @@ -9,7 +9,6 @@ #include "IndexAction.h" #include "index/SymbolOrigin.h" #include "clang/Frontend/CompilerInstance.h" -#include "clang/Index/IndexDataConsumer.h" #include "clang/Index/IndexingAction.h" #include "clang/Tooling/Tooling.h" diff --git a/clang-tools-extra/clangd/index/SymbolLocation.h b/clang-tools-extra/clangd/index/SymbolLocation.h index f1b7ffd5e0b..9b503546a9f 100644 --- a/clang-tools-extra/clangd/index/SymbolLocation.h +++ b/clang-tools-extra/clangd/index/SymbolLocation.h @@ -20,6 +20,13 @@ struct SymbolLocation { // Specify a position (Line, Column) of symbol. Using Line/Column allows us to // build LSP responses without reading the file content. // + // clangd uses the following definitions, which differ slightly from LSP: + // - Line is the number of newline characters (\n) before the point. + // - Column is (by default) the number of UTF-16 code between the last \n + // (or start of file) and the point. + // If the `offsetEncoding` protocol extension is used to negotiate UTF-8, + // then it is instead the number of *bytes* since the last \n. + // // Position is encoded into 32 bits to save space. // If Line/Column overflow, the value will be their maximum value. struct Position { @@ -37,8 +44,7 @@ struct SymbolLocation { static constexpr uint32_t MaxColumn = (1 << 12) - 1; private: - uint32_t Line : 20; // 0-based - // Using UTF-16 code units. + uint32_t Line : 20; // 0-based uint32_t Column : 12; // 0-based }; |

