Skip to content

Commit 026e93c

Browse files
committed
Add BlockEndHints.MinLineLimit test
Add a new test `MinLineLimit` that ensures hints are generated only when the line threshold is met. Limit is set through `InlayHintOptions.HintMinLineLimit`
1 parent 77230a2 commit 026e93c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,44 @@ TEST(BlockEndHints, PointerToMemberFunction) {
23392339
ExpectedHint{" // if ()", "ptrmem"});
23402340
}
23412341

2342+
TEST(BlockEndHints, MinLineLimit) {
2343+
assertBlockEndHintsWithOpts(
2344+
R"cpp(
2345+
namespace ns {
2346+
int Var;
2347+
int func1();
2348+
int func2(int, int);
2349+
struct S {
2350+
int Field;
2351+
int method1() const;
2352+
int method2(int, int) const;
2353+
$struct[[}]];
2354+
$namespace[[}]]
2355+
void foo() {
2356+
int int_a {};
2357+
while (ns::Var) {
2358+
$var[[}]]
2359+
2360+
while (ns::func1()) {
2361+
$func1[[}]]
2362+
2363+
while (ns::func2(int_a, int_a)) {
2364+
$func2[[}]]
2365+
2366+
while (ns::S{}.Field) {
2367+
$field[[}]]
2368+
2369+
while (ns::S{}.method1()) {
2370+
$method1[[}]]
2371+
2372+
while (ns::S{}.method2(int_a, int_a)) {
2373+
$method2[[}]]
2374+
$foo[[}]]
2375+
)cpp",
2376+
InlayHintOptions{10}, ExpectedHint{" // namespace ns", "namespace"},
2377+
ExpectedHint{" // foo", "foo"});
2378+
}
2379+
23422380
// FIXME: Low-hanging fruit where we could omit a type hint:
23432381
// - auto x = TypeName(...);
23442382
// - auto x = (TypeName) (...);

0 commit comments

Comments
 (0)