Skip to content

Commit 01e830f

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 d044914 commit 01e830f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

+38
Original file line numberDiff line numberDiff line change
@@ -2338,6 +2338,44 @@ TEST(BlockEndHints, PointerToMemberFunction) {
23382338
ExpectedHint{" // if ()", "ptrmem"});
23392339
}
23402340

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

0 commit comments

Comments
 (0)