Reputation: 144
I have to implement an external interface with a class generated from my DSL. One of the methods to implement has the following signature:
public void execute(SomeType<? extends OtherType> param1, ...) {...}
In the JvmModelInferrer, I mapped the appropriate elements of the DSL onto a method and added the parameters like this:
parameters += appRule.toParameter("param1", appRule.newTypeRef(SomeType, it.newTypeRef("? extends OtherType")))
It almost works, but generates a very strange output:
public void execute(final /*SomeType<? extends OtherType> */Object param1, ...) {...}
I suppose there could be additional settings to force the generator use the generic parameter I provided, but can't really find it.
Upvotes: 0
Views: 255
Reputation: 13858
Basically, you should set up the type parameters in the model instead of creating it in a string. For that, we use the following construct in EMF-IncQuery:
it.parameters += pattern.toParameter("processor",
pattern.newTypeRef(typeof (IMatchProcessor),
cloneWithProxies(matchClassReference).wildCardSuper))
Here, cloneWithProxies is provided by the JvmTypesBuilder (can be injected), while wildCardSuper is a helper method written by us:
public JvmWildcardTypeReference wildCardSuper(JvmTypeReference clone) {
JvmWildcardTypeReference result = factory.createJvmWildcardTypeReference();
JvmLowerBound lowerBound = factory.createJvmLowerBound();
lowerBound.setTypeReference(clone);
result.getConstraints().add(lowerBound);
return result;
}
Upvotes: 1