1//===--- Annotations.h - Annotated source code for tests ---------*- C++-*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8// A clangd-specific version of llvm/Testing/Annotations/Annotations.h, replaces
9// offsets and offset-based ranges with types from the LSP protocol.
10//===---------------------------------------------------------------------===//
11
12#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_ANNOTATIONS_H
13#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_ANNOTATIONS_H
14
15#include "Protocol.h"
16#include "llvm/Testing/Annotations/Annotations.h"
17
18namespace clang {
19namespace clangd {
20
21/// Same as llvm::Annotations, but adjusts functions to LSP-specific types for
22/// positions and ranges.
23class Annotations : public llvm::Annotations {
24 using Base = llvm::Annotations;
25
26public:
27 using llvm::Annotations::Annotations;
28
29 Position point(llvm::StringRef Name = "") const;
30 std::pair<Position, llvm::StringRef>
31 pointWithPayload(llvm::StringRef Name = "") const;
32 std::vector<Position> points(llvm::StringRef Name = "") const;
33 std::vector<std::pair<Position, llvm::StringRef>>
34 pointsWithPayload(llvm::StringRef Name = "") const;
35
36 clangd::Range range(llvm::StringRef Name = "") const;
37 std::pair<clangd::Range, llvm::StringRef>
38 rangeWithPayload(llvm::StringRef Name = "") const;
39 std::vector<clangd::Range> ranges(llvm::StringRef Name = "") const;
40 std::vector<std::pair<clangd::Range, llvm::StringRef>>
41 rangesWithPayload(llvm::StringRef Name = "") const;
42};
43
44} // namespace clangd
45} // namespace clang
46
47#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_ANNOTATIONS_H
48

source code of clang-tools-extra/clangd/unittests/Annotations.h