New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xtext-maven-plugin generate does not respect order of languages in pom.xml #2967
Comments
You could have different executions in the plugin configuration: the first one with the first two languages and the second one with the other ones |
you also could have circular dependencies between the two files. thus the behaviour is intentional. can you give some insights what
|
@LorenzoBettini Sadly I already tried that and it doesn't work: there will be 2 different runs, one for each execution, so the generator state is reset between the runs.
@cdietrich I will have to look into the code and come back to you. I am not that intimately familiar with the implemented DSL, I was working on just porting the DSL to Maven. Currently I just know that two files (each with their own grammar) need to be parsed first before being able to parse number 3, then 4, and then 5. Any other order does not work. Will be back with updates. |
Okay, so I took a look over what is implemented. Let's assume this is the implementation of class Lang1Generator extends AbstractGenerator {
public static var List<Variable> list1 = new ArrayList()
public static var List<Variable> list2 = new ArrayList()
public static var List<String> list3 = new ArrayList()
...
override void doGenerate(org.eclipse.emf.ecore.resource.Resource input, IFileSystemAccess2 fsa, IGeneratorContext context) {
// populate list1-3 based on what has been read from .lang1 file
}
} And then, let's assume this is the implementation of class Lang5Generator extends AbstractGenerator {
override void doGenerate(org.eclipse.emf.ecore.resource.Resource input, IFileSystemAccess2 fsa, IGeneratorContext context) {
// function calls using Lang1Generator::list1
}
} If we try to first generate I'm not sure how orthodox this implementation is. How would I create a dependency with Inside Eclipse, we would manually save |
and what do you store in the lists? also the manual eclipse order seems wrong |
So, the
Then, in
In
Only The benefit of using grammars for
The definitions in
Not really as
That I am not familiar with. Could you please link to what you are reffering? Maybe an example
I couldn't agree more. That's what I am also trying to fix, among other things. |
can you give a concrete example how you write stuff to generators and read stuff from there? maybe based on a more hello worldy language, |
Creating an example is way above my Xtext knowledge. I am not sure what the misunderstanding is. It is not important what those variables store. How would I make Maven respect this generation order? ( |
Usually you should be able to obtain the information you need in lang5 generator from lang5 generator without the need to store anything from lang1 or lang1 generator running before this is why i asked you to be more explicit what you actually do store in lang 1 and read in lang 5 |
@cosminpolifronie any update here? |
Working on creating a minimal example to showcase the situation I'm in. It will take a bit, as I am not that familiar with Xtext. What I have found out is that my proposed change would have not worked anyway, as the validation step does not call I have reached the conclusion I need to make changes to the input files so that each is independently generable. I will get back to you. |
Hello everyone! I was trying to use my languages to generate code in another project, and I found out that the order in the pom.xml is not respected.
Instead, all grammars to be parsed are gathered together, some deltas are computed, and the end result is an arbitrary run of the languages.
For example, in my case:
The pom above will validate and generate in this order:
lang3 lang1 lang5 lang2 lang4
Expected run:
lang1 lang2 lang3 lang4 lang5
This is necessary in my project as the first 2 languages are initializing some states/variables inside the generator which will be used by langs3-5.
I found the culprit code to be here:
xtext/org.eclipse.xtext.builder.standalone/src/org/eclipse/xtext/builder/standalone/StandaloneBuilder.java
Lines 250 to 273 in 1d83f89
This code should be modified to use the
languages
list to determine the parsing order of the files.I tried to do the changes myself but I am having trouble building xtext locally.
Would there be another way to do this? I cannot use multiple
execution
entries as this would reinitialize the language model.This language works perfectly fine inside Eclipse, I just have to manually run the generator on each file individually, in the order that I need.
The text was updated successfully, but these errors were encountered: