Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] A (very stupid?) beginner problem(I cannot run the 15min code generation tutorial)
[SOLVED] A (very stupid?) beginner problem [message #1859876] Mon, 03 July 2023 14:15 Go to next message
Antonio Cicchetti is currently offline Antonio CicchettiFriend
Messages: 18
Registered: November 2013
Junior Member
Dear all,
I am sorry if this is a very stupid question but I could not find a solution after two days of tries, forum/internet browsing.

I am using XText SDK 2.30 and Eclipse EMF 202303. I am trying to run code generation by using/adapting the 15min tutorial available in the documentation, however I have not been successful in even getting an initial generator override to run. This is the code I am trying to run in ("Challenge" is a type in my xText grammar/model):

@SuppressWarnings("all")
public class MyDslGenerator extends AbstractGenerator {
@Override
public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) {
for (e : resource.allContents.toIterable.filter(Challenge)) {
}
}
}

In particular, it looks like I do not have the "allContents" operation for the resource type (I have a getAllContents method but then the code is completely different from the tutorial). I tried by looking at complete examples and it seems I am not missing any imports but it really feels like I am missing something in my environment to run this. Any help/hint would be appreciated. Thanks a lot.

Antonio

[Updated on: Tue, 04 July 2023 06:36]

Report message to a moderator

Re: A (very stupid?) beginner problem [message #1859878 is a reply to message #1859876] Mon, 03 July 2023 14:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
This seems to be xtend syntax in java code

Where are you actually editing ?

the java code would be something like

Iterables.filter(IteratorExtensions.toIterable(resource.getAllContents()), Greeting.class)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Tue, 04 July 2023 04:39]

Report message to a moderator

Re: A (very stupid?) beginner problem [message #1859886 is a reply to message #1859878] Tue, 04 July 2023 06:19 Go to previous messageGo to next message
Antonio Cicchetti is currently offline Antonio CicchettiFriend
Messages: 18
Registered: November 2013
Junior Member
Hi Christian,
I am editing the MyDSLGenerator.java inside the .generator package in (xtend-gen). When you write "this seems to be xtend syntax in java code" do you mean that I need to create a different file for this or it is enough to use the ''' <xtend_code>'''?

Thanks again for your quick help!

Antonio

[Updated on: Tue, 04 July 2023 06:20]

Report message to a moderator

Re: A (very stupid?) beginner problem [message #1859887 is a reply to message #1859886] Tue, 04 July 2023 06:39 Go to previous messageGo to next message
Antonio Cicchetti is currently offline Antonio CicchettiFriend
Messages: 18
Registered: November 2013
Junior Member
Hi again,
I finally understood where I was making my beginners' mistake. I was editing the .java file in the .generator package (xtend-gen folder), but indeed that file is supposed to be automatically generated from the xtend code you write for the generator. Such a code is found in the src folder and again .generator package. Due to this overload of names I got confused.

Thanks again for the help and I hope this thread can avoid waste of time for others.

Antonio
Re: A (very stupid?) beginner problem [message #1859889 is a reply to message #1859887] Tue, 04 July 2023 08:25 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Xtend is transpiled to java (as is typescript to JavaScript) so having both files cannot be avoided

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Previous Topic:Calling IReferenceFinder.findAllReferences in tests
Next Topic:File extension conflict
Goto Forum:
  


Current Time: Thu Dec 12 12:09:21 GMT 2024

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

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

Back to the top