diff options
author | Michael Forster <forster@google.com> | 2019-12-12 14:30:02 +0100 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2019-12-12 14:55:20 +0100 |
commit | d6417f5584aa7673fa0212029a96cc9cacb1aad5 (patch) | |
tree | 3f42ba6020a54e4387f64b5d33c4077c1ca423c4 /clang-tools-extra/clangd/Protocol.h | |
parent | 9c8cfa09d762a307bae55b75b621cbc53f4a3b3b (diff) | |
download | bcm5719-llvm-d6417f5584aa7673fa0212029a96cc9cacb1aad5.tar.gz bcm5719-llvm-d6417f5584aa7673fa0212029a96cc9cacb1aad5.zip |
[clangd] Implement "textDocument/documentLink" protocol support
Summary:
This adds an implementation for the "textDocument/documentLink" LSP request.
It returns links for all `#include` directives to the resolved target files.
Fixes https://github.com/clangd/clangd/issues/217.
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70872
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.h')
-rw-r--r-- | clang-tools-extra/clangd/Protocol.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h index f110292b091..1ccfa587bf8 100644 --- a/clang-tools-extra/clangd/Protocol.h +++ b/clang-tools-extra/clangd/Protocol.h @@ -1250,6 +1250,39 @@ struct SelectionRange { }; llvm::json::Value toJSON(const SelectionRange &); +/// Parameters for the document link request. +struct DocumentLinkParams { + /// The document to provide document links for. + TextDocumentIdentifier textDocument; +}; +bool fromJSON(const llvm::json::Value &, DocumentLinkParams &); + +/// A range in a text document that links to an internal or external resource, +/// like another text document or a web site. +struct DocumentLink { + /// The range this link applies to. + Range range; + + /// The uri this link points to. If missing a resolve request is sent later. + URIForFile target; + + // TODO(forster): The following optional fields defined by the language + // server protocol are unsupported: + // + // data?: any - A data entry field that is preserved on a document link + // between a DocumentLinkRequest and a + // DocumentLinkResolveRequest. + + friend bool operator==(const DocumentLink &LHS, const DocumentLink &RHS) { + return LHS.range == RHS.range && LHS.target == RHS.target; + } + + friend bool operator!=(const DocumentLink &LHS, const DocumentLink &RHS) { + return !(LHS == RHS); + } +}; +llvm::json::Value toJSON(const DocumentLink &DocumentLink); + } // namespace clangd } // namespace clang |