Chapter 10. Scoping
Usually, the first aspect you need to customize in your DSL implementation in Xtext is the validator. Typically, the second aspect you need to customize is scoping , which is the main mechanism behind visibility and cross-reference resolution. As soon as the DSL needs some constructs for structuring the code, a custom scoping implementation is required. In particular, scoping and typing are often strictly connected and interdependent especially for object-oriented languages. For this reason, in this chapter, we will continue developing the SmallJava DSL introduced in the previous chapter. We will describe both local and global scoping and explain how to customize scoping using SmallJava as a case study.
This chapter will cover the following topics:
- A detailed description of the Xtext mechanisms for local and global scoping
- How to customize the local scoping in an object-oriented language
- How to customize the global scoping with the concepts of packages and imports...