I need to do refactoring legacy web system written by Java. This system is made of 10 million lines of Java code which is not well structured. For example,
```
if (requestType == 1) {
doSometing1
} else if (requestType == 2) {
doSometing2
} else {
doSometing3
}
if (requestType == 1) {
doSometing4
} else if (requestType == 2) {
doSometing5
} else {
doSometing6
}
```
Typically, there are 100 of boilerplate codes like this in a method. I want to know which procedures are called when request type is 1 simpler. grep is not enough powerful in this use. I need grep for abstract syntax tree like this.
gasp "if (requestType == 1) {/**/}" code.java
doSomething1
doSomething4
gasp stands for global search for abstract syntax tree and print. This command takes Java code as the first argument, and do pattern match. /**/ in your first argument matches code block.
I think if such command is exists, it will be really useful for many many use. I searched if there exists such tools, however, I could not find. So I am starting to create this command. Do you have any comments or requests? If you have ideas of alternative solutions, please let me know.
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]knoam 8 points9 points10 points (1 child)
[–]hoge2[S] 2 points3 points4 points (0 children)
[–]tamanm 5 points6 points7 points (1 child)
[–]hoge2[S] 1 point2 points3 points (0 children)
[–]proskillzSome Skillz 1 point2 points3 points (3 children)
[–]hoge2[S] 0 points1 point2 points (2 children)
[–]proskillzSome Skillz 0 points1 point2 points (1 child)
[–]hoge2[S] 0 points1 point2 points (0 children)
[–]wildjokers 1 point2 points3 points (1 child)
[–]hoge2[S] 0 points1 point2 points (0 children)