0
votes

Problem:

I would like to have a xtext DSL where I can cross link to java types included in a JAR.

Example:

Let’s suppose we have a simple DSL like:

Object:
    'object' name=ID '{'
    property=Property
    '}';

Property:
    'property' name=ID '{'
    object=ObjectOrInclude
    '}';

ObjectOrInclude:
    Include | Object;

Include:
    'include' include=[Object|ID];

In addition, there is a JAR in our classpath providing several classes that implement the interface

public interface IObject{
…
}

The cross link include should than allow us to refer to the EObjects coming from my DSLSs but also to the classes supplied by the JAR. I assume that I must integrate my Java Interface somehow into the xtext index and provide an ID and ResourceDescription for every class, so that the linker can resolve the classes. Yet, I have no idea how to implement this extension of the index.

Question:

How do I get my Java classes into the xtext index so that cross linking works?

1
Nice hair ;) . . . - GOXR3PLUS

1 Answers

1
votes

This is ususally done by using Xtype or Xbase. unfortunately you want to refer to both EObjects and JvmTypes. you could do this by implement a jvmmodelinferrer that maps your Objects to JvmTypes. have a look at https://www.eclipse.org/Xtext/documentation/104_jvmdomainmodel.html to get an idea how to do that