1 /*
2  * Copyright (C) 2007-2010 Júlio Vilmar Gesser.
3  * Copyright (C) 2011, 2013-2016 The JavaParser Team.
4  *
5  * This file is part of JavaParser.
6  *
7  * JavaParser can be used either under the terms of
8  * a) the GNU Lesser General Public License as published by
9  *     the Free Software Foundation, either version 3 of the License, or
10  *     (at your option) any later version.
11  * b) the terms of the Apache License
12  *
13  * You should have received a copy of both licenses in LICENCE.LGPL and
14  * LICENCE.APACHE. Please refer to those files for details.
15  *
16  * JavaParser is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU Lesser General Public License for more details.
20  */
21 
22 package com.github.javaparser.printer;
23 
24 import com.github.javaparser.GeneratedJavaParserConstants;
25 import com.github.javaparser.ast.*;
26 import com.github.javaparser.ast.body.*;
27 import com.github.javaparser.ast.comments.Comment;
28 import com.github.javaparser.ast.expr.*;
29 import com.github.javaparser.ast.modules.*;
30 import com.github.javaparser.ast.observer.ObservableProperty;
31 import com.github.javaparser.ast.stmt.*;
32 import com.github.javaparser.ast.type.*;
33 import com.github.javaparser.metamodel.JavaParserMetaModel;
34 import com.github.javaparser.printer.concretesyntaxmodel.CsmConditional;
35 import com.github.javaparser.printer.concretesyntaxmodel.CsmElement;
36 import com.github.javaparser.printer.concretesyntaxmodel.CsmMix;
37 
38 import java.util.*;
39 import java.util.stream.Collectors;
40 
41 import static com.github.javaparser.GeneratedJavaParserConstants.*;
42 import static com.github.javaparser.ast.observer.ObservableProperty.*;
43 import static com.github.javaparser.printer.concretesyntaxmodel.CsmConditional.Condition.*;
44 import static com.github.javaparser.printer.concretesyntaxmodel.CsmElement.*;
45 import static com.github.javaparser.utils.Utils.EOL;
46 
47 /**
48  * The Concrete Syntax Model for a single node type. It knows the syntax used to represent a certain element in Java
49  * code.
50  */
51 public class ConcreteSyntaxModel {
52 
53     private static final Map<Class, CsmElement> concreteSyntaxModelByClass = new HashMap<>();
54     private static Optional<String> initializationError;
55 
modifiers()56     private static CsmElement modifiers() {
57         return list(ObservableProperty.MODIFIERS, space(), none(), space());
58     }
59 
60     /**
61      * Build a mix collecting all the elements specified.
62      */
mix(CsmElement... elements)63     private static CsmElement mix(CsmElement... elements) {
64         return new CsmMix(Arrays.asList(elements));
65     }
66 
memberAnnotations()67     private static CsmElement memberAnnotations() {
68         return list(ObservableProperty.ANNOTATIONS, newline(), none(), newline());
69     }
70 
annotations()71     private static CsmElement annotations() {
72         return list(ObservableProperty.ANNOTATIONS, space(), none(), newline());
73     }
74 
typeParameters()75     private static CsmElement typeParameters() {
76         return list(ObservableProperty.TYPE_PARAMETERS, CsmElement.sequence(CsmElement.comma(), CsmElement.space()), CsmElement.token(GeneratedJavaParserConstants.LT),
77                 CsmElement.sequence(CsmElement.token(GeneratedJavaParserConstants.GT), CsmElement.space()));
78     }
79 
typeArguments()80     private static CsmElement typeArguments() {
81         return list(ObservableProperty.TYPE_ARGUMENTS, CsmElement.sequence(CsmElement.comma(), CsmElement.space()), CsmElement.token(GeneratedJavaParserConstants.LT),
82                 CsmElement.sequence(CsmElement.token(GeneratedJavaParserConstants.GT)));
83     }
84 
85     static {
86 
87         ///
88         /// Body
89         ///
90 
concreteSyntaxModelByClass.put(AnnotationDeclaration.class, CsmElement.sequence( CsmElement.comment(), memberAnnotations(), modifiers(), CsmElement.token(GeneratedJavaParserConstants.AT), CsmElement.token(GeneratedJavaParserConstants.INTERFACE), CsmElement.space(), CsmElement.child(ObservableProperty.NAME), CsmElement.space(), CsmElement.token(LBRACE), CsmElement.newline(), CsmElement.indent(), CsmElement.list(ObservableProperty.MEMBERS, CsmElement.newline(), CsmElement.none(), CsmElement.none(), CsmElement.newline()), CsmElement.unindent(), CsmElement.token(RBRACE) ))91         concreteSyntaxModelByClass.put(AnnotationDeclaration.class, CsmElement.sequence(
92                 CsmElement.comment(),
93                 memberAnnotations(),
94                 modifiers(),
95                 CsmElement.token(GeneratedJavaParserConstants.AT),
96                 CsmElement.token(GeneratedJavaParserConstants.INTERFACE),
97                 CsmElement.space(),
98                 CsmElement.child(ObservableProperty.NAME),
99                 CsmElement.space(),
100                 CsmElement.token(LBRACE),
101                 CsmElement.newline(),
102                 CsmElement.indent(),
103                 CsmElement.list(ObservableProperty.MEMBERS, CsmElement.newline(), CsmElement.none(), CsmElement.none(), CsmElement.newline()),
104                 CsmElement.unindent(),
105                 CsmElement.token(RBRACE)
106         ));
107 
concreteSyntaxModelByClass.put(AnnotationMemberDeclaration.class, CsmElement.sequence( CsmElement.comment(), memberAnnotations(), modifiers(), CsmElement.child(ObservableProperty.TYPE), CsmElement.space(), CsmElement.child(ObservableProperty.NAME), CsmElement.token(LPAREN), CsmElement.token(RPAREN), CsmElement.conditional(ObservableProperty.DEFAULT_VALUE, IS_PRESENT, CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants._DEFAULT), CsmElement.space(), CsmElement.child(DEFAULT_VALUE))), CsmElement.semicolon() ))108         concreteSyntaxModelByClass.put(AnnotationMemberDeclaration.class, CsmElement.sequence(
109                 CsmElement.comment(),
110                 memberAnnotations(),
111                 modifiers(),
112                 CsmElement.child(ObservableProperty.TYPE),
113                 CsmElement.space(),
114                 CsmElement.child(ObservableProperty.NAME),
115                 CsmElement.token(LPAREN),
116                 CsmElement.token(RPAREN),
117                 CsmElement.conditional(ObservableProperty.DEFAULT_VALUE, IS_PRESENT, CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants._DEFAULT), CsmElement.space(), CsmElement.child(DEFAULT_VALUE))),
118                 CsmElement.semicolon()
119         ));
120 
concreteSyntaxModelByClass.put(ClassOrInterfaceDeclaration.class, sequence( comment(), list(ObservableProperty.ANNOTATIONS, newline(), none(), newline()), modifiers(), conditional(ObservableProperty.INTERFACE, FLAG, token(GeneratedJavaParserConstants.INTERFACE), token(GeneratedJavaParserConstants.CLASS)), space(), child(ObservableProperty.NAME), list(TYPE_PARAMETERS, sequence(comma(), space()), string(GeneratedJavaParserConstants.LT), string(GeneratedJavaParserConstants.GT)), list(ObservableProperty.EXTENDED_TYPES, sequence(string(GeneratedJavaParserConstants.COMMA), space()), sequence(space(), token(GeneratedJavaParserConstants.EXTENDS), space()), none()), list(ObservableProperty.IMPLEMENTED_TYPES, sequence(string(GeneratedJavaParserConstants.COMMA), space()), sequence( space(), token(GeneratedJavaParserConstants.IMPLEMENTS), space()), none()), space(), block(sequence(newline(), list(ObservableProperty.MEMBERS, sequence(newline(), newline()), CsmElement.newline(), newline()))) ))121         concreteSyntaxModelByClass.put(ClassOrInterfaceDeclaration.class, sequence(
122                 comment(),
123                 list(ObservableProperty.ANNOTATIONS, newline(), none(), newline()),
124                 modifiers(),
125                 conditional(ObservableProperty.INTERFACE, FLAG, token(GeneratedJavaParserConstants.INTERFACE), token(GeneratedJavaParserConstants.CLASS)),
126                 space(),
127                 child(ObservableProperty.NAME),
128                 list(TYPE_PARAMETERS, sequence(comma(), space()), string(GeneratedJavaParserConstants.LT), string(GeneratedJavaParserConstants.GT)),
129                 list(ObservableProperty.EXTENDED_TYPES,
130                         sequence(string(GeneratedJavaParserConstants.COMMA), space()),
131                         sequence(space(), token(GeneratedJavaParserConstants.EXTENDS), space()),
132                         none()),
133                 list(ObservableProperty.IMPLEMENTED_TYPES, sequence(string(GeneratedJavaParserConstants.COMMA), space()), sequence(
134                         space(),
135                         token(GeneratedJavaParserConstants.IMPLEMENTS),
136                         space()), none()),
137                 space(),
138                 block(sequence(newline(), list(ObservableProperty.MEMBERS, sequence(newline(), newline()), CsmElement.newline(), newline())))
139         ));
140 
concreteSyntaxModelByClass.put(ConstructorDeclaration.class, sequence( comment(), memberAnnotations(), modifiers(), typeParameters(), child(ObservableProperty.NAME), token(GeneratedJavaParserConstants.LPAREN), list(ObservableProperty.PARAMETERS, sequence(comma(), space()), none(), none()), token(GeneratedJavaParserConstants.RPAREN), list(ObservableProperty.THROWN_EXCEPTIONS, sequence(comma(), space()), sequence(space(), token(GeneratedJavaParserConstants.THROWS), space()), none()), space(), child(ObservableProperty.BODY) ))141         concreteSyntaxModelByClass.put(ConstructorDeclaration.class, sequence(
142                 comment(),
143                 memberAnnotations(),
144                 modifiers(),
145                 typeParameters(),
146                 child(ObservableProperty.NAME),
147                 token(GeneratedJavaParserConstants.LPAREN),
148                 list(ObservableProperty.PARAMETERS, sequence(comma(), space()), none(), none()),
149                 token(GeneratedJavaParserConstants.RPAREN),
150                 list(ObservableProperty.THROWN_EXCEPTIONS, sequence(comma(), space()), sequence(space(), token(GeneratedJavaParserConstants.THROWS), space()), none()),
151                 space(),
152                 child(ObservableProperty.BODY)
153         ));
154 
concreteSyntaxModelByClass.put(EnumConstantDeclaration.class, sequence( comment(), memberAnnotations(), child(ObservableProperty.NAME), list(ObservableProperty.ARGUMENTS, sequence(comma(), space()), token(GeneratedJavaParserConstants.LPAREN), token(GeneratedJavaParserConstants.RPAREN)), conditional(CLASS_BODY, IS_NOT_EMPTY, sequence(space(), token(GeneratedJavaParserConstants.LBRACE), CsmElement.newline(), CsmElement.indent(), CsmElement.newline(), list(ObservableProperty.CLASS_BODY, newline(), newline(), none(), CsmElement.newline()), unindent(), token(RBRACE), CsmElement.newline())) ))155         concreteSyntaxModelByClass.put(EnumConstantDeclaration.class, sequence(
156                 comment(),
157                 memberAnnotations(),
158                 child(ObservableProperty.NAME),
159                 list(ObservableProperty.ARGUMENTS, sequence(comma(), space()), token(GeneratedJavaParserConstants.LPAREN), token(GeneratedJavaParserConstants.RPAREN)),
160                 conditional(CLASS_BODY, IS_NOT_EMPTY, sequence(space(), token(GeneratedJavaParserConstants.LBRACE), CsmElement.newline(), CsmElement.indent(), CsmElement.newline(),
161                         list(ObservableProperty.CLASS_BODY, newline(), newline(), none(), CsmElement.newline()),
162                         unindent(),
163                         token(RBRACE), CsmElement.newline()))
164         ));
165 
concreteSyntaxModelByClass.put(EnumDeclaration.class, sequence( comment(), annotations(), modifiers(), token(GeneratedJavaParserConstants.ENUM), space(), child(ObservableProperty.NAME), list(ObservableProperty.IMPLEMENTED_TYPES, sequence(comma(), space()), sequence(space(), token(GeneratedJavaParserConstants.IMPLEMENTS), space()), none()), space(), token(GeneratedJavaParserConstants.LBRACE), CsmElement.newline(), CsmElement.indent(), CsmElement.newline(), list(ObservableProperty.ENTRIES, sequence(comma(), space()), CsmElement.none(), none()), conditional(ObservableProperty.MEMBERS, IS_EMPTY, conditional(ObservableProperty.ENTRIES, IS_NOT_EMPTY, newline()), sequence(CsmElement.semicolon(), newline(), CsmElement.newline(), list(ObservableProperty.MEMBERS, newline(), newline(), none(), CsmElement.newline()))), unindent(), token(RBRACE) ))166         concreteSyntaxModelByClass.put(EnumDeclaration.class, sequence(
167                 comment(),
168                 annotations(),
169                 modifiers(),
170                 token(GeneratedJavaParserConstants.ENUM),
171                 space(),
172                 child(ObservableProperty.NAME),
173                 list(ObservableProperty.IMPLEMENTED_TYPES,
174                         sequence(comma(), space()),
175                         sequence(space(), token(GeneratedJavaParserConstants.IMPLEMENTS), space()),
176                         none()),
177                 space(),
178                 token(GeneratedJavaParserConstants.LBRACE),
179                 CsmElement.newline(),
180                 CsmElement.indent(),
181                 CsmElement.newline(),
182                 list(ObservableProperty.ENTRIES,
183                         sequence(comma(), space()),
184                         CsmElement.none(),
185                         none()),
186                 conditional(ObservableProperty.MEMBERS, IS_EMPTY,
187                         conditional(ObservableProperty.ENTRIES, IS_NOT_EMPTY, newline()),
188                         sequence(CsmElement.semicolon(), newline(), CsmElement.newline(), list(ObservableProperty.MEMBERS, newline(), newline(), none(), CsmElement.newline()))),
189                 unindent(),
190                 token(RBRACE)
191         ));
192 
concreteSyntaxModelByClass.put(FieldDeclaration.class, sequence( orphanCommentsBeforeThis(), comment(), annotations(), modifiers(), conditional(ObservableProperty.VARIABLES, IS_NOT_EMPTY, child(ObservableProperty.MAXIMUM_COMMON_TYPE)), space(), list(ObservableProperty.VARIABLES, sequence(comma(), space())), semicolon()))193         concreteSyntaxModelByClass.put(FieldDeclaration.class, sequence(
194                 orphanCommentsBeforeThis(),
195                 comment(),
196                 annotations(),
197                 modifiers(),
198                 conditional(ObservableProperty.VARIABLES, IS_NOT_EMPTY, child(ObservableProperty.MAXIMUM_COMMON_TYPE)),
199                 space(),
200                 list(ObservableProperty.VARIABLES, sequence(comma(), space())),
201                 semicolon()));
202 
concreteSyntaxModelByClass.put(InitializerDeclaration.class, sequence( comment(), conditional(ObservableProperty.STATIC, FLAG, sequence(token(GeneratedJavaParserConstants.STATIC), space())), child(ObservableProperty.BODY)))203         concreteSyntaxModelByClass.put(InitializerDeclaration.class, sequence(
204                 comment(),
205                 conditional(ObservableProperty.STATIC, FLAG, sequence(token(GeneratedJavaParserConstants.STATIC), space())),
206                 child(ObservableProperty.BODY)));
207 
concreteSyntaxModelByClass.put(MethodDeclaration.class, sequence( orphanCommentsBeforeThis(), comment(), mix(memberAnnotations(), modifiers()), typeParameters(), child(ObservableProperty.TYPE), space(), child(ObservableProperty.NAME), token(GeneratedJavaParserConstants.LPAREN), conditional(ObservableProperty.RECEIVER_PARAMETER, IS_PRESENT, sequence(child(ObservableProperty.RECEIVER_PARAMETER), comma(), space())), list(ObservableProperty.PARAMETERS, sequence(comma(), space()), none(), none()), token(GeneratedJavaParserConstants.RPAREN), list(ObservableProperty.THROWN_EXCEPTIONS, sequence(comma(), space()), sequence(space(), token(GeneratedJavaParserConstants.THROWS), space()), none()), conditional(ObservableProperty.BODY, IS_PRESENT, sequence(space(), child(ObservableProperty.BODY)), semicolon()) ))208         concreteSyntaxModelByClass.put(MethodDeclaration.class, sequence(
209                 orphanCommentsBeforeThis(),
210                 comment(),
211                 mix(memberAnnotations(), modifiers()),
212                 typeParameters(),
213                 child(ObservableProperty.TYPE),
214                 space(),
215                 child(ObservableProperty.NAME),
216                 token(GeneratedJavaParserConstants.LPAREN),
217                 conditional(ObservableProperty.RECEIVER_PARAMETER, IS_PRESENT, sequence(child(ObservableProperty.RECEIVER_PARAMETER), comma(), space())),
218                 list(ObservableProperty.PARAMETERS, sequence(comma(), space()), none(), none()),
219                 token(GeneratedJavaParserConstants.RPAREN),
220                 list(ObservableProperty.THROWN_EXCEPTIONS, sequence(comma(), space()), sequence(space(), token(GeneratedJavaParserConstants.THROWS), space()), none()),
221                 conditional(ObservableProperty.BODY, IS_PRESENT, sequence(space(), child(ObservableProperty.BODY)), semicolon())
222         ));
223 
concreteSyntaxModelByClass.put(Parameter.class, sequence( comment(), list(ObservableProperty.ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.space()), modifiers(), child(ObservableProperty.TYPE), conditional(ObservableProperty.VAR_ARGS, FLAG, CsmElement.sequence( list(ObservableProperty.VAR_ARGS_ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.none()), token(GeneratedJavaParserConstants.ELLIPSIS))), space(), child(ObservableProperty.NAME)))224         concreteSyntaxModelByClass.put(Parameter.class, sequence(
225                 comment(),
226                 list(ObservableProperty.ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.space()),
227                 modifiers(),
228                 child(ObservableProperty.TYPE),
229                 conditional(ObservableProperty.VAR_ARGS, FLAG, CsmElement.sequence(
230                         list(ObservableProperty.VAR_ARGS_ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.none()),
231                         token(GeneratedJavaParserConstants.ELLIPSIS))),
232                 space(),
233                 child(ObservableProperty.NAME)));
234 
concreteSyntaxModelByClass.put(ReceiverParameter.class, sequence( comment(), list(ObservableProperty.ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.space()), child(ObservableProperty.TYPE), space(), child(ObservableProperty.NAME)))235         concreteSyntaxModelByClass.put(ReceiverParameter.class, sequence(
236                 comment(),
237                 list(ObservableProperty.ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.space()),
238                 child(ObservableProperty.TYPE),
239                 space(),
240                 child(ObservableProperty.NAME)));
241 
concreteSyntaxModelByClass.put(VariableDeclarator.class, sequence( comment(), child(ObservableProperty.NAME), conditional(ObservableProperty.INITIALIZER, IS_PRESENT, sequence(space(), token(GeneratedJavaParserConstants.ASSIGN), space(), child(ObservableProperty.INITIALIZER))) ))242         concreteSyntaxModelByClass.put(VariableDeclarator.class, sequence(
243                 comment(),
244                 child(ObservableProperty.NAME),
245                 // FIXME: we should introduce a derived property
246                 // list(ObservableProperty.EXTRA_ARRAY_LEVELS),
247                 conditional(ObservableProperty.INITIALIZER, IS_PRESENT, sequence(space(), token(GeneratedJavaParserConstants.ASSIGN), space(),
248                         child(ObservableProperty.INITIALIZER)))
249         ));
250 
251         ///
252         /// Expressions
253         ///
254 
concreteSyntaxModelByClass.put(ArrayAccessExpr.class, CsmElement.sequence( CsmElement.comment(), CsmElement.child(ObservableProperty.NAME), CsmElement.token(GeneratedJavaParserConstants.LBRACKET), CsmElement.child(ObservableProperty.INDEX), CsmElement.token(GeneratedJavaParserConstants.RBRACKET) ))255         concreteSyntaxModelByClass.put(ArrayAccessExpr.class, CsmElement.sequence(
256                 CsmElement.comment(),
257                 CsmElement.child(ObservableProperty.NAME),
258                 CsmElement.token(GeneratedJavaParserConstants.LBRACKET),
259                 CsmElement.child(ObservableProperty.INDEX),
260                 CsmElement.token(GeneratedJavaParserConstants.RBRACKET)
261         ));
262 
concreteSyntaxModelByClass.put(ArrayCreationExpr.class, sequence( comment(), token(GeneratedJavaParserConstants.NEW), space(), CsmElement.child(ObservableProperty.ELEMENT_TYPE), list(ObservableProperty.LEVELS), conditional(ObservableProperty.INITIALIZER, IS_PRESENT, sequence(space(), child(ObservableProperty.INITIALIZER))) ))263         concreteSyntaxModelByClass.put(ArrayCreationExpr.class, sequence(
264                 comment(),
265                 token(GeneratedJavaParserConstants.NEW),
266                 space(),
267                 CsmElement.child(ObservableProperty.ELEMENT_TYPE),
268                 list(ObservableProperty.LEVELS),
269                 conditional(ObservableProperty.INITIALIZER, IS_PRESENT, sequence(space(), child(ObservableProperty.INITIALIZER)))
270         ));
271 
concreteSyntaxModelByClass.put(ArrayInitializerExpr.class, sequence( comment(), token(GeneratedJavaParserConstants.LBRACE), list(ObservableProperty.VALUES, sequence(comma(), space()), space(), space()), orphanCommentsEnding(), token(RBRACE)))272         concreteSyntaxModelByClass.put(ArrayInitializerExpr.class, sequence(
273                 comment(),
274                 token(GeneratedJavaParserConstants.LBRACE),
275                 list(ObservableProperty.VALUES, sequence(comma(), space()), space(), space()),
276                 orphanCommentsEnding(),
277                 token(RBRACE)));
278 
concreteSyntaxModelByClass.put(AssignExpr.class, sequence( comment(), child(ObservableProperty.TARGET), space(), attribute(ObservableProperty.OPERATOR), space(), child(ObservableProperty.VALUE) ))279         concreteSyntaxModelByClass.put(AssignExpr.class, sequence(
280                 comment(),
281                 child(ObservableProperty.TARGET),
282                 space(),
283                 attribute(ObservableProperty.OPERATOR),
284                 space(),
285                 child(ObservableProperty.VALUE)
286         ));
287 
concreteSyntaxModelByClass.put(BinaryExpr.class, sequence( comment(), child(ObservableProperty.LEFT), space(), attribute(ObservableProperty.OPERATOR), space(), child(ObservableProperty.RIGHT) ))288         concreteSyntaxModelByClass.put(BinaryExpr.class, sequence(
289                 comment(),
290                 child(ObservableProperty.LEFT),
291                 space(),
292                 attribute(ObservableProperty.OPERATOR),
293                 space(),
294                 child(ObservableProperty.RIGHT)
295         ));
296 
concreteSyntaxModelByClass.put(BooleanLiteralExpr.class, sequence( comment(), attribute(VALUE) ))297         concreteSyntaxModelByClass.put(BooleanLiteralExpr.class, sequence(
298                 comment(), attribute(VALUE)
299         ));
300 
concreteSyntaxModelByClass.put(CastExpr.class, sequence( comment(), token(GeneratedJavaParserConstants.LPAREN), child(ObservableProperty.TYPE), token(GeneratedJavaParserConstants.RPAREN), space(), child(ObservableProperty.EXPRESSION) ))301         concreteSyntaxModelByClass.put(CastExpr.class, sequence(
302                 comment(),
303                 token(GeneratedJavaParserConstants.LPAREN),
304                 child(ObservableProperty.TYPE),
305                 token(GeneratedJavaParserConstants.RPAREN),
306                 space(),
307                 child(ObservableProperty.EXPRESSION)
308         ));
309 
concreteSyntaxModelByClass.put(CharLiteralExpr.class, sequence( comment(), charToken(ObservableProperty.VALUE) ))310         concreteSyntaxModelByClass.put(CharLiteralExpr.class, sequence(
311                 comment(),
312                 charToken(ObservableProperty.VALUE)
313         ));
314 
concreteSyntaxModelByClass.put(ClassExpr.class, sequence( comment(), child(ObservableProperty.TYPE), token(GeneratedJavaParserConstants.DOT), token(GeneratedJavaParserConstants.CLASS)))315         concreteSyntaxModelByClass.put(ClassExpr.class, sequence(
316                 comment(), child(ObservableProperty.TYPE), token(GeneratedJavaParserConstants.DOT), token(GeneratedJavaParserConstants.CLASS)));
317 
concreteSyntaxModelByClass.put(ConditionalExpr.class, CsmElement.sequence( CsmElement.comment(), CsmElement.child(ObservableProperty.CONDITION), CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.HOOK), CsmElement.space(), CsmElement.child(ObservableProperty.THEN_EXPR), CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.COLON), CsmElement.space(), CsmElement.child(ObservableProperty.ELSE_EXPR) ))318         concreteSyntaxModelByClass.put(ConditionalExpr.class, CsmElement.sequence(
319                 CsmElement.comment(),
320                 CsmElement.child(ObservableProperty.CONDITION),
321                 CsmElement.space(),
322                 CsmElement.token(GeneratedJavaParserConstants.HOOK),
323                 CsmElement.space(),
324                 CsmElement.child(ObservableProperty.THEN_EXPR),
325                 CsmElement.space(),
326                 CsmElement.token(GeneratedJavaParserConstants.COLON),
327                 CsmElement.space(),
328                 CsmElement.child(ObservableProperty.ELSE_EXPR)
329         ));
330 
concreteSyntaxModelByClass.put(DoubleLiteralExpr.class, sequence( comment(), attribute(ObservableProperty.VALUE) ))331         concreteSyntaxModelByClass.put(DoubleLiteralExpr.class, sequence(
332                 comment(),
333                 attribute(ObservableProperty.VALUE)
334         ));
335 
concreteSyntaxModelByClass.put(EnclosedExpr.class, sequence( comment(), token(GeneratedJavaParserConstants.LPAREN), child(ObservableProperty.INNER), token(GeneratedJavaParserConstants.RPAREN) ))336         concreteSyntaxModelByClass.put(EnclosedExpr.class, sequence(
337                 comment(),
338                 token(GeneratedJavaParserConstants.LPAREN),
339                 child(ObservableProperty.INNER),
340                 token(GeneratedJavaParserConstants.RPAREN)
341         ));
342 
concreteSyntaxModelByClass.put(FieldAccessExpr.class, CsmElement.sequence( CsmElement.comment(), CsmElement.child(SCOPE), CsmElement.token(GeneratedJavaParserConstants.DOT), child(ObservableProperty.NAME) ))343         concreteSyntaxModelByClass.put(FieldAccessExpr.class, CsmElement.sequence(
344                 CsmElement.comment(),
345                 CsmElement.child(SCOPE),
346                 CsmElement.token(GeneratedJavaParserConstants.DOT),
347                 child(ObservableProperty.NAME)
348         ));
349 
concreteSyntaxModelByClass.put(InstanceOfExpr.class, sequence( comment(), child(ObservableProperty.EXPRESSION), space(), token(GeneratedJavaParserConstants.INSTANCEOF), space(), child(ObservableProperty.TYPE) ))350         concreteSyntaxModelByClass.put(InstanceOfExpr.class, sequence(
351                 comment(),
352                 child(ObservableProperty.EXPRESSION),
353                 space(),
354                 token(GeneratedJavaParserConstants.INSTANCEOF),
355                 space(),
356                 child(ObservableProperty.TYPE)
357         ));
358 
concreteSyntaxModelByClass.put(IntegerLiteralExpr.class, sequence( comment(), attribute(ObservableProperty.VALUE) ))359         concreteSyntaxModelByClass.put(IntegerLiteralExpr.class, sequence(
360                 comment(),
361                 attribute(ObservableProperty.VALUE)
362         ));
363 
concreteSyntaxModelByClass.put(LambdaExpr.class, sequence( comment(), conditional(ObservableProperty.ENCLOSING_PARAMETERS, FLAG, token(GeneratedJavaParserConstants.LPAREN)), list(ObservableProperty.PARAMETERS, sequence(comma(), space())), conditional(ObservableProperty.ENCLOSING_PARAMETERS, FLAG, token(GeneratedJavaParserConstants.RPAREN)), space(), token(GeneratedJavaParserConstants.ARROW), space(), conditional(ObservableProperty.EXPRESSION_BODY, IS_PRESENT, child(ObservableProperty.EXPRESSION_BODY), child(ObservableProperty.BODY)) ))364         concreteSyntaxModelByClass.put(LambdaExpr.class, sequence(
365                 comment(),
366                 conditional(ObservableProperty.ENCLOSING_PARAMETERS, FLAG, token(GeneratedJavaParserConstants.LPAREN)),
367                 list(ObservableProperty.PARAMETERS, sequence(comma(), space())),
368                 conditional(ObservableProperty.ENCLOSING_PARAMETERS, FLAG, token(GeneratedJavaParserConstants.RPAREN)),
369                 space(),
370                 token(GeneratedJavaParserConstants.ARROW),
371                 space(),
372                 conditional(ObservableProperty.EXPRESSION_BODY, IS_PRESENT, child(ObservableProperty.EXPRESSION_BODY), child(ObservableProperty.BODY))
373         ));
374 
concreteSyntaxModelByClass.put(LongLiteralExpr.class, sequence( comment(), attribute(ObservableProperty.VALUE) ))375         concreteSyntaxModelByClass.put(LongLiteralExpr.class, sequence(
376                 comment(),
377                 attribute(ObservableProperty.VALUE)
378         ));
379 
concreteSyntaxModelByClass.put(MarkerAnnotationExpr.class, sequence(comment(), token(GeneratedJavaParserConstants.AT), attribute(ObservableProperty.NAME)))380         concreteSyntaxModelByClass.put(MarkerAnnotationExpr.class, sequence(comment(), token(GeneratedJavaParserConstants.AT), attribute(ObservableProperty.NAME)));
381 
concreteSyntaxModelByClass.put(MemberValuePair.class, CsmElement.sequence(CsmElement.comment(), CsmElement.child(ObservableProperty.NAME), CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.ASSIGN), CsmElement.space(), CsmElement.child(ObservableProperty.VALUE)))382         concreteSyntaxModelByClass.put(MemberValuePair.class, CsmElement.sequence(CsmElement.comment(),
383                 CsmElement.child(ObservableProperty.NAME),
384                 CsmElement.space(),
385                 CsmElement.token(GeneratedJavaParserConstants.ASSIGN),
386                 CsmElement.space(),
387                 CsmElement.child(ObservableProperty.VALUE)));
388 
concreteSyntaxModelByClass.put(MethodCallExpr.class, sequence( comment(), conditional(ObservableProperty.SCOPE, IS_PRESENT, sequence(child(ObservableProperty.SCOPE), token(GeneratedJavaParserConstants.DOT))), typeArguments(), child(ObservableProperty.NAME), token(GeneratedJavaParserConstants.LPAREN), list(ObservableProperty.ARGUMENTS, sequence(comma(), space()), none(), none()), token(GeneratedJavaParserConstants.RPAREN) ))389         concreteSyntaxModelByClass.put(MethodCallExpr.class, sequence(
390                 comment(),
391                 conditional(ObservableProperty.SCOPE, IS_PRESENT, sequence(child(ObservableProperty.SCOPE), token(GeneratedJavaParserConstants.DOT))),
392                 typeArguments(),
393                 child(ObservableProperty.NAME),
394                 token(GeneratedJavaParserConstants.LPAREN),
395                 list(ObservableProperty.ARGUMENTS, sequence(comma(), space()), none(), none()),
396                 token(GeneratedJavaParserConstants.RPAREN)
397         ));
398 
concreteSyntaxModelByClass.put(MethodReferenceExpr.class, sequence( comment(), child(ObservableProperty.SCOPE), token(GeneratedJavaParserConstants.DOUBLECOLON), typeArguments(), attribute(ObservableProperty.IDENTIFIER) ))399         concreteSyntaxModelByClass.put(MethodReferenceExpr.class, sequence(
400                 comment(),
401                 child(ObservableProperty.SCOPE),
402                 token(GeneratedJavaParserConstants.DOUBLECOLON),
403                 typeArguments(),
404                 attribute(ObservableProperty.IDENTIFIER)
405         ));
406 
concreteSyntaxModelByClass.put(Name.class, sequence( comment(), conditional(ObservableProperty.QUALIFIER, IS_PRESENT, sequence(child(ObservableProperty.QUALIFIER), token(GeneratedJavaParserConstants.DOT))), list(ObservableProperty.ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.space()), attribute(ObservableProperty.IDENTIFIER), orphanCommentsEnding() ))407         concreteSyntaxModelByClass.put(Name.class, sequence(
408                 comment(),
409                 conditional(ObservableProperty.QUALIFIER, IS_PRESENT, sequence(child(ObservableProperty.QUALIFIER), token(GeneratedJavaParserConstants.DOT))),
410                 list(ObservableProperty.ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.space()),
411                 attribute(ObservableProperty.IDENTIFIER),
412                 orphanCommentsEnding()
413         ));
414 
concreteSyntaxModelByClass.put(NameExpr.class, sequence( comment(), child(ObservableProperty.NAME), orphanCommentsEnding() ))415         concreteSyntaxModelByClass.put(NameExpr.class, sequence(
416                 comment(),
417                 child(ObservableProperty.NAME),
418                 orphanCommentsEnding()
419         ));
420 
concreteSyntaxModelByClass.put(NormalAnnotationExpr.class, sequence( comment(), token(GeneratedJavaParserConstants.AT), child(ObservableProperty.NAME), token(GeneratedJavaParserConstants.LPAREN), list(ObservableProperty.PAIRS, sequence(comma(), space())), token(GeneratedJavaParserConstants.RPAREN) ))421         concreteSyntaxModelByClass.put(NormalAnnotationExpr.class, sequence(
422                 comment(),
423                 token(GeneratedJavaParserConstants.AT),
424                 child(ObservableProperty.NAME),
425                 token(GeneratedJavaParserConstants.LPAREN),
426                 list(ObservableProperty.PAIRS, sequence(comma(), space())),
427                 token(GeneratedJavaParserConstants.RPAREN)
428         ));
429 
concreteSyntaxModelByClass.put(NullLiteralExpr.class, sequence( comment(), token(GeneratedJavaParserConstants.NULL) ))430         concreteSyntaxModelByClass.put(NullLiteralExpr.class, sequence(
431                 comment(),
432                 token(GeneratedJavaParserConstants.NULL)
433         ));
434 
concreteSyntaxModelByClass.put(ObjectCreationExpr.class, sequence( comment(), conditional(ObservableProperty.SCOPE, IS_PRESENT, sequence(child(ObservableProperty.SCOPE), token(GeneratedJavaParserConstants.DOT))), token(GeneratedJavaParserConstants.NEW), space(), list(ObservableProperty.TYPE_ARGUMENTS, CsmElement.sequence(CsmElement.comma(), CsmElement.space()), CsmElement.token(LT), CsmElement.token(GT)), conditional(ObservableProperty.TYPE_ARGUMENTS, IS_NOT_EMPTY, space()), child(ObservableProperty.TYPE), token(GeneratedJavaParserConstants.LPAREN), list(ObservableProperty.ARGUMENTS, sequence(comma(), space()), none(), none()), token(GeneratedJavaParserConstants.RPAREN), conditional(ObservableProperty.ANONYMOUS_CLASS_BODY, IS_PRESENT, CsmElement.sequence( CsmElement.space(), CsmElement.token(LBRACE), CsmElement.newline(), CsmElement.indent(), CsmElement.list(ObservableProperty.ANONYMOUS_CLASS_BODY, CsmElement.newline(), CsmElement.newline(), CsmElement.newline(), CsmElement.newline()), CsmElement.unindent(), CsmElement.token(RBRACE) )) ))435         concreteSyntaxModelByClass.put(ObjectCreationExpr.class, sequence(
436                 comment(),
437                 conditional(ObservableProperty.SCOPE, IS_PRESENT, sequence(child(ObservableProperty.SCOPE), token(GeneratedJavaParserConstants.DOT))),
438                 token(GeneratedJavaParserConstants.NEW),
439                 space(),
440                 list(ObservableProperty.TYPE_ARGUMENTS, CsmElement.sequence(CsmElement.comma(), CsmElement.space()), CsmElement.token(LT), CsmElement.token(GT)),
441                 conditional(ObservableProperty.TYPE_ARGUMENTS, IS_NOT_EMPTY, space()),
442                 child(ObservableProperty.TYPE),
443                 token(GeneratedJavaParserConstants.LPAREN),
444                 list(ObservableProperty.ARGUMENTS, sequence(comma(), space()), none(), none()),
445                 token(GeneratedJavaParserConstants.RPAREN),
446                 conditional(ObservableProperty.ANONYMOUS_CLASS_BODY, IS_PRESENT,
447                         CsmElement.sequence(
448                                 CsmElement.space(), CsmElement.token(LBRACE), CsmElement.newline(), CsmElement.indent(),
449                                 CsmElement.list(ObservableProperty.ANONYMOUS_CLASS_BODY,
450                                         CsmElement.newline(),
451                                         CsmElement.newline(),
452                                         CsmElement.newline(),
453                                         CsmElement.newline()),
454                                 CsmElement.unindent(),
455                                 CsmElement.token(RBRACE)
456                         ))
457         ));
458 
concreteSyntaxModelByClass.put(SimpleName.class, attribute(ObservableProperty.IDENTIFIER))459         concreteSyntaxModelByClass.put(SimpleName.class, attribute(ObservableProperty.IDENTIFIER));
460 
concreteSyntaxModelByClass.put(SingleMemberAnnotationExpr.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.AT), CsmElement.child(ObservableProperty.NAME), CsmElement.token(GeneratedJavaParserConstants.LPAREN), CsmElement.child(ObservableProperty.MEMBER_VALUE), CsmElement.token(GeneratedJavaParserConstants.RPAREN)))461         concreteSyntaxModelByClass.put(SingleMemberAnnotationExpr.class, CsmElement.sequence(
462                 CsmElement.comment(),
463                 CsmElement.token(GeneratedJavaParserConstants.AT),
464                 CsmElement.child(ObservableProperty.NAME),
465                 CsmElement.token(GeneratedJavaParserConstants.LPAREN),
466                 CsmElement.child(ObservableProperty.MEMBER_VALUE),
467                 CsmElement.token(GeneratedJavaParserConstants.RPAREN)));
468 
concreteSyntaxModelByClass.put(StringLiteralExpr.class, sequence( comment(), stringToken(ObservableProperty.VALUE) ))469         concreteSyntaxModelByClass.put(StringLiteralExpr.class, sequence(
470                 comment(),
471                 stringToken(ObservableProperty.VALUE)
472         ));
473 
concreteSyntaxModelByClass.put(SuperExpr.class, CsmElement.sequence( CsmElement.comment(), CsmElement.conditional(ObservableProperty.CLASS_EXPR, IS_PRESENT, CsmElement.sequence(CsmElement.child(ObservableProperty.CLASS_EXPR), CsmElement.token(GeneratedJavaParserConstants.DOT))), CsmElement.token(GeneratedJavaParserConstants.SUPER) ))474         concreteSyntaxModelByClass.put(SuperExpr.class, CsmElement.sequence(
475                 CsmElement.comment(),
476                 CsmElement.conditional(ObservableProperty.CLASS_EXPR, IS_PRESENT, CsmElement.sequence(CsmElement.child(ObservableProperty.CLASS_EXPR), CsmElement.token(GeneratedJavaParserConstants.DOT))),
477                 CsmElement.token(GeneratedJavaParserConstants.SUPER)
478         ));
479 
concreteSyntaxModelByClass.put(ThisExpr.class, sequence( comment(), conditional(ObservableProperty.CLASS_EXPR, IS_PRESENT, sequence(child(CLASS_EXPR), token(GeneratedJavaParserConstants.DOT))), token(GeneratedJavaParserConstants.THIS) ))480         concreteSyntaxModelByClass.put(ThisExpr.class, sequence(
481                 comment(),
482                 conditional(ObservableProperty.CLASS_EXPR, IS_PRESENT, sequence(child(CLASS_EXPR), token(GeneratedJavaParserConstants.DOT))),
483                 token(GeneratedJavaParserConstants.THIS)
484         ));
485 
concreteSyntaxModelByClass.put(TypeExpr.class, sequence( comment(), child(ObservableProperty.TYPE) ))486         concreteSyntaxModelByClass.put(TypeExpr.class, sequence(
487                 comment(),
488                 child(ObservableProperty.TYPE)
489         ));
490 
concreteSyntaxModelByClass.put(UnaryExpr.class, sequence( conditional(ObservableProperty.PREFIX, FLAG, attribute(ObservableProperty.OPERATOR)), child(ObservableProperty.EXPRESSION), conditional(ObservableProperty.POSTFIX, FLAG, attribute(ObservableProperty.OPERATOR)) ))491         concreteSyntaxModelByClass.put(UnaryExpr.class, sequence(
492                 conditional(ObservableProperty.PREFIX, FLAG, attribute(ObservableProperty.OPERATOR)),
493                 child(ObservableProperty.EXPRESSION),
494                 conditional(ObservableProperty.POSTFIX, FLAG, attribute(ObservableProperty.OPERATOR))
495         ));
496 
concreteSyntaxModelByClass.put(VariableDeclarationExpr.class, sequence( comment(), list(ObservableProperty.ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.space()), modifiers(), child(ObservableProperty.MAXIMUM_COMMON_TYPE), space(), list(ObservableProperty.VARIABLES, sequence(comma(), space())) ))497         concreteSyntaxModelByClass.put(VariableDeclarationExpr.class, sequence(
498                 comment(),
499                 list(ObservableProperty.ANNOTATIONS, CsmElement.space(), CsmElement.none(), CsmElement.space()),
500                 modifiers(),
501                 child(ObservableProperty.MAXIMUM_COMMON_TYPE),
502                 space(),
503                 list(ObservableProperty.VARIABLES, sequence(comma(), space()))
504         ));
505 
506         ///
507         /// Statements
508         ///
509 
concreteSyntaxModelByClass.put(AssertStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.ASSERT), CsmElement.space(), CsmElement.child(ObservableProperty.CHECK), CsmElement.conditional(ObservableProperty.MESSAGE, IS_PRESENT, CsmElement.sequence( CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.COLON), CsmElement.space(), CsmElement.child(ObservableProperty.MESSAGE) )), CsmElement.semicolon() ))510         concreteSyntaxModelByClass.put(AssertStmt.class, CsmElement.sequence(
511                 CsmElement.comment(),
512                 CsmElement.token(GeneratedJavaParserConstants.ASSERT),
513                 CsmElement.space(),
514                 CsmElement.child(ObservableProperty.CHECK),
515                 CsmElement.conditional(ObservableProperty.MESSAGE, IS_PRESENT, CsmElement.sequence(
516                         CsmElement.space(),
517                         CsmElement.token(GeneratedJavaParserConstants.COLON),
518                         CsmElement.space(),
519                         CsmElement.child(ObservableProperty.MESSAGE)
520                 )),
521                 CsmElement.semicolon()
522         ));
523 
concreteSyntaxModelByClass.put(BlockStmt.class, sequence( orphanCommentsBeforeThis(), comment(), token(GeneratedJavaParserConstants.LBRACE), newline(), list(ObservableProperty.STATEMENTS, newline(), indent(), sequence(newline(), unindent())), orphanCommentsEnding(), token(RBRACE) ))524         concreteSyntaxModelByClass.put(BlockStmt.class, sequence(
525                 orphanCommentsBeforeThis(),
526                 comment(),
527                 token(GeneratedJavaParserConstants.LBRACE),
528                 newline(),
529                 list(ObservableProperty.STATEMENTS, newline(), indent(), sequence(newline(), unindent())),
530                 orphanCommentsEnding(),
531                 token(RBRACE)
532         ));
533 
concreteSyntaxModelByClass.put(BreakStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.BREAK), CsmElement.conditional(ObservableProperty.LABEL, IS_PRESENT, CsmElement.sequence(CsmElement.space(), CsmElement.child(ObservableProperty.LABEL))), CsmElement.semicolon() ))534         concreteSyntaxModelByClass.put(BreakStmt.class, CsmElement.sequence(
535                 CsmElement.comment(),
536                 CsmElement.token(GeneratedJavaParserConstants.BREAK),
537                 CsmElement.conditional(ObservableProperty.LABEL, IS_PRESENT, CsmElement.sequence(CsmElement.space(), CsmElement.child(ObservableProperty.LABEL))),
538                 CsmElement.semicolon()
539         ));
540 
concreteSyntaxModelByClass.put(CatchClause.class, CsmElement.sequence( CsmElement.comment(), CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.CATCH), CsmElement.space(), CsmElement.token(LPAREN), CsmElement.child(ObservableProperty.PARAMETER), CsmElement.token(RPAREN), CsmElement.space(), CsmElement.child(BODY) ))541         concreteSyntaxModelByClass.put(CatchClause.class, CsmElement.sequence(
542                 CsmElement.comment(),
543                 CsmElement.space(),
544                 CsmElement.token(GeneratedJavaParserConstants.CATCH),
545                 CsmElement.space(),
546                 CsmElement.token(LPAREN),
547                 CsmElement.child(ObservableProperty.PARAMETER),
548                 CsmElement.token(RPAREN),
549                 CsmElement.space(),
550                 CsmElement.child(BODY)
551         ));
552 
concreteSyntaxModelByClass.put(ContinueStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.CONTINUE), CsmElement.conditional(ObservableProperty.LABEL, IS_PRESENT, CsmElement.sequence(CsmElement.space(), CsmElement.child(ObservableProperty.LABEL))), CsmElement.semicolon() ))553         concreteSyntaxModelByClass.put(ContinueStmt.class, CsmElement.sequence(
554                 CsmElement.comment(),
555                 CsmElement.token(GeneratedJavaParserConstants.CONTINUE),
556                 CsmElement.conditional(ObservableProperty.LABEL, IS_PRESENT, CsmElement.sequence(CsmElement.space(), CsmElement.child(ObservableProperty.LABEL))),
557                 CsmElement.semicolon()
558         ));
559 
concreteSyntaxModelByClass.put(DoStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.DO), CsmElement.space(), CsmElement.child(ObservableProperty.BODY), CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.WHILE), CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.LPAREN), child(ObservableProperty.CONDITION), CsmElement.token(GeneratedJavaParserConstants.RPAREN), CsmElement.semicolon() ))560         concreteSyntaxModelByClass.put(DoStmt.class, CsmElement.sequence(
561                 CsmElement.comment(),
562                 CsmElement.token(GeneratedJavaParserConstants.DO),
563                 CsmElement.space(),
564                 CsmElement.child(ObservableProperty.BODY),
565                 CsmElement.space(),
566                 CsmElement.token(GeneratedJavaParserConstants.WHILE),
567                 CsmElement.space(),
568                 CsmElement.token(GeneratedJavaParserConstants.LPAREN),
569                 child(ObservableProperty.CONDITION),
570                 CsmElement.token(GeneratedJavaParserConstants.RPAREN),
571                 CsmElement.semicolon()
572         ));
573 
concreteSyntaxModelByClass.put(EmptyStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.SEMICOLON) ))574         concreteSyntaxModelByClass.put(EmptyStmt.class, CsmElement.sequence(
575                 CsmElement.comment(),
576                 CsmElement.token(GeneratedJavaParserConstants.SEMICOLON)
577         ));
578 
concreteSyntaxModelByClass.put(UnparsableStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.SEMICOLON) ))579         concreteSyntaxModelByClass.put(UnparsableStmt.class, CsmElement.sequence(
580                 CsmElement.comment(),
581                 CsmElement.token(GeneratedJavaParserConstants.SEMICOLON)
582         ));
583 
concreteSyntaxModelByClass.put(ExplicitConstructorInvocationStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.conditional(ObservableProperty.THIS, FLAG, CsmElement.sequence(typeArguments(), CsmElement.token(GeneratedJavaParserConstants.THIS)), CsmElement.sequence( CsmElement.conditional(ObservableProperty.EXPRESSION, IS_PRESENT, CsmElement.sequence(CsmElement.child(ObservableProperty.EXPRESSION), CsmElement.token(GeneratedJavaParserConstants.DOT))), typeArguments(), CsmElement.token(GeneratedJavaParserConstants.SUPER) )), CsmElement.token(GeneratedJavaParserConstants.LPAREN), CsmElement.list(ObservableProperty.ARGUMENTS, CsmElement.sequence(CsmElement.comma(), CsmElement.space())), CsmElement.token(GeneratedJavaParserConstants.RPAREN), CsmElement.semicolon() ))584         concreteSyntaxModelByClass.put(ExplicitConstructorInvocationStmt.class, CsmElement.sequence(
585                 CsmElement.comment(),
586                 CsmElement.conditional(ObservableProperty.THIS, FLAG,
587                         CsmElement.sequence(typeArguments(), CsmElement.token(GeneratedJavaParserConstants.THIS)),
588                         CsmElement.sequence(
589                                 CsmElement.conditional(ObservableProperty.EXPRESSION, IS_PRESENT, CsmElement.sequence(CsmElement.child(ObservableProperty.EXPRESSION), CsmElement.token(GeneratedJavaParserConstants.DOT))),
590                                 typeArguments(),
591                                 CsmElement.token(GeneratedJavaParserConstants.SUPER)
592                         )),
593                 CsmElement.token(GeneratedJavaParserConstants.LPAREN),
594                 CsmElement.list(ObservableProperty.ARGUMENTS, CsmElement.sequence(CsmElement.comma(), CsmElement.space())),
595                 CsmElement.token(GeneratedJavaParserConstants.RPAREN),
596                 CsmElement.semicolon()
597         ));
598 
concreteSyntaxModelByClass.put(ExpressionStmt.class, sequence( orphanCommentsBeforeThis(), comment(), child(ObservableProperty.EXPRESSION), semicolon() ))599         concreteSyntaxModelByClass.put(ExpressionStmt.class, sequence(
600                 orphanCommentsBeforeThis(),
601                 comment(),
602                 child(ObservableProperty.EXPRESSION),
603                 semicolon()
604         ));
605 
concreteSyntaxModelByClass.put(ForeachStmt.class, sequence( comment(), token(GeneratedJavaParserConstants.FOR), space(), token(GeneratedJavaParserConstants.LPAREN), child(ObservableProperty.VARIABLE), space(), token(GeneratedJavaParserConstants.COLON), space(), child(ObservableProperty.ITERABLE), token(GeneratedJavaParserConstants.RPAREN), space(), child(ObservableProperty.BODY) ))606         concreteSyntaxModelByClass.put(ForeachStmt.class, sequence(
607                 comment(),
608                 token(GeneratedJavaParserConstants.FOR),
609                 space(),
610                 token(GeneratedJavaParserConstants.LPAREN),
611                 child(ObservableProperty.VARIABLE),
612                 space(),
613                 token(GeneratedJavaParserConstants.COLON),
614                 space(),
615                 child(ObservableProperty.ITERABLE),
616                 token(GeneratedJavaParserConstants.RPAREN),
617                 space(),
618                 child(ObservableProperty.BODY)
619         ));
620 
concreteSyntaxModelByClass.put(ForStmt.class, sequence( comment(), token(GeneratedJavaParserConstants.FOR), space(), token(GeneratedJavaParserConstants.LPAREN), list(ObservableProperty.INITIALIZATION, sequence(comma(), space())), semicolon(), space(), child(ObservableProperty.COMPARE), semicolon(), space(), list(ObservableProperty.UPDATE, sequence(comma(), space())), token(GeneratedJavaParserConstants.RPAREN), space(), child(ObservableProperty.BODY) ))621         concreteSyntaxModelByClass.put(ForStmt.class, sequence(
622                 comment(),
623                 token(GeneratedJavaParserConstants.FOR),
624                 space(),
625                 token(GeneratedJavaParserConstants.LPAREN),
626                 list(ObservableProperty.INITIALIZATION, sequence(comma(), space())),
627                 semicolon(),
628                 space(),
629                 child(ObservableProperty.COMPARE),
630                 semicolon(),
631                 space(),
632                 list(ObservableProperty.UPDATE, sequence(comma(), space())),
633                 token(GeneratedJavaParserConstants.RPAREN),
634                 space(),
635                 child(ObservableProperty.BODY)
636         ));
637 
concreteSyntaxModelByClass.put(IfStmt.class, sequence( comment(), token(GeneratedJavaParserConstants.IF), space(), token(GeneratedJavaParserConstants.LPAREN), child(ObservableProperty.CONDITION), token(GeneratedJavaParserConstants.RPAREN), conditional(ObservableProperty.THEN_BLOCK, CsmConditional.Condition.FLAG, sequence(space(), child(ObservableProperty.THEN_STMT), conditional(ObservableProperty.ELSE_STMT, IS_PRESENT, space())), sequence(newline(), CsmElement.indent(), child(ObservableProperty.THEN_STMT), conditional(ObservableProperty.ELSE_STMT, IS_PRESENT, newline()), unindent())), conditional(ObservableProperty.ELSE_STMT, IS_PRESENT, sequence(token(GeneratedJavaParserConstants.ELSE), conditional(Arrays.asList(ObservableProperty.ELSE_BLOCK, ObservableProperty.CASCADING_IF_STMT), CsmConditional.Condition.FLAG, sequence(space(), child(ObservableProperty.ELSE_STMT)), sequence(newline(), CsmElement.indent(), child(ObservableProperty.ELSE_STMT), unindent())))) ))638         concreteSyntaxModelByClass.put(IfStmt.class, sequence(
639                 comment(),
640                 token(GeneratedJavaParserConstants.IF),
641                 space(),
642                 token(GeneratedJavaParserConstants.LPAREN),
643                 child(ObservableProperty.CONDITION),
644                 token(GeneratedJavaParserConstants.RPAREN),
645                 conditional(ObservableProperty.THEN_BLOCK, CsmConditional.Condition.FLAG,
646                         sequence(space(), child(ObservableProperty.THEN_STMT),
647                                 conditional(ObservableProperty.ELSE_STMT, IS_PRESENT, space())),
648                         sequence(newline(), CsmElement.indent(), child(ObservableProperty.THEN_STMT),
649                                 conditional(ObservableProperty.ELSE_STMT, IS_PRESENT, newline()),
650                                 unindent())),
651                 conditional(ObservableProperty.ELSE_STMT, IS_PRESENT,
652                         sequence(token(GeneratedJavaParserConstants.ELSE),
653                                 conditional(Arrays.asList(ObservableProperty.ELSE_BLOCK, ObservableProperty.CASCADING_IF_STMT), CsmConditional.Condition.FLAG,
654                                         sequence(space(), child(ObservableProperty.ELSE_STMT)),
655                                         sequence(newline(), CsmElement.indent(), child(ObservableProperty.ELSE_STMT), unindent()))))
656         ));
657 
concreteSyntaxModelByClass.put(LabeledStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.child(ObservableProperty.LABEL), CsmElement.token(GeneratedJavaParserConstants.COLON), CsmElement.space(), child(ObservableProperty.STATEMENT) ))658         concreteSyntaxModelByClass.put(LabeledStmt.class, CsmElement.sequence(
659                 CsmElement.comment(),
660                 CsmElement.child(ObservableProperty.LABEL),
661                 CsmElement.token(GeneratedJavaParserConstants.COLON),
662                 CsmElement.space(),
663                 child(ObservableProperty.STATEMENT)
664         ));
665 
concreteSyntaxModelByClass.put(LocalClassDeclarationStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.child(ObservableProperty.CLASS_DECLARATION) ))666         concreteSyntaxModelByClass.put(LocalClassDeclarationStmt.class, CsmElement.sequence(
667                 CsmElement.comment(),
668                 CsmElement.child(ObservableProperty.CLASS_DECLARATION)
669         ));
670 
concreteSyntaxModelByClass.put(ReturnStmt.class, sequence(comment(), token(GeneratedJavaParserConstants.RETURN), conditional(ObservableProperty.EXPRESSION, IS_PRESENT, sequence(space(), child(ObservableProperty.EXPRESSION))), semicolon()))671         concreteSyntaxModelByClass.put(ReturnStmt.class, sequence(comment(), token(GeneratedJavaParserConstants.RETURN),
672                 conditional(ObservableProperty.EXPRESSION, IS_PRESENT, sequence(space(), child(ObservableProperty.EXPRESSION))),
673                 semicolon()));
674 
concreteSyntaxModelByClass.put(SwitchEntryStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.conditional(ObservableProperty.LABEL, IS_PRESENT, CsmElement.sequence(CsmElement.token(GeneratedJavaParserConstants.CASE), CsmElement.space(), CsmElement.child(ObservableProperty.LABEL), CsmElement.token(GeneratedJavaParserConstants.COLON)), CsmElement.sequence(CsmElement.token(GeneratedJavaParserConstants._DEFAULT), CsmElement.token(GeneratedJavaParserConstants.COLON))), CsmElement.newline(), CsmElement.indent(), CsmElement.list(ObservableProperty.STATEMENTS, CsmElement.newline(), CsmElement.none(), CsmElement.newline()), CsmElement.unindent() ))675         concreteSyntaxModelByClass.put(SwitchEntryStmt.class, CsmElement.sequence(
676                 CsmElement.comment(),
677                 CsmElement.conditional(ObservableProperty.LABEL, IS_PRESENT,
678                         CsmElement.sequence(CsmElement.token(GeneratedJavaParserConstants.CASE), CsmElement.space(), CsmElement.child(ObservableProperty.LABEL), CsmElement.token(GeneratedJavaParserConstants.COLON)),
679                         CsmElement.sequence(CsmElement.token(GeneratedJavaParserConstants._DEFAULT), CsmElement.token(GeneratedJavaParserConstants.COLON))),
680                 CsmElement.newline(),
681                 CsmElement.indent(),
682                 CsmElement.list(ObservableProperty.STATEMENTS, CsmElement.newline(), CsmElement.none(), CsmElement.newline()),
683                 CsmElement.unindent()
684         ));
685 
concreteSyntaxModelByClass.put(SwitchStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.SWITCH), CsmElement.token(GeneratedJavaParserConstants.LPAREN), CsmElement.child(ObservableProperty.SELECTOR), CsmElement.token(GeneratedJavaParserConstants.RPAREN), CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.LBRACE), CsmElement.newline(), CsmElement.list(ObservableProperty.ENTRIES, CsmElement.none(), CsmElement.indent(), CsmElement.unindent()), CsmElement.token(GeneratedJavaParserConstants.RBRACE) ))686         concreteSyntaxModelByClass.put(SwitchStmt.class, CsmElement.sequence(
687                 CsmElement.comment(),
688                 CsmElement.token(GeneratedJavaParserConstants.SWITCH),
689                 CsmElement.token(GeneratedJavaParserConstants.LPAREN),
690                 CsmElement.child(ObservableProperty.SELECTOR),
691                 CsmElement.token(GeneratedJavaParserConstants.RPAREN),
692                 CsmElement.space(),
693                 CsmElement.token(GeneratedJavaParserConstants.LBRACE),
694                 CsmElement.newline(),
695                 CsmElement.list(ObservableProperty.ENTRIES, CsmElement.none(), CsmElement.indent(), CsmElement.unindent()),
696                 CsmElement.token(GeneratedJavaParserConstants.RBRACE)
697         ));
698 
concreteSyntaxModelByClass.put(SynchronizedStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.SYNCHRONIZED), CsmElement.space(), CsmElement.token(LPAREN), CsmElement.child(EXPRESSION), CsmElement.token(RPAREN), CsmElement.space(), CsmElement.child(BODY) ))699         concreteSyntaxModelByClass.put(SynchronizedStmt.class, CsmElement.sequence(
700                 CsmElement.comment(),
701                 CsmElement.token(GeneratedJavaParserConstants.SYNCHRONIZED),
702                 CsmElement.space(),
703                 CsmElement.token(LPAREN),
704                 CsmElement.child(EXPRESSION),
705                 CsmElement.token(RPAREN),
706                 CsmElement.space(),
707                 CsmElement.child(BODY)
708         ));
709 
concreteSyntaxModelByClass.put(ThrowStmt.class, sequence( comment(), token(GeneratedJavaParserConstants.THROW), space(), child(ObservableProperty.EXPRESSION), semicolon() ))710         concreteSyntaxModelByClass.put(ThrowStmt.class, sequence(
711                 comment(),
712                 token(GeneratedJavaParserConstants.THROW),
713                 space(),
714                 child(ObservableProperty.EXPRESSION),
715                 semicolon()
716         ));
717 
concreteSyntaxModelByClass.put(TryStmt.class, CsmElement.sequence( CsmElement.comment(), CsmElement.token(GeneratedJavaParserConstants.TRY), CsmElement.space(), CsmElement.conditional(ObservableProperty.RESOURCES, CsmConditional.Condition.IS_NOT_EMPTY, CsmElement.sequence( CsmElement.token(LPAREN), list(ObservableProperty.RESOURCES, CsmElement.sequence(CsmElement.semicolon(), CsmElement.newline()), CsmElement.indent(), CsmElement.unindent()), CsmElement.token(RPAREN), CsmElement.space())), CsmElement.child(ObservableProperty.TRY_BLOCK), CsmElement.list(ObservableProperty.CATCH_CLAUSES), CsmElement.conditional(ObservableProperty.FINALLY_BLOCK, IS_PRESENT, CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.FINALLY), CsmElement.space(), CsmElement.child(ObservableProperty.FINALLY_BLOCK))) ))718         concreteSyntaxModelByClass.put(TryStmt.class, CsmElement.sequence(
719                 CsmElement.comment(),
720                 CsmElement.token(GeneratedJavaParserConstants.TRY),
721                 CsmElement.space(),
722                 CsmElement.conditional(ObservableProperty.RESOURCES, CsmConditional.Condition.IS_NOT_EMPTY, CsmElement.sequence(
723                         CsmElement.token(LPAREN),
724                         list(ObservableProperty.RESOURCES, CsmElement.sequence(CsmElement.semicolon(), CsmElement.newline()), CsmElement.indent(), CsmElement.unindent()),
725                         CsmElement.token(RPAREN),
726                         CsmElement.space())),
727                 CsmElement.child(ObservableProperty.TRY_BLOCK),
728                 CsmElement.list(ObservableProperty.CATCH_CLAUSES),
729                 CsmElement.conditional(ObservableProperty.FINALLY_BLOCK, IS_PRESENT, CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.FINALLY), CsmElement.space(), CsmElement.child(ObservableProperty.FINALLY_BLOCK)))
730         ));
731 
concreteSyntaxModelByClass.put(WhileStmt.class, sequence( comment(), token(GeneratedJavaParserConstants.WHILE), space(), token(GeneratedJavaParserConstants.LPAREN), child(ObservableProperty.CONDITION), token(GeneratedJavaParserConstants.RPAREN), space(), child(ObservableProperty.BODY) ))732         concreteSyntaxModelByClass.put(WhileStmt.class, sequence(
733                 comment(),
734                 token(GeneratedJavaParserConstants.WHILE),
735                 space(),
736                 token(GeneratedJavaParserConstants.LPAREN),
737                 child(ObservableProperty.CONDITION),
738                 token(GeneratedJavaParserConstants.RPAREN),
739                 space(),
740                 child(ObservableProperty.BODY)
741         ));
742 
743         ///
744         /// Types
745         ///
746 
concreteSyntaxModelByClass.put(ArrayType.class, sequence( child(ObservableProperty.COMPONENT_TYPE), list(ObservableProperty.ANNOTATIONS), string(GeneratedJavaParserConstants.LBRACKET), string(GeneratedJavaParserConstants.RBRACKET)))747         concreteSyntaxModelByClass.put(ArrayType.class, sequence(
748                 child(ObservableProperty.COMPONENT_TYPE),
749                 list(ObservableProperty.ANNOTATIONS),
750                 string(GeneratedJavaParserConstants.LBRACKET),
751                 string(GeneratedJavaParserConstants.RBRACKET)));
752 
concreteSyntaxModelByClass.put(ClassOrInterfaceType.class, sequence(comment(), conditional(SCOPE, IS_PRESENT, sequence(child(SCOPE), string(GeneratedJavaParserConstants.DOT))), list(ANNOTATIONS, space()), child(NAME), conditional(ObservableProperty.USING_DIAMOND_OPERATOR, FLAG, sequence(string(GeneratedJavaParserConstants.LT), string(GeneratedJavaParserConstants.GT)), list(TYPE_ARGUMENTS, sequence(comma(), space()), string(GeneratedJavaParserConstants.LT), string(GeneratedJavaParserConstants.GT)))))753         concreteSyntaxModelByClass.put(ClassOrInterfaceType.class, sequence(comment(),
754                 conditional(SCOPE, IS_PRESENT, sequence(child(SCOPE), string(GeneratedJavaParserConstants.DOT))),
755                 list(ANNOTATIONS, space()),
756                 child(NAME),
757                 conditional(ObservableProperty.USING_DIAMOND_OPERATOR, FLAG,
758                         sequence(string(GeneratedJavaParserConstants.LT), string(GeneratedJavaParserConstants.GT)),
759                         list(TYPE_ARGUMENTS, sequence(comma(), space()), string(GeneratedJavaParserConstants.LT), string(GeneratedJavaParserConstants.GT)))));
760 
concreteSyntaxModelByClass.put(IntersectionType.class, CsmElement.sequence( CsmElement.comment(), annotations(), CsmElement.list(ObservableProperty.ELEMENTS, CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.BIT_AND), CsmElement.space()))))761         concreteSyntaxModelByClass.put(IntersectionType.class, CsmElement.sequence(
762                 CsmElement.comment(),
763                 annotations(),
764                 CsmElement.list(ObservableProperty.ELEMENTS, CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.BIT_AND), CsmElement.space()))));
765 
concreteSyntaxModelByClass.put(PrimitiveType.class, sequence( comment(), list(ObservableProperty.ANNOTATIONS), attribute(ObservableProperty.TYPE)))766         concreteSyntaxModelByClass.put(PrimitiveType.class, sequence(
767                 comment(),
768                 list(ObservableProperty.ANNOTATIONS),
769                 attribute(ObservableProperty.TYPE)));
770 
concreteSyntaxModelByClass.put(TypeParameter.class, sequence( comment(), annotations(), child(ObservableProperty.NAME), list(ObservableProperty.TYPE_BOUND, sequence( space(), token(GeneratedJavaParserConstants.BIT_AND), space()), sequence( space(), token(GeneratedJavaParserConstants.EXTENDS), space()), none()) ))771         concreteSyntaxModelByClass.put(TypeParameter.class, sequence(
772                 comment(),
773                 annotations(),
774                 child(ObservableProperty.NAME),
775                 list(ObservableProperty.TYPE_BOUND,
776                         sequence(
777                                 space(),
778                                 token(GeneratedJavaParserConstants.BIT_AND),
779                                 space()),
780                         sequence(
781                                 space(),
782                                 token(GeneratedJavaParserConstants.EXTENDS),
783                                 space()),
784                         none())
785         ));
786 
concreteSyntaxModelByClass.put(UnionType.class, CsmElement.sequence( CsmElement.comment(), annotations(), CsmElement.list(ObservableProperty.ELEMENTS, CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.BIT_OR), CsmElement.space())) ))787         concreteSyntaxModelByClass.put(UnionType.class, CsmElement.sequence(
788                 CsmElement.comment(),
789                 annotations(),
790                 CsmElement.list(ObservableProperty.ELEMENTS, CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.BIT_OR), CsmElement.space()))
791         ));
792 
concreteSyntaxModelByClass.put(UnknownType.class, none())793         concreteSyntaxModelByClass.put(UnknownType.class, none());
794 
concreteSyntaxModelByClass.put(VoidType.class, sequence(comment(), annotations(), token(GeneratedJavaParserConstants.VOID)))795         concreteSyntaxModelByClass.put(VoidType.class, sequence(comment(), annotations(), token(GeneratedJavaParserConstants.VOID)));
796 
concreteSyntaxModelByClass.put(VarType.class, sequence(comment(), annotations(), string(GeneratedJavaParserConstants.IDENTIFIER, "var")))797         concreteSyntaxModelByClass.put(VarType.class, sequence(comment(), annotations(), string(GeneratedJavaParserConstants.IDENTIFIER, "var")));
798 
concreteSyntaxModelByClass.put(WildcardType.class, sequence(comment(), annotations(), token(GeneratedJavaParserConstants.HOOK), CsmElement.conditional(ObservableProperty.EXTENDED_TYPE, IS_PRESENT, CsmElement.sequence(space(), token(GeneratedJavaParserConstants.EXTENDS), space(), CsmElement.child(EXTENDED_TYPE))), CsmElement.conditional(ObservableProperty.SUPER_TYPE, IS_PRESENT, CsmElement.sequence(space(), token(GeneratedJavaParserConstants.SUPER), space(), CsmElement.child(SUPER_TYPE)))))799         concreteSyntaxModelByClass.put(WildcardType.class, sequence(comment(), annotations(), token(GeneratedJavaParserConstants.HOOK),
800                 CsmElement.conditional(ObservableProperty.EXTENDED_TYPE, IS_PRESENT, CsmElement.sequence(space(), token(GeneratedJavaParserConstants.EXTENDS), space(), CsmElement.child(EXTENDED_TYPE))),
801                 CsmElement.conditional(ObservableProperty.SUPER_TYPE, IS_PRESENT, CsmElement.sequence(space(), token(GeneratedJavaParserConstants.SUPER), space(), CsmElement.child(SUPER_TYPE)))));
802 
803         ///
804         /// Top Level
805         ///
806 
concreteSyntaxModelByClass.put(ArrayCreationLevel.class, sequence( annotations(), token(GeneratedJavaParserConstants.LBRACKET), child(ObservableProperty.DIMENSION), token(GeneratedJavaParserConstants.RBRACKET) ))807         concreteSyntaxModelByClass.put(ArrayCreationLevel.class, sequence(
808                 annotations(),
809                 token(GeneratedJavaParserConstants.LBRACKET),
810                 child(ObservableProperty.DIMENSION),
811                 token(GeneratedJavaParserConstants.RBRACKET)
812         ));
813 
concreteSyntaxModelByClass.put(CompilationUnit.class, sequence( comment(), child(ObservableProperty.PACKAGE_DECLARATION), list(ObservableProperty.IMPORTS, none(), none(), newline()), list(TYPES, newline(), CsmElement.newline(), CsmElement.none(), CsmElement.newline()), child(ObservableProperty.MODULE), orphanCommentsEnding()))814         concreteSyntaxModelByClass.put(CompilationUnit.class, sequence(
815                 comment(),
816                 child(ObservableProperty.PACKAGE_DECLARATION),
817                 list(ObservableProperty.IMPORTS, none(), none(), newline()),
818                 list(TYPES, newline(), CsmElement.newline(), CsmElement.none(), CsmElement.newline()),
819                 child(ObservableProperty.MODULE),
820                 orphanCommentsEnding()));
821 
concreteSyntaxModelByClass.put(ImportDeclaration.class, sequence( comment(), token(GeneratedJavaParserConstants.IMPORT), space(), conditional(ObservableProperty.STATIC, FLAG, sequence(token(GeneratedJavaParserConstants.STATIC), space())), child(ObservableProperty.NAME), conditional(ASTERISK, FLAG, sequence(token(GeneratedJavaParserConstants.DOT), token(GeneratedJavaParserConstants.STAR))), semicolon(), newline(), orphanCommentsEnding() ))822         concreteSyntaxModelByClass.put(ImportDeclaration.class, sequence(
823                 comment(),
824                 token(GeneratedJavaParserConstants.IMPORT),
825                 space(),
826                 conditional(ObservableProperty.STATIC, FLAG, sequence(token(GeneratedJavaParserConstants.STATIC), space())),
827                 child(ObservableProperty.NAME),
828                 conditional(ASTERISK, FLAG, sequence(token(GeneratedJavaParserConstants.DOT), token(GeneratedJavaParserConstants.STAR))),
829                 semicolon(),
830                 newline(),
831                 orphanCommentsEnding()
832         ));
833 
concreteSyntaxModelByClass.put(PackageDeclaration.class, sequence( comment(), list(ObservableProperty.ANNOTATIONS), token(GeneratedJavaParserConstants.PACKAGE), space(), child(ObservableProperty.NAME), semicolon(), newline(), newline(), orphanCommentsEnding()))834         concreteSyntaxModelByClass.put(PackageDeclaration.class, sequence(
835                 comment(),
836                 list(ObservableProperty.ANNOTATIONS),
837                 token(GeneratedJavaParserConstants.PACKAGE),
838                 space(),
839                 child(ObservableProperty.NAME),
840                 semicolon(),
841                 newline(),
842                 newline(),
843                 orphanCommentsEnding()));
844 
845         ///
846         /// Module info
847         ///
848 
concreteSyntaxModelByClass.put(ModuleDeclaration.class, CsmElement.sequence( annotations(), CsmElement.conditional(ObservableProperty.OPEN, FLAG, CsmElement.sequence(CsmElement.token(GeneratedJavaParserConstants.OPEN), CsmElement.space())), CsmElement.token(GeneratedJavaParserConstants.MODULE), CsmElement.space(), CsmElement.child(ObservableProperty.NAME), CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.LBRACE), CsmElement.newline(), CsmElement.indent(), CsmElement.list(ObservableProperty.MODULE_STMTS), CsmElement.unindent(), CsmElement.token(GeneratedJavaParserConstants.RBRACE), CsmElement.newline() ))849         concreteSyntaxModelByClass.put(ModuleDeclaration.class, CsmElement.sequence(
850                 annotations(),
851                 CsmElement.conditional(ObservableProperty.OPEN, FLAG, CsmElement.sequence(CsmElement.token(GeneratedJavaParserConstants.OPEN), CsmElement.space())),
852                 CsmElement.token(GeneratedJavaParserConstants.MODULE),
853                 CsmElement.space(),
854                 CsmElement.child(ObservableProperty.NAME),
855                 CsmElement.space(),
856                 CsmElement.token(GeneratedJavaParserConstants.LBRACE),
857                 CsmElement.newline(),
858                 CsmElement.indent(),
859                 CsmElement.list(ObservableProperty.MODULE_STMTS),
860                 CsmElement.unindent(),
861                 CsmElement.token(GeneratedJavaParserConstants.RBRACE),
862                 CsmElement.newline()
863         ));
864 
concreteSyntaxModelByClass.put(ModuleExportsStmt.class, CsmElement.sequence( CsmElement.token(GeneratedJavaParserConstants.EXPORTS), CsmElement.space(), CsmElement.child(ObservableProperty.NAME), CsmElement.list(ObservableProperty.MODULE_NAMES, CsmElement.sequence(CsmElement.comma(), CsmElement.space()), CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.TO), CsmElement.space()), CsmElement.none()), CsmElement.semicolon(), CsmElement.newline() ))865         concreteSyntaxModelByClass.put(ModuleExportsStmt.class, CsmElement.sequence(
866                 CsmElement.token(GeneratedJavaParserConstants.EXPORTS),
867                 CsmElement.space(),
868                 CsmElement.child(ObservableProperty.NAME),
869                 CsmElement.list(ObservableProperty.MODULE_NAMES,
870                         CsmElement.sequence(CsmElement.comma(), CsmElement.space()),
871                         CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.TO), CsmElement.space()),
872                         CsmElement.none()),
873                 CsmElement.semicolon(),
874                 CsmElement.newline()
875         ));
876 
concreteSyntaxModelByClass.put(ModuleOpensStmt.class, CsmElement.sequence( CsmElement.token(GeneratedJavaParserConstants.OPENS), CsmElement.space(), CsmElement.child(ObservableProperty.NAME), CsmElement.list(ObservableProperty.MODULE_NAMES, CsmElement.sequence(CsmElement.comma(), CsmElement.space()), CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.TO), CsmElement.space()), CsmElement.none()), CsmElement.semicolon(), CsmElement.newline() ))877         concreteSyntaxModelByClass.put(ModuleOpensStmt.class, CsmElement.sequence(
878                 CsmElement.token(GeneratedJavaParserConstants.OPENS),
879                 CsmElement.space(),
880                 CsmElement.child(ObservableProperty.NAME),
881                 CsmElement.list(ObservableProperty.MODULE_NAMES,
882                         CsmElement.sequence(CsmElement.comma(), CsmElement.space()),
883                         CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.TO), CsmElement.space()),
884                         CsmElement.none()),
885                 CsmElement.semicolon(),
886                 CsmElement.newline()
887         ));
888 
concreteSyntaxModelByClass.put(ModuleProvidesStmt.class, CsmElement.sequence( CsmElement.token(GeneratedJavaParserConstants.PROVIDES), CsmElement.space(), CsmElement.child(ObservableProperty.TYPE), CsmElement.list(ObservableProperty.WITH_TYPES, CsmElement.sequence(CsmElement.comma(), CsmElement.space()), CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.WITH), CsmElement.space()), CsmElement.none()), CsmElement.semicolon(), CsmElement.newline() ))889         concreteSyntaxModelByClass.put(ModuleProvidesStmt.class, CsmElement.sequence(
890                 CsmElement.token(GeneratedJavaParserConstants.PROVIDES),
891                 CsmElement.space(),
892                 CsmElement.child(ObservableProperty.TYPE),
893                 CsmElement.list(ObservableProperty.WITH_TYPES,
894                         CsmElement.sequence(CsmElement.comma(), CsmElement.space()),
895                         CsmElement.sequence(CsmElement.space(), CsmElement.token(GeneratedJavaParserConstants.WITH), CsmElement.space()),
896                         CsmElement.none()),
897                 CsmElement.semicolon(),
898                 CsmElement.newline()
899         ));
900 
concreteSyntaxModelByClass.put(ModuleRequiresStmt.class, CsmElement.sequence( CsmElement.token(GeneratedJavaParserConstants.REQUIRES), CsmElement.space(), modifiers(), CsmElement.child(ObservableProperty.NAME), CsmElement.semicolon(), CsmElement.newline() ))901         concreteSyntaxModelByClass.put(ModuleRequiresStmt.class, CsmElement.sequence(
902                 CsmElement.token(GeneratedJavaParserConstants.REQUIRES),
903                 CsmElement.space(),
904                 modifiers(),
905                 CsmElement.child(ObservableProperty.NAME),
906                 CsmElement.semicolon(),
907                 CsmElement.newline()
908         ));
909 
concreteSyntaxModelByClass.put(ModuleUsesStmt.class, CsmElement.sequence( CsmElement.token(GeneratedJavaParserConstants.USES), CsmElement.space(), CsmElement.child(ObservableProperty.TYPE), CsmElement.semicolon(), CsmElement.newline() ))910         concreteSyntaxModelByClass.put(ModuleUsesStmt.class, CsmElement.sequence(
911                 CsmElement.token(GeneratedJavaParserConstants.USES),
912                 CsmElement.space(),
913                 CsmElement.child(ObservableProperty.TYPE),
914                 CsmElement.semicolon(),
915                 CsmElement.newline()
916         ));
917 
918         List<String> unsupportedNodeClassNames = JavaParserMetaModel.getNodeMetaModels().stream()
919                 .filter(c -> !c.isAbstract() && !Comment.class.isAssignableFrom(c.getType()) && !concreteSyntaxModelByClass.containsKey(c.getType()))
920                 .map(nm -> nm.getType().getSimpleName())
921                 .collect(Collectors.toList());
922         if (unsupportedNodeClassNames.isEmpty()) {
923             initializationError = Optional.empty();
924         } else {
925             initializationError = Optional.of("The CSM should include support for these classes: " + String.join(", ", unsupportedNodeClassNames));
926         }
927     }
928 
ConcreteSyntaxModel()929     private ConcreteSyntaxModel() {
930 
931     }
932 
genericPrettyPrint(Node node, SourcePrinter printer)933     public static void genericPrettyPrint(Node node, SourcePrinter printer) {
934         forClass(node.getClass()).prettyPrint(node, printer);
935     }
936 
genericPrettyPrint(Node node)937     public static String genericPrettyPrint(Node node) {
938         SourcePrinter sourcePrinter = new SourcePrinter("    ", EOL);
939         forClass(node.getClass()).prettyPrint(node, sourcePrinter);
940         return sourcePrinter.getSource();
941     }
942 
forClass(Class<? extends Node> nodeClazz)943     public static CsmElement forClass(Class<? extends Node> nodeClazz) {
944         initializationError.ifPresent(s -> {
945             throw new IllegalStateException(s);
946         });
947         if (!concreteSyntaxModelByClass.containsKey(nodeClazz)) {
948             throw new UnsupportedOperationException(nodeClazz.getSimpleName());
949         }
950         return concreteSyntaxModelByClass.get(nodeClazz);
951     }
952 
953 }
954