开发者

How can I extend the IntelliJ IDEA CE code evaluation feature?

I'm using IntelliJ IDEA Community Edition 10 to develop a Java SE project.

My app takes a long time to start, so my preferred way of debugging the code is Launch -> Stop at a breakpoint -> Open the code evaluation window -> type in some code and see what it returns.

But the problem arises when my code returns a large array/collection of objects. What I want is filter the objects by value of a field or some other criteria.

I could use Apache Commons Collections or Google Guava to do the filtering, but IntelliJ IDEA's code evaluation does not allow creation of anonymous classes on-the-fly, which I need to define Predicates.

I could also use lambdaJ, but the classes of objects in my huge collections are declared final (and I can't change that), so lambdaJ cannot extend these classes for its operation.

I also tried to use BeanShell, but it requires me to pass the code as a string, which kills IDEA's code-completion. Also bsh cannot make use of local variables inside the process being debugged. Lastly, I have to specify full class names every tim开发者_Python百科e.

Can anyone help to find a solution to this problem? It might be some magical way to extend the IntelliJ IDEA's code evaluation to support anonymous classes, or another way to filter collections which will work in this situation.


You could still use lambdaj by extending its features with your own Converters, Aggregators and Matchers as described here:

http://code.google.com/p/lambdaj/wiki/LambdajExtensibility


You can write you own methods to filter the results how you want. As long as they are compiled before you start debugging, they can be used in the evaluation. e.g.

 MyFilter.filter(result()).from(1).to(10) // etc
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜