Я использую это поле, потому что в поле комментария ограничено пространство.
Мне нравится эта особенность вложенных шаблонов, но я не могу сопоставить простой случай.Я попробовал следующие шаблоны:
visit(body) {
case \functionCall("methodA", [arg, *_]): println("match");
case \functionCall(SomeId("methodA", [arg, *_])): println("match");
case \functionCall(SomeId("methodA"), [arg, *_]): println("match");
case \functionCall(IdExpresssion("methodA", [arg, *_])): println("match");
case \functionCall(IdExpresssion("methodA"), [arg, *_]): println("match");
case \functionCall(name("methodA", [arg, *_])): println("match");
case \functionCall(name("methodA"), [arg, *_]): println("match");
}
iprint (body) дает следующие результаты:
compoundStatement(
[
compoundStatement(
[
expressionStatement(
.... some expressions and declarations
for(
... for statement
compoundStatement(
[
... inside for loop
expressionStatement(
functionCall(
idExpression(
name(
"methodA",
src=|project://Instrumentation/example.c|(11195,10)),
src=|project://Instrumentation/example.c|(11195,10),
decl=|cpp+problem://Attempt%20to%20use%20symbol%20failed:%20methodA|,
typ=problemType("Failure to determine type of expression")),
[equals(
idExpression(
name(
"beforeTest",
src=|project://Instrumentation/example.c|(11207,20)),
src=|project://Instrumentation/example.c|(11207,20),
decl=|cpp+variable:///test1()/beforeTest|,
typ=problemType("Type depends on an unresolved name")),
idExpression(
name(
"afterTest",
src=|project://Instrumentation/example.c|(11231,19)),
src=|project://Instrumentation/example.c|(11231,19),
decl=|cpp+variable:///test1()/afterTest|,
typ=problemType("Type depends on an unresolved name")),
src=|project://Instrumentation/example.c|(11207,43),
typ=problemType("Type depends on an unresolved name"))],
src=|project://Instrumentation/example.c|(11195,57),
typ=problemBinding()),
src=|project://Instrumentation/example.c|(11195,58)),
expressionStatement(
... more expressions and declaratios in for loop
],
src=|project://Instrumentation/example.c|(10148,1349))ok
Как создать шаблон, который соответствует MethodA?