Designing, implementing and integrating a structured C# code editor

Kirill Osenkov

Diploma thesis in Computer Science (equiv. to Master of Science)

Brandenburg University of Technology

Cottbus, Germany

June 1, 2007

Full text (pdf)

Screenshots

Presentation (in German)

Links about structured editors

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 better illustrates the structure of the program and allows for atomic operations on the 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.

Contents

  1. Introduction
    1. Text vs. structured editors
    2. Integration of an editor with the IDE
    3. Principles of plain text editors
    4. Principles of structured editors
    5. Disadvantages and possible difficulties
  2. Existing research
    1. History
    2. Intentional Programming     
    3. JetBrains MPS
    4. The Synthesizer Generator
    5. Other implementations
    6. Summary
  3. Functionality of the structured editor
    1. Creating a program
    2. Namespace member declarations
    3. Type declarations
    4. Access modifiers
    5. Class and struct members
    6. Statements
    7. Control structures
    8. Comments
    9. Code completion
  4. Architecture
    1. The Editor Framework
    2. Utils
    3. Canvas
    4. Controls
    5. Core
    6. Implementation of the C# editor
  5. Blocks
    1. Data structure
    2. Tree organization
    3. Operations on the data structure
    4. ContainerBlock
    5. RootBlock
    6. HContainerBlock, VContainerBlock
    7. LinearContainerBlock
    8. TextBoxBlock
    9. TextBoxBlockWithCompletion
    10. LabelBlock
    11. UniversalBlock
    12. ButtonBlock
    13. EmptyBlock
  6. Implementation of the functionality
    1. Designing the user interface
    2. Focus
    3. Events and user interaction
    4. Actions
    5. Controls
    6. VisibilityConditions
  7. Implementing the C# editor
    1. The project structure
    2. Defining data structures (blocks)
    3. Dynamic help
    4. LanguageService
    5. ClassNavigator algorithms
    6. Stand-alone editor window
  8. Integrating into SharpDevelop
    1. The SharpDevelop IDE
    2. Architecture
    3. Sharpdevelop Add-In
    4. Round-tripping
    5. Implementation of the add-in
    6. Code completion
  9. Summary
    1. Future research directions
    2. Drawbacks of the current implementation
  10. References
  11. List of figures