|
Re: Inferrer Enumeration type creation [message #731869 is a reply to message #731855] |
Mon, 03 October 2011 10:58 |
|
Hi,
this should be straight forward. so what is the actual problem you have?
dont forget to adopt IQualifiedNameProvider too
def dispatch Iterable<JvmDeclaredType> transform(Entity entity) {
val jvmClass = typesFactory.createJvmGenericType
jvmClass.simpleName = entity.name
jvmClass.packageName = entity.packageName
entity.associatePrimary(jvmClass)
jvmClass.visibility = JvmVisibility::PUBLIC
if (entity.superType != null)
jvmClass.superTypes += cloneWithProxies(entity.superType)
for(f : entity.features) {
transform(f, jvmClass)
}
val enum1 = typesFactory.createJvmEnumerationType
enum1.simpleName = entity.name + "Type"
val l1 = typesFactory.createJvmEnumerationLiteral
l1.simpleName = "Deutschland"
l1.visibility = JvmVisibility::PUBLIC
l1.^static = true
var t1 = typesFactory.createJvmParameterizedTypeReference
t1.type = enum1
l1.type = t1
val l2 = typesFactory.createJvmEnumerationLiteral
l2.simpleName = "Frankreich"
l2.visibility = JvmVisibility::PUBLIC
l2.^static = true
var t2 = typesFactory.createJvmParameterizedTypeReference
t2.type = enum1
l2.type = t2
enum1.members += l1
enum1.members += l2
entity.associatePrimary(enum1)
newArrayList(jvmClass as JvmDeclaredType, enum1 as JvmDeclaredType)
}
note that you (may) have to add some other stuff (operations/constructors...) to the enum
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Mon, 03 October 2011 12:35] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: Inferrer Enumeration type creation [message #733392 is a reply to message #733332] |
Tue, 04 October 2011 15:46 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Balázs,
I had to fix a problem with adding java.lang.Object as a base class for
root classes also following Christian's advice. He's very helpful!
On 04/10/2011 8:34 AM, Balazs Molnar wrote:
> Hello,
>
> I had the problem of adding org.eclipse.xtext.xbase.lib already fixed
> in an earlier post following Christian's advise :)
>
> regards,
> Balázs
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03868 seconds