Port SelectionTree from clangd to clice (#166)
This commit is contained in:
@@ -1,8 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "SourceLocation.h"
|
||||
#include <tuple>
|
||||
#include "clang/Lex/Token.h"
|
||||
#include "llvm/ADT/FunctionExtras.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct tuple_size<clang::SourceRange> : std::integral_constant<std::size_t, 2> {};
|
||||
|
||||
template <>
|
||||
struct tuple_element<0, clang::SourceRange> {
|
||||
using type = clang::SourceLocation;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct tuple_element<1, clang::SourceRange> {
|
||||
using type = clang::SourceLocation;
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
namespace clang {
|
||||
|
||||
/// Through ADL, make `clang::SourceRange` could be destructured.
|
||||
template <std::size_t I>
|
||||
clang::SourceLocation get(clang::SourceRange range) {
|
||||
if constexpr(I == 0) {
|
||||
return range.getBegin();
|
||||
} else {
|
||||
return range.getEnd();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace clang
|
||||
|
||||
namespace clice {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user