将链式方法调用与结构化搜索相匹配 [英] Matching chained method calls with structural search

查看:113
本文介绍了将链式方法调用与结构化搜索相匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试匹配一些流利的API的这种方法调用.可以有任意数量的方法调用(至少2个调用,但没有上限).整个表达式应该匹配.实际上,目标是在省略doIt()的流利api中找到链接方法调用,因为在这种情况下,流利API不执行任何操作.

I try to match this kind of method calls of some fluent API. There can be an arbitrary number of method calls (at least 2 calls, but no upper limit). The whole expression should be matched. Actually, the goal is to find chained method calls in a fluent api which omit doIt(), as in this case the fluent API does nothing.

FooClass.some("fluent")
        .api()
        .bar(()->"somelambda")
        .doIt();

我尝试过类似的事情

FooClass.$a$($b$) 

,并使用不同的出现次数",例如0,∞表示$a$0,1表示$b$,但这仍然只匹配FooClass.some("fluent")

and use different "occurence counts" like 0,∞ for $a$, and 0,1 for $b$, but this still only matches FooClass.some("fluent")

推荐答案

假设所有流利的api方法都返回FooClass的实例,则下面的方法应该起作用. 从现有的模板方法调用开始,并添加分号来搜索语句:

Assuming all the fluent api methods return an instance of FooClass, the following should work. Start with the existing template method calls and add a semicolon to search for statements:

$Instance$.$MethodCall$($Parameter$);

点击修改变量:

  1. 实例Expression type设置为FooClass
  2. MethodCall Text/Regexp设置为doit并启用Invert condition
  1. set Expression type of Instance to FooClass
  2. set Text/Regexp of MethodCall to doit and enable Invert condition

这篇关于将链式方法调用与结构化搜索相匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆