Retrieve literals from enum [message #666451] |
Wed, 20 April 2011 09:44  |
Eclipse User |
|
|
|
Hi,
How do I retrieve all literals from an enum?
Until Indigo it has been possible to use something like MyEnum.allInstances(). This does not evaluate in Indigo (Interactive Xtext OCL Console).
Thanks in advance & best regards
Joern
|
|
|
|
|
|
|
|
Re: Retrieve literals from enum [message #666989 is a reply to message #666496] |
Mon, 25 April 2011 07:38  |
Eclipse User |
|
|
|
Hi
I've no idea why oclType() does not exist. You'll have to provide
detailed information on versions and files. AFAIK oclType() exists in
all Eclipse OCL versions but with rather suspect utility in most.
I've just committed changes that resolve a pleasing number of FIXMEs in
regard to TypeValues by introducing a templated Classifier<T> so that
the known type is propagated as e.g. Classifier<CollectionKind>. This
gets rid of most of the pragmatic code; both oclType() and
allInstances() are now model rather than manually-defined.
As a result both of
CollectionKind.allInstances()
CollectionKind.ownedLiteral
now return
Set{CollectionKind::Bag,CollectionKind::Collection,Collectio nKind::OrderedSet,CollectionKind::Sequence,CollectionKind::S et}
An N-build for this is available from
https://hudson.eclipse.org/hudson/job/buckminster-mdt-ocl-co re-3.1-nightly/lastSuccessfulBuild/artifact/MDT-OCL.download s/
(It needs a moderately recent Xtext N-build too.)
Regards
Ed Willink
On 20/04/2011 16:20, Joern wrote:
> Hi Ed,
>
> Thanks for the answer.
>
> I tried your proposals - but the operation oclType() seems not to
> exist. Neither Enum::Literal.oclType() nor Enum.oclType() does evaluate.
>
> In the spec I only found a refernce to "OclType" as "the singleton
> instance of TypeType" ...
>
> But another workaround would be welcome :)
>
> Best regards,
>
> Joern
|
|
|
Powered by
FUDForum. Page generated in 0.24694 seconds