Skip to content

Commit 0002acd

Browse files
authored
Merge pull request DeusData#2090 from sanskar717/feat/solidity-support
fix(lang): track Solidity modifier invocations as decorators
2 parents 442989e + e2c9de1 commit 0002acd

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎internal/cbm/lang_specs.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ static const char *solidity_field_types[] = {"state_variable_declaration", "stru
10391039
static const char *solidity_call_types[] = {"call_expression", "call", "new_expression", NULL};
10401040
static const char *solidity_import_types[] = {"import_directive", "import", "using_directive",
10411041
NULL};
1042+
static const char *solidity_decorator_types[] = {"modifier_invocation", NULL};
10421043
static const char *solidity_branch_types[] = {"if_statement", "for_statement",
10431044
"while_statement", "do_while_statement",
10441045
"try_statement", NULL};
@@ -2116,7 +2117,7 @@ static const CBMLangSpec lang_specs[CBM_LANG_COUNT] = {
21162117
solidity_field_types, solidity_module_types, solidity_call_types,
21172118
solidity_import_types, empty_types, solidity_branch_types,
21182119
solidity_var_types, solidity_assign_types, solidity_throw_types, NULL,
2119-
empty_types, NULL, NULL, tree_sitter_solidity, NULL},
2120+
solidity_decorator_types, NULL, NULL, tree_sitter_solidity, NULL},
21202121

21212122
// CBM_LANG_TYPST
21222123
[CBM_LANG_TYPST] = {CBM_LANG_TYPST, typst_func_types, empty_types, empty_types,

‎tests/test_extraction.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5428,6 +5428,24 @@ TEST(extract_python_bare_decorator_route_rules) {
54285428
PASS();
54295429
}
54305430

5431+
/* Issue #2090: Solidity modifier_invocation tracked as decorator. */
5432+
TEST(solidity_modifier_decorator) {
5433+
CBMFileResult *r = extract("pragma solidity ^0.8.0;\n"
5434+
"contract Vault {\n"
5435+
" modifier onlyOwner() { _; }\n"
5436+
" function withdraw() public onlyOwner {\n"
5437+
" }\n"
5438+
"}\n",
5439+
CBM_LANG_SOLIDITY, "t", "Vault.sol");
5440+
ASSERT_NOT_NULL(r);
5441+
ASSERT_FALSE(r->has_error);
5442+
const CBMDefinition *m = find_def_by_name(r, "withdraw");
5443+
ASSERT_NOT_NULL(m);
5444+
ASSERT(decorators_contain(m, "onlyOwner"));
5445+
cbm_free_result(r);
5446+
PASS();
5447+
}
5448+
54315449
/* ── ArkTS (HarmonyOS .ets) ─────────────────────────────────────── */
54325450

54335451
TEST(arkts_component_struct) {
@@ -13712,6 +13730,7 @@ SUITE(extraction) {
1371213730
RUN_TEST(extract_java_method_annotations_issue382);
1371313731
RUN_TEST(extract_python_mock_patch_is_not_route);
1371413732
RUN_TEST(extract_python_bare_decorator_route_rules);
13733+
RUN_TEST(solidity_modifier_decorator);
1371513734
RUN_TEST(arkts_component_struct);
1371613735
RUN_TEST(arkts_exported_struct_decorators);
1371713736
RUN_TEST(arkts_member_decorators);

0 commit comments

Comments
 (0)