我使用此字段,因为评论字段中的空间有限。
我喜欢嵌套模式的这个特性,但我没有得到匹配的简单大小写。我尝试了以下模式:
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 匹配的模式?