是否有一系列 IntelliJ 自动重构可以消除多余的类 Foo?
重构前:
public static class Foo {
private final String s;
public Foo(String s) {
this.s = s;
}
public String getS() {
return s;
}
}
private static void run() {
Foo f = new Foo("blah");
f.getS().length();
f.getS().getBytes();
Foo f2 = new Foo("blahg");
f2.getS().length();
f2.getS().getBytes();
}
重构后:
private static void run() {
String f = "blah";
f.length();
f.getBytes();
String f2 = new "blahg";
f2.length();
f2.getBytes();
}
在我的具体案例中进行自动重构的原因是现实生活中 Foo 被使用了几千次。但我也只是感兴趣。使用其他自动化步骤将代理对象获取到 Foo 的状态非常容易,但我只是不知道如何进行最后一点。
爪哇intellij-idea重构自动重构
慕神8447489
慕仙森
相关分类