Reputation: 116
Currently, I am working on research about refactoring tasks and its prioritization. I need to examine effects of each task (for example, move method, extract method, delete method) and to do some calculation on class and project level.
What is the best way of approaching these tasks manually, on code level?
I was thinking on building Eclipse plugin on top of its main application that open refactor menu and do refactoring tasks, but it doesn't seem good method, I need closer relation to code of each class.
Other way, I was thinking to build a plugin that parses each class and its references and does ref. tasks while parsing? This approach seems more appropriate to me since I need to automate the process and do some calculation.
What is the common way of programming/coding refactoring tasks (move, extract and delete method)? I am working on Java.
Upvotes: 1
Views: 346
Reputation: 95362
The most general refactoring tools are Program Transformation Systems (PTS). These are tools that read source code, build compiler data structures (often ASTs) representing that code, allow custom modifications to those structures, and can then regenerated code from the modified structures.
Good PTSes can be configured to handle arbitrary langauges, and will let you write code transformation in terms of source-to-source transformations using the surface syntax of the target langauge, in the following form:
when you see *thispattern*, replace it by *thatpattern* if *condition*
Such tools can carry out arbitrary code refactorings in the small, or even architectural code changes or langauge migrations in the large.
[See my bio for one of these].
Upvotes: 0
Reputation: 787
It is a bit unclear what you are trying to do. With Eclipse JDT, APIs exist to run the manual refactorings: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2Frefactoring%2FIJavaRefactorings.html
I have seen a research paper describing the impact of suchrefactorings on power consumption.
Otherwise you can look at AutoRefactor for an example of how to use JDT for doing refactorings. Disclaimer: I am the author of AutoRefactor.
Upvotes: 0