Using Java Compiler as a Refactoring and an Analysis

W
Document Sample
scope of work template
							Using Java 6 Compiler
as a Refactoring and
 an Analysis Engine




                      Jan Bečička
                     Petr Hřebejk
                       Petr Zajac
                Sun Microsystems
Agenda

 • Refactoring API
 • Using Javac
  > Read model in NetBeans
  > Write model in NetBeans
 • Codeviation Project
 • Q&A




                     1st Workshop on Refactoring Tools
NetBeans Refactoring API

 •   UI and API framework
 •   Language independent
 •   Describes workflow
 •   Allow refactoring over different file types




                        1st Workshop on Refactoring Tools
Javac

 • Javac now open sourced
 • Javac APIs
  > JSR 199 – driving the compiler (tools):
    javax.tools.*
  > JSR 269 – son of APT: javax.lang.model.*
  > Trees: com.sun.source.tree.*
  > Javadoc
 • KSL – Kitchen Sink Language Project



                    1st Workshop on Refactoring Tools
Read model in NetBeans

 • Javac
  >   Elements
  >   Types
  >   Trees
  >   Utilities
 • NetBeans APIs
  > Utility methods not available in Javac
  > Usages Cache




                       1st Workshop on Refactoring Tools
Write model in NetBeans

  • TreeMaker
     >   Modification of ASTs
     >   Creating new ASTs
     >   Managing the Import Section
     >   Inserting Code as Text

public ForLoopTree ForLoop(List<? extends StatementTree> initializer,
                        ExpressionTree condition,
                        List<? extends ExpressionStatementTree> update,
                        StatementTree statement)
public BlockTree createMethodBody(MethodTree method, String bodyText)




                                   1st Workshop on Refactoring Tools
Codeviation

 • What should be refactored
 • Was the refactoring successful?
 • Inspecting arbitrary builds
   >   Switching compiler
   >   Metrics
   >   Analysis
   >   Class Rank
 • Integration with:
   > Version Control Systems
   > Bug-tracking systems


                        1st Workshop on Refactoring Tools
Questions & Answers




               1st Workshop on Refactoring Tools
Using Java 6 Compiler
as a Refactoring and
 an Analysis Engine




                      Jan Bečička
                     Petr Hřebejk
                       Petr Zajac
                Sun Microsystems

						
Related docs