CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
91 lines
2.7 KiB
C++
91 lines
2.7 KiB
C++
//===--- Annotations.cpp - Annotated source code for unit tests --*- C++-*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "Annotations.h"
|
|
#include "SourceCode.h"
|
|
|
|
namespace clang {
|
|
namespace clangd {
|
|
|
|
Position Annotations::point(llvm::StringRef Name) const {
|
|
return pointWithPayload(Name).first;
|
|
}
|
|
|
|
std::pair<Position, llvm::StringRef>
|
|
Annotations::pointWithPayload(llvm::StringRef Name) const {
|
|
auto [BasePoint, Payload] = Base::pointWithPayload(Name);
|
|
return {offsetToPosition(code(), BasePoint), Payload};
|
|
}
|
|
|
|
std::vector<Position> Annotations::points(llvm::StringRef Name) const {
|
|
auto BasePoints = Base::points(Name);
|
|
|
|
std::vector<Position> Ps;
|
|
Ps.reserve(BasePoints.size());
|
|
for (const auto Point : BasePoints)
|
|
Ps.push_back(offsetToPosition(code(), Point));
|
|
|
|
return Ps;
|
|
}
|
|
|
|
std::vector<std::pair<Position, llvm::StringRef>>
|
|
Annotations::pointsWithPayload(llvm::StringRef Name) const {
|
|
auto BasePoints = Base::pointsWithPayload(Name);
|
|
|
|
std::vector<std::pair<Position, llvm::StringRef>> Ps;
|
|
Ps.reserve(BasePoints.size());
|
|
for (const auto &[Point, Payload] : BasePoints)
|
|
Ps.push_back({offsetToPosition(code(), Point), Payload});
|
|
|
|
return Ps;
|
|
}
|
|
|
|
static clangd::Range toLSPRange(llvm::StringRef Code,
|
|
llvm::Annotations::Range R) {
|
|
clangd::Range LSPRange;
|
|
LSPRange.start = offsetToPosition(Code, R.Begin);
|
|
LSPRange.end = offsetToPosition(Code, R.End);
|
|
return LSPRange;
|
|
}
|
|
|
|
Range Annotations::range(llvm::StringRef Name) const {
|
|
return rangeWithPayload(Name).first;
|
|
}
|
|
|
|
std::pair<clangd::Range, llvm::StringRef>
|
|
Annotations::rangeWithPayload(llvm::StringRef Name) const {
|
|
auto [BaseRange, Payload] = Base::rangeWithPayload(Name);
|
|
return {toLSPRange(code(), BaseRange), Payload};
|
|
}
|
|
|
|
std::vector<Range> Annotations::ranges(llvm::StringRef Name) const {
|
|
auto OffsetRanges = Base::ranges(Name);
|
|
|
|
std::vector<clangd::Range> Rs;
|
|
Rs.reserve(OffsetRanges.size());
|
|
for (const auto &R : OffsetRanges)
|
|
Rs.push_back(toLSPRange(code(), R));
|
|
|
|
return Rs;
|
|
}
|
|
|
|
std::vector<std::pair<clangd::Range, llvm::StringRef>>
|
|
Annotations::rangesWithPayload(llvm::StringRef Name) const {
|
|
auto OffsetRanges = Base::rangesWithPayload(Name);
|
|
|
|
std::vector<std::pair<clangd::Range, llvm::StringRef>> Rs;
|
|
Rs.reserve(OffsetRanges.size());
|
|
for (const auto &[R, Payload] : OffsetRanges)
|
|
Rs.push_back({toLSPRange(code(), R), Payload});
|
|
|
|
return Rs;
|
|
}
|
|
|
|
} // namespace clangd
|
|
} // namespace clang
|