Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Inferring multiple classes for one model element with type parameters
Inferring multiple classes for one model element with type parameters [message #1053360] Sat, 04 May 2013 12:37
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi,

I try to define a DSL that looks like:

processor P<T,R> {

  in port input: T
  out port output: R

}


I infer the JVM model based on the domain model and for each of the processor I create two classes:

class P1<T,R> {
  public Port<T> input;
  public Port<R> output;
}

class P2<T,R> {
  public Port<T> input;
  public Port<R> output;
}


Each class (JvmDeclaredType) associates the type parameters using the cloneWithProxies:

for (p: element.getTypeParameters()) {
  clazz.getTypeParameters.add(builder.cloneWithProxies(p));
}


Now I'm wondering how to create correctly the fields. If I use:

for (port: element.getPorts()) {
  JvmTypeReference jvmType = builder.newTypeRef(port, Port.class, port.getType())
  clazz.getMembers().add(builder.toField(port, port.getName(), jvmType)
}


Xtext correctly associates the first one, but of the second class (that is generated after the first one) I get:
class P2<T,R> {
  public Port<?> input;
  public Port<?> output;
}


I have not figure our how can I re-associate the type parameters when generating the second class.
What is the right way for handling the type parameters across multiple classes?

Thanks a lot!
Filip
Previous Topic:how to coherently update parts of my script in the editor
Next Topic:Access Restriction
Goto Forum:
  


Current Time: Thu Apr 18 08:15:29 GMT 2024

Powered by FUDForum. Page generated in 0.01769 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top