skip to main content
10.1145/2048066.2048078acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Tool-supported refactoring for JavaScript

Published:22 October 2011Publication History

ABSTRACT

Refactoring is a popular technique for improving the structure of existing programs while maintaining their behavior. For statically typed programming languages such as Java, a wide variety of refactorings have been described, and tool support for performing refactorings and ensuring their correctness is widely available in modern IDEs. For the JavaScript programming language, however, existing refactoring tools are less mature and often unable to ensure that program behavior is preserved. Refactoring algorithms that have been developed for statically typed languages are not applicable to JavaScript because of its dynamic nature. We propose a framework for specifying and implementing JavaScript refactorings based on pointer analysis. We describe novel refactorings motivated by best practice recommendations for JavaScript programming, and demonstrate how they can be described concisely in terms of queries provided by our framework. Experiments performed with a prototype implementation on a suite of existing applications show that our approach is well-suited for developing practical refactoring tools for JavaScript.

References

  1. C. Anderson, P. Giannini, and S. Drossopoulou. Towards Type Inference for JavaScript. In Proc. 19th European Conference on Object-Oriented Programming, volume 3586 of LNCS. Springer-Verlag, July 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. C. Bachmann and E. Pfister. JavaScript Refactoring Eclipse Plug-in. Bachelor thesis, University of Applied Science Rapperswil, 2008.Google ScholarGoogle Scholar
  3. M. Balmer and R. Kühni. Refactoring Support für Eclipse JavaScript Development Tools. Diploma thesis, University of Applied Science Rapperswil, 2008.Google ScholarGoogle Scholar
  4. K. Beck. Extreme Programming Explained: Embrace Change. Addison-Wesley, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. D. Crockford. JavaScript: The Good Parts. O'Reilly, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Eclipse. JavaScript Development Tools. http://wiki.eclipse.org/JSDT.Google ScholarGoogle Scholar
  7. ECMA. ECMAScript Language Specification, 5th edition, 2009. ECMA-262.Google ScholarGoogle Scholar
  8. er, Schafer, and Tip}trA. Feldthaus, T. Millstein, A. Møller, M. Schafer, and F. Tip. Tool-supported Refactoring for JavaScript. http://www.brics.dk/jsrefactor/, 2011. Technical Report.Google ScholarGoogle Scholar
  9. M. Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. A. Garrido and R. E. Johnson. Refactoring C with Conditional Compilation. In phProc. 18th IEEE International Conference on Automated Software Engineering, October 2003.Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. W. G. Griswold. Program Restructuring as an Aid to Software Maintenance. Ph.D. thesis, University of Washington, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. S. Guarnieri and V. B. Livshits. Gatekeeper: Mostly static enforcement of security and reliability policies for JavaScript code. In Proc. 18th USENIX Security Symposium, August 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. S. Guarnieri, M. Pistoia, O. Tripp, J. Dolby, S. Teilhet, and R. Berg. Saving the world wide web from vulnerable JavaScript. In Proc. 20th International Symposium on Software Testing and Analysis, July 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. A. Guha, S. Krishnamurthi, and T. Jim. Using Static Analysis for Ajax Intrusion Detection. In Proc. 18th International Conference on World Wide Web, May 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. A. Guha, C. Saftoiu, and S. Krishnamurthi. The Essence of JavaScript. In Proc. 24th European Conference on Object-Oriented Programming, volume 6183 of LNCS. Springer-Verlag, June 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. R. Hasti and S. Horwitz. Using Static Single Assignment Form to Improve Flow-Insensitive Pointer Analysis. In Proc. ACM SIGPLAN Conference on Programming Language Design and Implementation, June 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. D. Jang and K.-M. Choe. Points-to Analysis for JavaScript. In Proc. 24th Annual ACM Symposium on Applied Computing, Programming Language Track, March 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. er, and Thiemann}tajs2009S. H. Jensen, A. Møller, and P. Thiemann. Type Analysis for JavaScript. In Proc. 16th International Static Analysis Symposium, volume 5673 of LNCS. Springer-Verlag, August 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. er, and Thiemann}lazypropagation2010S. H. Jensen, A. Møller, and P. Thiemann. Interprocedural Analysis with Lazy Propagation. In Proc. 17th International Static Analysis Symposium, volume 6337 of LNCS. Springer-Verlag, September 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. er}dom2011S. H. Jensen, M. Madsen, and A. Møller. Modeling the HTML DOM and browser API in static analysis of JavaScript web applications. In Proc. European Software Engineering Conference and ACM SIGSOFT International Symposium on Foundations of Software Engineering, September 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. JetBrains. JavaScript Editor. http://www.jetbrains.com/editors/javascript_editor.jsp.Google ScholarGoogle Scholar
  22. I. Moore. Automatic Inheritance Hierarchy Restructuring and Method Refactoring. In Proc. ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, October 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. W. F. Opdyke. Refactoring Object-Oriented Frameworks. Ph.D. thesis, University of Illinois at Urbana-Champaign, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. D. B. Roberts, J. Brant, and R. Johnson. A Refactoring Tool for Smalltalk. Theory and Practice of Object Systems, 3 (4): 253--263, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. P. Saxena, D. Akhawe, S. Hanna, S. McCamant, D. Song, and F. Mao. A Symbolic Execution Framework for JavaScript. In phProc. 31st IEEE Symposium on Security and Privacy, May 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. M. Schafer, T. Ekman, and O. de Moor. Sound and Extensible Renaming for Java. In Proc. ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, October 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. F. Tip. Refactoring Using Type Constraints. In Proc. 14th International Static Analysis Symposium, volume 4634 of LNCS. Springer-Verlag, August 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. D. von Dincklage and A. Diwan. Converting Java Classes to Use Generics. In Proc. ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, October 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. World Wide Web Consortium. Document Object Model Level 3. http://www.w3.org/DOM/DOMTR#dom3.Google ScholarGoogle Scholar

Index Terms

  1. Tool-supported refactoring for JavaScript

    Recommendations

    Comments

    Login options

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

    Sign in
    • Published in

      cover image ACM Conferences
      OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications
      October 2011
      1104 pages
      ISBN:9781450309400
      DOI:10.1145/2048066
      • cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 46, Issue 10
        OOPSLA '11
        October 2011
        1063 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2076021
        Issue’s Table of Contents

      Copyright © 2011 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 22 October 2011

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate268of1,244submissions,22%

      Upcoming Conference

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader