Another tool is RefactoringNG in which you describe refactoring rules as transformations of source abstract syntax trees to destination syntax trees. For example, the rule that rewrites x = x + 1 to x++ is as follows:

// x = x + 1 -> x++
Assignment {
   Identifier [name: "x"],
   Binary [kind: PLUS] {
      Identifier [name: "x"],
      Literal [kind: INT_LITERAL, value: 1]
} ->
   Identifier [name: "x"]

Advantage of this approach is that you can create batches. For example, a library author can prepare a batch that upgrades the source code to a new version of library. See for more information.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo