Signed-off-by: Christian Dietrich <christian.dietrich@itemis.de>
This commit is contained in:
Christian Dietrich 2022-03-02 12:35:24 +01:00
parent 93047069b1
commit 5def003d52
2 changed files with 13 additions and 24 deletions

View file

@ -446,9 +446,8 @@ class SerializerFragment2 extends AbstractStubGeneratingFragment {
val clazz = if (isGenerateStub) grammar.abstractSyntacticSequencerClass else grammar.syntacticSequencerClass
val javaFile = fileAccessFactory.createGeneratedJavaFile(clazz)
javaFile.resourceSet = language.resourceSet
val elements = allAmbiguousTransitionsBySyntax
val partitions = Iterables.partition(elements, 60)
val elements = allAmbiguousTransitionsBySyntax
val partitions = Iterables.partition(elements, 60)
javaFile.content = '''
public «IF isGenerateStub»abstract «ENDIF»class «clazz.simpleName» extends «AbstractSyntacticSequencer» {
@ -460,12 +459,12 @@ class SerializerFragment2 extends AbstractStubGeneratingFragment {
@«Inject»
protected void init(«IGrammarAccess» access) {
grammarAccess = («grammar.grammarAccess») access;
«IF partitions.size > 1»
«FOR partition : partitions.indexed»
init«partition.key»(access);
init«partition.key»();
«ENDFOR»
«ELSE»
grammarAccess = («grammar.grammarAccess») access;
«FOR group : allAmbiguousTransitionsBySyntax»
match_«group.identifier» = «group.elementAlias.elementAliasToConstructor»;
«ENDFOR»
@ -474,8 +473,7 @@ class SerializerFragment2 extends AbstractStubGeneratingFragment {
«IF partitions.size > 1»
«FOR partition : partitions.indexed»
private void init«partition.key»(«IGrammarAccess» access) {
grammarAccess = («grammar.grammarAccess») access;
private void init«partition.key»() {
«FOR element : partition.value»
match_«element.identifier» = «element.elementAlias.elementAliasToConstructor»;
«ENDFOR»

View file

@ -1231,6 +1231,12 @@ public class SerializerFragment2 extends AbstractStubGeneratingFragment {
_builder.append(IGrammarAccess.class, "\t");
_builder.append(" access) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("grammarAccess = (");
TypeReference _grammarAccess_1 = SerializerFragment2.this._grammarAccessExtensions.getGrammarAccess(SerializerFragment2.this.getGrammar());
_builder.append(_grammarAccess_1, "\t\t");
_builder.append(") access;");
_builder.newLineIfNotEmpty();
{
int _size = IterableExtensions.size(partitions);
boolean _greaterThan = (_size > 1);
@ -1242,17 +1248,11 @@ public class SerializerFragment2 extends AbstractStubGeneratingFragment {
_builder.append("init");
Integer _key = partition.getKey();
_builder.append(_key, "\t\t");
_builder.append("(access);");
_builder.append("();");
_builder.newLineIfNotEmpty();
}
}
} else {
_builder.append("\t\t");
_builder.append("grammarAccess = (");
TypeReference _grammarAccess_1 = SerializerFragment2.this._grammarAccessExtensions.getGrammarAccess(SerializerFragment2.this.getGrammar());
_builder.append(_grammarAccess_1, "\t\t");
_builder.append(") access;");
_builder.newLineIfNotEmpty();
{
List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax_1 = SerializerFragment2.this._syntacticSequencerExtensions.getAllAmbiguousTransitionsBySyntax();
for(final EqualAmbiguousTransitions group_1 : _allAmbiguousTransitionsBySyntax_1) {
@ -1285,16 +1285,7 @@ public class SerializerFragment2 extends AbstractStubGeneratingFragment {
_builder.append("private void init");
Integer _key_1 = partition_1.getKey();
_builder.append(_key_1, "\t");
_builder.append("(");
_builder.append(IGrammarAccess.class, "\t");
_builder.append(" access) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("grammarAccess = (");
TypeReference _grammarAccess_2 = SerializerFragment2.this._grammarAccessExtensions.getGrammarAccess(SerializerFragment2.this.getGrammar());
_builder.append(_grammarAccess_2, "\t\t");
_builder.append(") access;");
_builder.append("() {");
_builder.newLineIfNotEmpty();
{
List<EqualAmbiguousTransitions> _value = partition_1.getValue();