简体   繁体   English

如何保存Eclipse调用层次结构搜索?

[英]How to save Eclipse call hierarchy search?

I am using Eclipse and want to extract call hierarchies of two methods to see if their flows intersect. 我正在使用Eclipse,并希望提取两个方法的调用层次结构,以查看它们的流程是否相交。 What I'm currently doing is copying one method call hierarchy to a text editor and searching the other method call hierarchy for methods in the first call hierarchy. 我目前正在做的是将一个方法调用层次结构复制到文本编辑器,并在另一个方法调用层次结构中搜索第一个调用层次结构中的方法。

  1. Is there a way to save a call hierarchy, other then copy paste, so that it can be reloaded into the search window later? 有没有一种方法可以保存呼叫层次结构,而不是复制粘贴,以便以后可以将其重新加载到搜索窗口中?

  2. Is there another way to check call hierarchy intersections of existing Java code? 还有另一种方法来检查现有Java代码的调用层次结构交集吗? (Other tools maybe?) (也许还有其他工具?)

I'd separate your problem into 2 different tasks 我将您的问题分为2个不同的任务

  1. Get stack trace and save it 获取堆栈跟踪并保存
  2. Find intersections. 查找路口。

If you can change the code you are discovering you can just use code like new Throwable().printStackTrace(out) to get stack trace in the beginning of each interesting method. 如果您可以更改所发现的代码,则可以使用new Throwable().printStackTrace(out)类的代码在每个有趣方法的开头获取堆栈跟踪。 Save it to dedicated file and process later. 将其保存到专用文件中,然后再处理。

If you cannot (or do not want) change the code that is being discovered you can easily implement the same with AspectJ. 如果您不能(或不希望)更改被发现的代码,则可以使用AspectJ轻松实现相同的代码。 Recommendation: use dynamic weaving, it is easier and more flexible. 建议:使用动态编织,会更轻松,更灵活。

Now the second task: searching for intersections. 现在的第二项任务是:搜索路口。 Unfortunately I do not know standard tools, but it seems that it is not so difficult to implement this. 不幸的是,我不知道标准工具,但似乎很难实现这一点。 The implementation will depend on your requirements. 具体实施取决于您的要求。 If for example you just have to find the first common method in 2 stack traces the task is trivial. 例如,如果您只需要在2个堆栈跟踪中找到第一个通用方法,那么该任务就很简单了。 If however you need a real "diff" functionality you can use one of available java diff libraries. 但是,如果您需要真正的“差异”功能,则可以使用可用的Java差异库之一。 If personally found http://badiff.org/wiki/Badiff as a most flexible and well designed java diff library. 如果个人发现http://badiff.org/wiki/Badiff是最灵活且设计良好的Java diff库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM