Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [xtext-dev] add visitor method to generated AbstractElement interface with @modified tag to

Hi Michael,

I reply for Sven as he's so busy:

You can use the generated EMF switches (XtextutilSwitch, ParsetreeSwitch or XtextSwitch) to implement multi-methods (dynamic dispatch) for Ecore models and avoid repetitive usage of "instanceof". The switch classes simply implement a visitor pattern. Inherit from the generated abstract class and override the "caseXXX" methods to return type specific values. Use doSwitch() to call the type specific function.

The switch internally uses the much better performing EClass IDs from the EPackage instead of "instanceof". It also takes care of inheritance by switching to the superclass if there is no result.

Sorry, I don't have an example at hand, but feel free to ask again if this information is not sufficient.

Regards
Jan




Am 15.09.2008 um 10:32 schrieb michael clay:

hi sven,

could you point me in the right direction pls. did you mean
XtextutilSwitch,ParsetreeSwitch or XtextSwitch
do you have an example code to showcase the usage of the 'generated
switch' class to examine if its sufficient?


m

On Mon, Sep 15, 2008 at 10:24 AM, Sven Efftinge <sven@xxxxxxxxxxx> wrote:
Hi Michael,

you could use the generated Switch class to do that.
Would that be sufficient?

Sven

On Sep 14, 2008, at 8:13 PM, michael clay wrote:

hi all,

i would like to add a visitor method (@modified) to the generated EMF AbstractElement interface to get rid of the various 'instanceof' test
in several places of the xtext code for a cleaner
structuring and better maintainability of the code base.

pls. let me know if this is ok for you.

thx
m
_______________________________________________
xtext-dev mailing list
xtext-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/xtext-dev

_______________________________________________
xtext-dev mailing list
xtext-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/xtext-dev

_______________________________________________
xtext-dev mailing list
xtext-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/xtext-dev

--
Dr. Jan Köhnlein
Senior Software Architekt

Telefon: +49 (0) 431 / 5606-337
Mobile: +49 (0) 163 / 3979 776
Telefax: +49 (0) 431 / 5606-339

http://www.itemis.de
jan.koehnlein@xxxxxxxxx

itemis AG
Schauenburgerstr. 116
24118 Kiel

Rechtlicher Hinweis:

Amtsgericht Dortmund, HRB 20621

Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek

Aufsichtsrat: Prof. Dr. Burkhart Igel (Vors.) Stephan Grollmann, Michael Neuhaus




Back to the top