Command-line tools, such as grep, sed, awkand perlallow you to perform the operation text search and replace.
However, is there any tool that will allow me to perform semantic search and replace operations in the Java codebase from the command line?
The Eclipse IDE allows me, for example, to easily rename a variable, field, method or class. But I would like to be able to do the same from the command line.
The renaming operation above is just one example. I would also like to be able to select replacement text with additional semantic restrictions, such as:
- only areas of methods M1, M2 of classes C, D and E;
- only all variables or fields of class C;
- all expressions in which a variable of a certain class appears;
- only the scope of the class of the variable;
- only areas of all overridden versions of method M of class C;
- and etc.
Having chosen the code using such arbitrary semantic restrictions, I would like to be able to perform arbitrary transformations on it.
So basically, I need access to the code symbol table.
Question:
- Is there an existing tool for this type of work, or do I need to create it myself?
- Even if I have to create it myself, create any tools or libraries that would at least provide me with a character table of Java code, on top of which I could add my own search and replace operations and other refactoring operations?