10.1145/1134285.1134311acmconferencesArticle/Chapter ViewAbstractPublication PagesicseConference Proceedingsconference-collections
Article

JunGL: a scripting language for refactoring

Published:28 May 2006Publication History

ABSTRACT

Refactorings are behaviour-preserving program transformations, typically for improving the structure of existing code. A few of these transformations have been mechanised in interactive development environments. Many more refactorings have been proposed, and it would be desirable for programmers to script their own refactorings. Implementing such source-to-source transformations, however, is quite complex: even the most sophisticated development environments contain significant bugs in their refactoring tools.We present a domain-specific language for refactoring, named JunGL. It manipulates a graph representation of the program: all information about the program, including ASTs for its compilation units, variable binding, control flow and so on is represented in a uniform graph format. The language is a hybrid of a functional language (in the style of ML) and a logic query language (akin to Datalog). JunGL furthermore has a notion of demand-driven evaluation for constructing computed information in the graph, such as control flow edges. Borrowing from earlier work on the specification of compiler optimisations, JunGL uses so-called `path queries' to express dataflow properties.We motivate the design of JunGL via a number of non-trivial refactorings, and describe its implementation on the.NET platform.

References

  1. Andrew W. Appel. Modern Compiler Implementation in uppercaseML. Cambridge University Press, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Uwe Assmann. OPTIMIX --- a tool for rewriting and optimizing programs. In H. Ehrig, G. Engels, H. J. Kreowski, and G. Rozenberg, editors, Handbook of Graph Grammars and Computing by Graph Transformation. Volume 2: Applications, Languages and Tools, pages 307--318. World Scientific, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Ittai Balaban, Frank Tip, and Robert Fuhrer. Refactoring support for class library migration. In Proceedings of the 20th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 265--279, 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Peter Buneman, Mary Fernandez, and Dan Suciu. UnQL: A query language and algebra for semistructured data based on structural recursion. VLDB Journal, 9(1):76--110, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Alan Donovan, Adam Kiezun, Matthew S. Tschantz, and Michael D. Ernst. Converting java programs to use generic libraries. In Proceedings of the 19th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 15--34, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Stephen J. Drape, Oege de Moor, and Ganesh Sittampalam. Transforming the.NET intermediate language using path logic programming. In Principles and Practice of Declarative Programming, pages 133--144, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Torbjörn Ekman and Görel Hedin. Rewritable reference attributed grammars. In Martin Odersky, editor, European Conference on Object-Oriented Programming, pages 144--169, 2004.]]Google ScholarGoogle Scholar
  8. Dawson R. Engler. Interface compilation: Steps toward compiling program interfaces as languages. IEEE Transactions on Software Engineering, 25(3):387--400, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Ran Ettinger and Mathieu Verbaere. Untangling: a slice extraction refactoring. In Gail C. Murphy and Karl J. Lieberherr, editors, em Aspect-Oriented Software Development, pages 93--101, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Ran Ettinger and Mathieu Verbaere. Refactoring bugs in Eclipse, IntelliJ IDEA and Visual Studio. http://progtools.comlab.ox.ac.uk/projects/refactoring/bugreports, 2005.]]Google ScholarGoogle Scholar
  11. Martin Fowler. Refactoring: Improving the Design of Existing Code. Addison Wesley, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Martin Fowler. Refactoring home page. http://www.refactoring.com, 2005.]]Google ScholarGoogle Scholar
  13. Sam Z. Guyer and Calvin Lin. An annotation language for optimizing software libraries. In Second conference on Domain-Specific Languages, pages 39--52. USENIX, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Elnar Hajiyev, Mathieu Verbaere, Oege de Moor, and Kris de Volder. Codequest with datalog. In OOPSLA Companion, 2005.]]Google ScholarGoogle Scholar
  15. Susan Horwitz and Thomas Reps. The use of program dependence graphs in software engineering. In International Conference on Software Engineering, pages 392--411, 1992.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Neil D. Jones and Alan Mycroft. Stepwise development of operational and denotational semantics for prolog. In Symposium on Logic Programming, pages 281--288, 1984.]]Google ScholarGoogle Scholar
  17. Joshua Kerievsky. Refactoring to Patterns. Addison Wesley, 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Marion Klein, Jens Knoop, Dirk Koschützki, and Bernhard Steffen. DFA & OPT-METAFrame: a toolkit for program analysis and optimization. In Tools and Algorithms for the Construction and Analysis of Systems, volume 1055 of Lecture Notes in Computer Science, pages 418--421. Springer, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. David Lacey, Neil D. Jones, Eric Van Wyk, and Carl Christian Frederiksen. Proving correctness of compiler optimizations by temporal logic. In Proceedings of the 29th ACM symposium on Principles of Programming Languages, pages 283--294, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. David Lacey and Oege de Moor. Imperative program transformation by rewriting. In R. Wilhelm, editor, Proceedings of the 10th International Conference on Compiler Construction, volume 2027 of Lecture Notes in Computer Science, pages 52--68. Springer Verlag, 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Sorin Lerner, Todd Millstein, and Craig Chambers. Automatically proving the correctness of compiler optimizations. In Programming Language Design and Implementation, pages 220--231, 2003.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Sorin Lerner, Todd Millstein, Erika Rice, and Craig Chambers. Automated soundness proofs for dataflow and analyses via local rules. In Proceedings of the 32nd ACM symposium on Principles of Programming Languages, pages 364--377, 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Ondrej Lhotak and Laurie Hendren. Jedd: A BDD-based relational extension of java. In Programming Language Design and Implementation, pages 158--169, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Yanhong Annie Liu and Scott D. Stoller. Querying complex graphs. In P. Van Hentenryck, editor, Proceedings of the 8th International Symposium on Practical Aspects of Declarative Languages, pages 16--30, 2006.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Michael Martin, Benjamin Livshits, and Monica S. Lam. Finding application errors and security flaws using PQL: a program query language. In Proceedings of the 20th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 365--383, 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Tom Mens, Serge Demeyer, and Dirk Janssens. Formalising behaviour preserving program transformations. In Graph Transformation, volume 2505 of Lecture Notes in Computer Science, pages 286--301, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Tom Mens, Gabriele Taentzer, and Olga Runge. Detecting structural refactoring conflicts using critical pair analysis. Electronic Notes in Theoretical Computer Science, 127(3):113--128, 2005.]]Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Oege de Moor, David Lacey, and Eric Van Wyk. Universal regular path queries. Higher-order and symbolic computation, 16(1-2):15--35, 2003.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Karina Olmos and Eelco Visser. Strategies for source-to-source constant propagation. In B. Gramlich and S. Lucas, editors, Workshop on Reduction Strategies in Rewriting and Programming, volume 70 of Electronic Notes in Theoretical Computer Science. Elsevier Science Publishers, May 2002.]]Google ScholarGoogle ScholarCross RefCross Ref
  30. William F. Opdyke. Refactoring Object-Oriented Frameworks. PhD thesis, University of Illinois at Urbana-Champaign, 1992.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Donald F. Roberts. Practical Analysis for Refactoring. PhD thesis, University of Illinois at Urbana-Champaign, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. J. Alan Robinson and Ernest E. Sibert. LOGLISP: Motivation, design and implementation. In K. L. Clark and S. A. Tänlund, editors, Logic Programming, pages 299--313. Academic Press, 1982.]]Google ScholarGoogle Scholar
  33. Peter Sestoft and Henrik I. Hansen. C# Precisely. MIT Press, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Ganesh Sittampalam, Oege de Moor, and Ken Friis Larsen. Incremental execution of transformation specifications. In Proceedings of the 31st ACM symposium on Principles of Programming Languages, pages 26--38, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Don Syme. F# home page. http://research.microsoft.com/projects/ilx/fsharp.aspx, 2005.]]Google ScholarGoogle Scholar
  36. Frank Tip, Adam Kiezun, and Dirk Bäumer. Refactoring for generalization using type constraints. In Proceedings of the 18th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 13--26, 2003.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Eelco Visser. Meta-programming with concrete object syntax. In Generative programming and component engineering, pages 299--315, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Daniel von Dincklage and Amer Diwan. Converting java classes to use generics. In Proceedings of the 19th ACM conference on Object-Oriented Programming, Systems, Languages and Applications, pages 1--14, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Mark Weiser. Program slicing. IEEE Transactions on Software Engineering, 10:352--357, 1984.]]Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Deborah Whitfield and Mary Lou Soffa. An approach for exploring code-improving transformations. ACM Transactions on Programming Languages and Systems, 19(6):1053--1084, 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. JunGL: a scripting language for refactoring

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!