summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Protocol.h
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-03-27 17:47:49 +0000
committerSam McCall <sam.mccall@gmail.com>2019-03-27 17:47:49 +0000
commita69698f45fadefd2cabba8d5aa1a8e93463a6d49 (patch)
tree4052f9f6efd3a86a95ca6f019328d6b8ac0f50f5 /clang-tools-extra/clangd/Protocol.h
parent381188f1f39ea8980c23aecb3a0695425aaa99cc (diff)
downloadbcm5719-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/Protocol.h')
-rw-r--r--clang-tools-extra/clangd/Protocol.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h
index 468ead8df17..7cf414123f1 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -338,6 +338,18 @@ SymbolKind adjustKindToCapability(SymbolKind Kind,
// https://github.com/Microsoft/language-server-protocol/issues/344
SymbolKind indexSymbolKindToSymbolKind(index::SymbolKind Kind);
+// Determines the encoding used to measure offsets and lengths of source in LSP.
+enum class OffsetEncoding {
+ // Any string is legal on the wire. Unrecognized encodings parse as this.
+ UnsupportedEncoding,
+ // Length counts code units of UTF-16 encoded text. (Standard LSP behavior).
+ UTF16,
+ // Length counts bytes of UTF-8 encoded text. (Clangd extension).
+ UTF8,
+};
+llvm::json::Value toJSON(const OffsetEncoding &);
+bool fromJSON(const llvm::json::Value &, OffsetEncoding &);
+
// This struct doesn't mirror LSP!
// The protocol defines deeply nested structures for client capabilities.
// Instead of mapping them all, this just parses out the bits we care about.
@@ -369,6 +381,9 @@ struct ClientCapabilities {
/// Client supports CodeAction return value for textDocument/codeAction.
/// textDocument.codeAction.codeActionLiteralSupport.
bool CodeActionStructure = false;
+
+ /// Supported encodings for LSP character offsets. (clangd extension).
+ llvm::Optional<std::vector<OffsetEncoding>> offsetEncoding;
};
bool fromJSON(const llvm::json::Value &, ClientCapabilities &);
OpenPOWER on IntegriCloud