Diploma Thesis Designing, Implementing and Integrating a Structured C# Code Editor

Diploma Thesis Designing, Implementing and Integrating a Structured C# Code Editor

Brandenburg University of Chair of programming languages and Technology compiler construction Diploma thesis Designing, implementing and integrating a structured C# code editor Kirill Osenkov Advisor: Prof. Dr. rer. nat. habil. Peter Bachmann Co-Examiner: Prof. Dr. rer. nat. Claus Lewerentz CR-Classification: D.2.3, D.2.6 June 1, 2007 Eidesstattliche Erklärung Hiermit versichere ich, dass ich die vorliegende Diplomarbeit selbständig angefertigt habe. Die verwendeten Hilfsmittel und Quellen sind im Literaturverzeichnis vollständig aufgeführt. Diese Arbeit hat in gleicher oder ähnlicher Form noch keiner Prüfungsbehörde vorgelegen. Eingetragene Warenzeichen und Copyrights werden anerkannt, auch wenn sie nicht explizit gekennzeichnet sind. 1. Juni 2007 Cottbus 2 Abstract Programs are represented as text by most code editors. Structured editors, on the contrary, directly display the parse tree of a program as a hierarchy of embedded blocks. This way the visual layout illustrates the structure of the program and allows for atomic operations on language constructs. The structured editor lets developers avoid syntax errors and concentrate on the meaning of the program instead of formatting. In the scope of this thesis, an experimental structured editor is created for a subset of C# 1.0. It is integrated into the SharpDevelop IDE as an add-in and supports language-aware code completion. The implementation of the editor (.NET) is based on a framework specifically designed for building structured editors. The framework, the editor and the integration add-in are all documented together with the architecture and implementation details. Zusammenfassung Programme werden in den meisten Quelltexteditoren als Text repräsentiert. Strukturierte Editoren stellen dagegen den Syntaxbaum des Programms visuell als eine Hierarchie der geschachtelten Blöcke dar. Das Layout hilft dabei, die Struktur des Programms besser zu visualisieren und atomare Operationen bequem durchzuführen. Ein strukturierter Editor hilft Syntaxfehler zu vermeiden und lässt den Entwickler auf dem Inhalt statt Formattierung zu konzentrieren. In Rahmen dieser Diplomarbeit wird ein experimenteller strukturierter Editor für eine Teilmenge von C# 1.0 entworfen und implementiert. Der Editor ist mit der SharpDevelop Entwicklungsumgebung integriert und bietet kontextbasierte Code-Vervollständigung. Die Implementierung des Editors (.NET) beruht auf einem generischen Framework zur Entwicklung von strukturierten Editoren. Das Framework, der Editor und die Integration mit der Entwicklungsumgebung sowie die Architektur und Implementierungsdetails werden in dieser Arbeit dokumentiert. 3 Acknowledgements I would like to thank Professor Dr. Peter Bachmann for initiating and supporting this research. It was an enjoyment to work with such a good advisor on such an interesting project. I’d also like to thank Professor Dr. Claus Lewerentz for being a co-examiner of the thesis. Many thanks go to fellow students and friends with whom we worked together on the structured editor framework. I’m endlessly grateful to my wonderful mom. Thank you for your love and for always being there for me! Last, but not least, I thank my amazing girlfriend Vlada, for inspiring me and making me happy! Kirill Osenkov June 1, 2007 Cottbus, Germany 4 Contents: 1. INTRODUCTION .......................................................................................................................................7 1.1. TEXT VS . STRUCTURED EDITORS ............................................................................................................. 7 1.2. INTEGRATION OF AN EDITOR WITH THE IDE............................................................................................8 1.3. PRINCIPLES OF PLAIN TEXT EDITORS ....................................................................................................... 9 1.4. PRINCIPLES OF STRUCTURED EDITORS ................................................................................................... 17 1.5. DISADVANTAGES AND POSSIBLE DIFFICULTIES ..................................................................................... 25 2. EXISTING RESEARCH........................................................................................................................... 29 2.1. HISTORY ............................................................................................................................................... 29 2.2. INTENTIONAL PROGRAMMING ............................................................................................................... 31 2.3. JET BRAINS MPS ................................................................................................................................... 32 2.4. THE SYNTHESIZER GENERATOR ............................................................................................................. 33 2.5. OTHER IMPLEMENTATIONS .................................................................................................................... 33 2.6. SUMMARY ............................................................................................................................................. 34 3. FUNCTIONALITY OF THE STRUCTURED EDITOR....................................................................... 35 3.1. CREATING A PROGRAM ......................................................................................................................... 36 3.2. NAMESPACE MEMBER DECLARATIONS .................................................................................................. 39 3.3. TYPE DECLARATIONS ............................................................................................................................ 41 3.4. ACCESS MODIFIERS ............................................................................................................................... 42 3.5. CLASS AND STRUCT MEMBERS .............................................................................................................. 44 3.6. STATEMENTS ......................................................................................................................................... 47 3.7. CONTROL STRUCTURES ......................................................................................................................... 48 3.8. COMMENTS ........................................................................................................................................... 49 3.9. CODE COMPLETION ............................................................................................................................... 50 4. ARCHITECTURE..................................................................................................................................... 51 4.1. THE EDITOR FRAMEWORK .................................................................................................................... 51 4.2. UTILS .................................................................................................................................................... 53 4.3. CANVAS ................................................................................................................................................ 54 4.4. CONTROLS ............................................................................................................................................ 54 4.5. CORE ..................................................................................................................................................... 55 4.6. IMPLEMENTATION OF THE C# EDITOR ................................................................................................... 56 5. BLOCKS..................................................................................................................................................... 58 5.1. DATA STRUCTURE ................................................................................................................................. 58 5.2. TREE ORGANIZATION ............................................................................................................................ 60 5.3. OPERATIONS ON THE DATA STRUCTURE ................................................................................................62 5.4. CONTAINER BLOCK ............................................................................................................................... 63 5.5. ROOT BLOCK ......................................................................................................................................... 65 5 5.6. HC ONTAINER BLOCK , VCONTAINER BLOCK .......................................................................................... 65 5.7. LINEAR CONTAINER BLOCK ................................................................................................................... 66 5.8. TEXT BOX BLOCK ................................................................................................................................... 67 5.9. TEXT BOX BLOCK WITH COMPLETION ....................................................................................................68 5.10. LABEL BLOCK ...................................................................................................................................... 69 5.11. UNIVERSAL BLOCK .............................................................................................................................. 70 5.12. BUTTON BLOCK ..................................................................................................................................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    132 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us