forked from OSchip/llvm-project
[libTooling] Rename overloaded `range` range selector.
Renames the overloaded `RangeSelector` combinator `range` to the more descriptive `enclose` and `encloseNodes`. The old overloads are left in place and marked deprected and will be deleted at a future time. Reviewed By: tdl-g Differential Revision: https://reviews.llvm.org/D82592
This commit is contained in:
parent
1507fc1506
commit
056a539e57
|
@ -32,10 +32,20 @@ inline RangeSelector charRange(CharSourceRange R) {
|
|||
}
|
||||
|
||||
/// Selects from the start of \p Begin and to the end of \p End.
|
||||
RangeSelector range(RangeSelector Begin, RangeSelector End);
|
||||
RangeSelector enclose(RangeSelector Begin, RangeSelector End);
|
||||
|
||||
/// Convenience version of \c range where end-points are bound nodes.
|
||||
RangeSelector range(std::string BeginID, std::string EndID);
|
||||
RangeSelector encloseNodes(std::string BeginID, std::string EndID);
|
||||
|
||||
/// DEPRECATED. Use `enclose`.
|
||||
inline RangeSelector range(RangeSelector Begin, RangeSelector End) {
|
||||
return enclose(std::move(Begin), std::move(End));
|
||||
}
|
||||
|
||||
/// DEPRECATED. Use `encloseNodes`.
|
||||
inline RangeSelector range(std::string BeginID, std::string EndID) {
|
||||
return encloseNodes(std::move(BeginID), std::move(EndID));
|
||||
}
|
||||
|
||||
/// Selects the (empty) range [B,B) when \p Selector selects the range [B,E).
|
||||
RangeSelector before(RangeSelector Selector);
|
||||
|
|
|
@ -146,7 +146,7 @@ RangeSelector transformer::statement(std::string ID) {
|
|||
};
|
||||
}
|
||||
|
||||
RangeSelector transformer::range(RangeSelector Begin, RangeSelector End) {
|
||||
RangeSelector transformer::enclose(RangeSelector Begin, RangeSelector End) {
|
||||
return [Begin, End](const MatchResult &Result) -> Expected<CharSourceRange> {
|
||||
Expected<CharSourceRange> BeginRange = Begin(Result);
|
||||
if (!BeginRange)
|
||||
|
@ -165,8 +165,9 @@ RangeSelector transformer::range(RangeSelector Begin, RangeSelector End) {
|
|||
};
|
||||
}
|
||||
|
||||
RangeSelector transformer::range(std::string BeginID, std::string EndID) {
|
||||
return transformer::range(node(std::move(BeginID)), node(std::move(EndID)));
|
||||
RangeSelector transformer::encloseNodes(std::string BeginID,
|
||||
std::string EndID) {
|
||||
return transformer::enclose(node(std::move(BeginID)), node(std::move(EndID)));
|
||||
}
|
||||
|
||||
RangeSelector transformer::member(std::string ID) {
|
||||
|
|
|
@ -201,7 +201,7 @@ TEST(RangeSelectorTest, RangeOpNodes) {
|
|||
)cc";
|
||||
auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
|
||||
hasArgument(1, expr().bind("a1")));
|
||||
RangeSelector R = range("a0", "a1");
|
||||
RangeSelector R = encloseNodes("a0", "a1");
|
||||
TestMatch Match = matchCode(Code, Matcher);
|
||||
EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ TEST(RangeSelectorTest, RangeOpGeneral) {
|
|||
)cc";
|
||||
auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
|
||||
hasArgument(1, expr().bind("a1")));
|
||||
RangeSelector R = range(node("a0"), node("a1"));
|
||||
RangeSelector R = enclose(node("a0"), node("a1"));
|
||||
TestMatch Match = matchCode(Code, Matcher);
|
||||
EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue