Automated Python Refactoring Using Type Inference
am 24.12.2007 um 15:50
Das ist der Titel der Studienarbeit von Reto Schüttel und mir, die wir am Freitag pünktlich um 17:00 eingereicht haben. Die Arbeit hat viel Zeit und Nerven gekostet, aber auch Freude gemacht und ich denke das Ergebnis kann sich sehen lassen :).
Übersetzt heisst der Titel soviel wie Automatisierte Python-Refactorings mit Typinferenz. Für PyDev, eine Eclipse-basierte IDE für Python, haben wir die wohl nützlichsten Refactorings implementiert, wie zum Beispiel Rename Method, Rename Class und Rename Attribute. Screenshots und unseren Bericht gibts auf dem Wiki. Interessierte Python-Programmierer können das ganze relativ einfach über unsere Update-Site für Eclipse ausprobieren.
Nachfolgend noch das Abstract unserer Arbeit. Ach ja, und frohe Weihnachten :)!
Software development is often an unpredictable process, the goals change, an approach turns out to be inefficient or a complex part has to be split up into several pieces. Keeping up with this process often results in the need to make structural changes, so called refactorings. Automating these kinds of adjustments is often desirable, as it saves time and reduces the risk of faults.
There are several development environments available for the Python programming language, but only a few offer automatic refactoring. The aim of this project was to extend the refactoring support of PyDev, an Eclipse-based development environment. We implemented the following refactorings:
- Generate Docstring
- Inline Local Variable
- Extract Local Variable
- Rename Local Variable
- Rename Method
- Rename Attribute
- Rename Class
To be able to automatically rename methods, classes or attributes, it is essential to know the types of all involved objects. In a dynamically typed language like Python, the exact type of objects is not known before running the actual program. To still be able to determine these types in advance, a heuristic called type inference was implemented. Although the type inference heuristic still has some limitations, it turned out to be very powerful and an essential helper.
As more advanced refactorings often depend on knowing the type of objects, the type inference engine will make implementing these refactorings much simpler. But the engine also appears to be useful for many other common IDE tasks, like finding the references of a given attribute or method, searching for a definition or providing overall structural information.
