当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Eclipse Check for redundant method calls

问题描述:

I have a bunch of methods calling each other. The actual code is not important here, but here is an example:

void doStuff(){

doMoreStuff();

doEvenMoreStuff();

}

void doMoreStuff(){

doEvenMoreStuff();

}

void doEvenMoreStuff(){

// Do some stuff

}

As you can see, calling doStuff() causes doEvenMoreStuff() to be called twice. This isn't really a problem but it could help identify some problems and make my code cleaner. My question is, is there a way in Eclipse to check for things like this?

网友答案:

If you want to know from where all the method is being called then just highlight the method shortcut is

Windows : Ctl + Shift + g

Mac : Command + Shift + g

This will show you all the occurrences of the method call.

Also Eclipse gives you warning for unused methods but nothing about redundant method. Also this is not possible if the method is public since it can be used across files and it will be too complicated.

分享给朋友:
您可能感兴趣的文章:
随机阅读: