MPS 2023.3 Help

BaseLanguage Properties

Properties give you a shortcut to enrich your BaseLanguage classes with a private field together with a getter and a setter.

Properties explained

Properties are part of BaseLanguage itself, so no additional import is neccessary. They are supposed to be created as class members alongside fields and methods.

Property example

A property defines its:

  • Visibility, which will be used as the visibility of the getter.

  • Type - which indicates the type of the values stored by the property, as well as the return type of the getter and the type of the single parameter of the setter.

  • Getter - can be 'default' (implicit) to simply return the property value, or explicit.

  • Setter - can be 'none' for read-only properties, 'default' to simply set the value of the property or explicit.

Editing properties

When you insert a new property, it usually starts with a default getter and a private default setter.

Default property definition

Hitting Enter on the getter will create an explicit getter for you to insert the code and the setter will be removed (read-only property. The setter can be provided by hitting Enter in the setter region.

Property with an explicit getter

Hitting Enter on the setter, instead, will keep a default getter and create an explicit setter.

Property with explicit setter

Irrespective of the situation, you can always delete an explicit getter or setter with Delete and create them with Enter.

Property with both getter and a setter

Two special expressions are available in getters and setters:

  • value - refers to the setter's parameter

  • the actual property name - refers to the current property value in both the setter and the getter.

Two intentions/refactorings are available to convert a property into a field with getters and setters and vice versa.

Property refactorings
Last modified: 07 March 2024