Changeset View
Changeset View
Standalone View
Standalone View
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
Show First 20 Lines • Show All 766 Lines • ▼ Show 20 Lines | )cpp", | ||||
static int $StaticField_decl_static[[staticField]]; | static int $StaticField_decl_static[[staticField]]; | ||||
}; | }; | ||||
template <typename $TemplateParameter_decl[[X]]> | template <typename $TemplateParameter_decl[[X]]> | ||||
void $Function_decl[[foo]]($TemplateParameter[[X]]& $Parameter_decl[[x]]) { | void $Function_decl[[foo]]($TemplateParameter[[X]]& $Parameter_decl[[x]]) { | ||||
// We do not support dependent types, so this one should *not* get the modifier. | // We do not support dependent types, so this one should *not* get the modifier. | ||||
$Function[[foo]]($Parameter[[x]]); | $Function[[foo]]($Parameter[[x]]); | ||||
} | } | ||||
)cpp", | )cpp", | ||||
// init-captures | |||||
R"cpp( | |||||
void $Function_decl[[foo]]() { | |||||
int $LocalVariable_decl[[a]], $LocalVariable_decl[[b]]; | |||||
[ $LocalVariable_decl[[c]] = $LocalVariable[[a]], | |||||
$LocalVariable_decl[[d]]($LocalVariable[[b]]) ]() {}(); | |||||
} | |||||
)cpp", | |||||
}; | }; | ||||
for (const auto &TestCase : TestCases) | for (const auto &TestCase : TestCases) | ||||
// Mask off scope modifiers to keep the tests manageable. | // Mask off scope modifiers to keep the tests manageable. | ||||
// They're tested separately. | // They're tested separately. | ||||
checkHighlightings(TestCase, {}, ~ScopeModifierMask); | checkHighlightings(TestCase, {}, ~ScopeModifierMask); | ||||
checkHighlightings(R"cpp( | checkHighlightings(R"cpp( | ||||
class $Class_decl[[A]] { | class $Class_decl[[A]] { | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | const char *TestCases[] = { | ||||
)cpp", | )cpp", | ||||
R"cpp( | R"cpp( | ||||
void $Function_globalScope[[foo]](int $Parameter_functionScope[[y]]) { | void $Function_globalScope[[foo]](int $Parameter_functionScope[[y]]) { | ||||
int $LocalVariable_functionScope[[z]]; | int $LocalVariable_functionScope[[z]]; | ||||
} | } | ||||
)cpp", | )cpp", | ||||
R"cpp( | R"cpp( | ||||
// Lambdas are considered functions, not classes. | // Lambdas are considered functions, not classes. | ||||
auto $Variable_fileScope[[x]] = [m(42)] { // FIXME: annotate capture | auto $Variable_fileScope[[x]] = [$LocalVariable_functionScope[[m]](42)] { | ||||
return $LocalVariable_functionScope[[m]]; | return $LocalVariable_functionScope[[m]]; | ||||
}; | }; | ||||
)cpp", | )cpp", | ||||
R"cpp( | R"cpp( | ||||
// Classes in functions are classes. | // Classes in functions are classes. | ||||
void $Function_globalScope[[foo]]() { | void $Function_globalScope[[foo]]() { | ||||
class $Class_functionScope[[X]] { | class $Class_functionScope[[X]] { | ||||
int $Field_classScope[[x]]; | int $Field_classScope[[x]]; | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |