Structural Search Replace
This is a little complicated, and I'm not sure structural search replace will accomplish what I'm after but I'm hopeful.
given this class:
abstract class A {
static String getValue();
}
What I want to do is, for all usages of A.getValue() which are part of a variable assignment, inline that variable. I'm not sure that's clear, here's an example:
this:
class foo {
private String aValue;
void bar() {
aValue = A.getValue();
System.out.println(aValue);
}
void bar2() {
System.out.println(aValue);
}
}
becomes:
class foo {
void bar() {
System.out.println(A.getValue());
}
void bar2() {
System.out.println(A.getValue());
}
}
I want to do this for all types of variables (class, instance, local), so likewise:
this:
class foo {
void bar() {
String aValue = A.getValue();
System.out.println(aValue);
}
}
becomes:
class foo {
void bar() {
System.out.println(A.getValue());
}
}
and, this:
class foo {
private static String aValue;
void bar() {
aValue = A.getValue();
System.out.println(aValue);
}
}
void bar2() {
System.out.println(aValue);
}
}
becomes:
class foo {
void bar() {
System.out.println(A.getValue());
}
void bar2() {
System.out.println(A.getValue());
}
}
Is this even possible?
请先登录再写评论。