Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » post processing
post processing [message #1068595] Sat, 13 July 2013 20:25 Go to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
Hi,
Is there any tutorial about post-processing in xtext?

I saw some examples are for xtext 1.0 and it seems they are still working.

btw, what kind of language that used to write the post-processing code? I heard it is in xtend, but the examples that i saw are not compatible with xtend 2.0.

example that i saw looks like:

import ecore;
import xtext;

process(GeneratedMetamodel this) :
this.ePackage.eClassifiers.addToStringOperation();

EPackage ecorePackage():
JAVA org.eclipse.emf.ecore.impl.EcorePackageImpl.init();

create EOperation addToStringOperation(EClassifier c):
setName("toString") ->
setEType(ecorePackage().getEClassifier("EString")) ->
eAnnotations.add(addBodyAnnotation(
'if (eIsProxy()) return super.toString(); return ToString.valueOf(this);')) ->
((EClass)c).eOperations.add(this);


need some help.

Thanks
Re: post processing [message #1068599 is a reply to message #1068595] Sat, 13 July 2013 20:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

this is the old Xpand expression language Xtend (1)
you can use the new Xtend (or even Java) as well. have a look at
http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: post processing [message #1068601 is a reply to message #1068599] Sat, 13 July 2013 20:42 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
Thanks Chris.
Re: post processing [message #1068602 is a reply to message #1068599] Sat, 13 July 2013 20:45 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
By the way, some one mentioned that the file extension is .ext for the example(post processing) that i quote above.

I guess i should switch to .xtend, right?
Re: post processing [message #1068607 is a reply to message #1068602] Sat, 13 July 2013 21:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
hi,

.ext is for the "old" Xtend (1). have a look at for Docs on Xpand and Xtend: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.xpand.doc%2Fhelp%2Fcore_reference.html
my blog describes the usage of the "new" Xtend (extension .xtend) - http://www.eclipse.org/xtend/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: post processing [message #1068619 is a reply to message #1068607] Sat, 13 July 2013 21:59 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
HI Chris,
I have the grammar like this:

KeyValuePair:
key = Key (context = contextExpression)? value = Value
;
contextExpression:
'[' OrExpr ']'
;

OrExpr:
AndExpr ({Or.left=current} '|' right=AndExpr)*
;

AndExpr:
PrimaryExpr ({And.left=current} '&' right=PrimaryExpr)*
;

PrimaryExpr:
{PrimaryExpr} (q = QUALIFIED_NAME | bool = Bool_Expr | Not = NotExpr)
;

Bool_Expr:
left_operant = QUALIFIED_NAME operator = ('='|'!=') right_operant = QUALIFIED_NAME
;

NotExpr:
'!('OrExpr')'
;

I try to make the context accept some Boolean expression here, and i how i can display the expression in the outline view.
For example:[!(s=k&d=k)]

however, they are not like a simple datatype or a feature, and i cannot turn the expression in context into a desired String.

Do you have any idea to do this?
Re: post processing [message #1068732 is a reply to message #1068619] Sun, 14 July 2013 06:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi Sorry i lost Context. What does this have Todo with postprocessing. Postprocessing is for changing the metamodel

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: post processing [message #1068783 is a reply to message #1068732] Sun, 14 July 2013 10:46 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
HI,
sorry, it is just a new question. not about the post-processing
Re: post processing [message #1068786 is a reply to message #1068783] Sun, 14 July 2013 10:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
No Message Body

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: post processing [message #1068787 is a reply to message #1068786] Sun, 14 July 2013 10:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
ok then why do you not want the expression to be a real object? this make no sense to me.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: post processing [message #1068819 is a reply to message #1068787] Sun, 14 July 2013 13:12 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
eh, I saw someone's blog in which he defined a similar expression; so i guess that most people would do in this way.
http://blog.efftinge.de/2010/08/parsing-expressions-with-xtext.html



Re: post processing [message #1068838 is a reply to message #1068787] Sun, 14 July 2013 14:30 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
how can I define an object to accept such expression?
Re: post processing [message #1068848 is a reply to message #1068838] Sun, 14 July 2013 15:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi sorry i dont know what your actual problem with the grammar you
have is

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: post processing [message #1068854 is a reply to message #1068848] Sun, 14 July 2013 15:33 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
Never mind, Chris. Maybe I just don't know what to do clearly.

Another question:

when i launch a runtime eclipse, and modified the file (written in the newly defined language), then if i save the file and then click exit button, everything's fine; if i click the exit button first, and then I saved the file as the eclipse asked, error appeared. why is that?

here is the error message.

[Worker-1] ERROR org.eclipse.xtend.ide.XtendExecutableExtensionFactory - java.lang.NullPointerException
7 [Worker-1] ERROR org.eclipse.xtext.builder.impl.XtextBuilder -
java.lang.NullPointerException
at org.eclipse.xtend.ide.XtendExecutableExtensionFactory.getBundle(XtendExecutableExtensionFactory.java:21)
at org.eclipse.xtext.ui.guice.AbstractGuiceAwareExecutableExtensionFactory.create(AbstractGuiceAwareExecutableExtensionFactory.java:57)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:262)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant$BuilderParticipantReader.readElement(RegistryBuilderParticipant.java:102)
at org.eclipse.emf.ecore.plugin.RegistryReader.internalReadElement(RegistryReader.java:117)
at org.eclipse.emf.ecore.plugin.RegistryReader.readRegistry(RegistryReader.java:87)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.initParticipants(RegistryBuilderParticipant.java:80)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.getParticipants(RegistryBuilderParticipant.java:67)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:52)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:186)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:162)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:95)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Re: post processing [message #1068858 is a reply to message #1068854] Sun, 14 July 2013 15:47 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Sorry i have no idea on this. Especially since this error seem to
come from Xtend and not from your language

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Is there a headless feature fur running MWE2 workflows?
Next Topic:Errors during xtext ui project export operation
Goto Forum:
  


Current Time: Fri Mar 29 12:33:20 GMT 2024

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

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

Back to the top