Eclipse Xtext - Inheriting

On the last page we looked at calling a DSL from a DSL. On this page we look at inheritance in DSLs:

Inheriting a DSL from another DSL.

Here is some simple code for my DSL interface.
// my DSL interface
package example4

interface HelloWorld4 {
  def String getString()
Here is the DSL that inherits from it
// my DSL code
package example4
import example4.HelloWorld4

class HelloMe implements HelloWorld4 {
  def String getString(){
  	"Hello Me"

This works fine.

Note 1. The requirement to use the override keyword is not yet implemented. There is no checking of what is overridden (as in java).

Note 2. The way that I implemented the interface in my DSL means that the 'abstract' keyword appears in the generated interface code (but it still seems to work).

package example4;

public interface HelloWorld4 {
  public abstract String getString();

Inheriting from a native java class or interface in a DSL.


Further Reading

There is more about cross-referencing, on this page.

For more information about naming go on to this page.

This itemis blog has more information about this topic.


metadata block
see also: itemis blog
Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2022 Martin John Baker - All rights reserved - privacy policy.