https://ast-grep.github.io/playground.h ... xuICB9In0=
Test C++ code:
Код: Выделить всё
A::A()
: base::Class(a, b, c) {
a;
b;
c;
}
Код: Выделить всё
id: testbase_initializer
language: CPP
rule:
pattern:
selector: compound_statement
context: "A::A() : foo() { $$$BODYSTUFF }"
fix: |-
{
f();
$$$BODYSTUFF;
}
Код: Выделить всё
id: testbase_initializer
language: CPP
rule:
pattern:
selector: compound_statement
context: "A::A() : foo() { $$$BODYSTUFF }"
follows:
kind: field_initializer_list
has:
pattern:
selector: field_initializer
context: "A::A() : TestBase($NAME, $DETAILS, $ID) { }"
fix: |-
{
setName($NAME);
setId($ID);
$$$BODYSTUFF
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... n-compound