|
12 | 12 | import twg2.parser.codeParser.AccessModifier;
|
13 | 13 | import twg2.parser.codeParser.extractors.DataTypeExtractor;
|
14 | 14 | import twg2.parser.codeParser.tools.NameUtil;
|
15 |
| -import twg2.parser.fragment.CodeFragment; |
16 |
| -import twg2.parser.fragment.CodeFragmentType; |
| 15 | +import twg2.parser.fragment.CodeToken; |
| 16 | +import twg2.parser.fragment.CodeTokenType; |
17 | 17 | import twg2.parser.output.WriteSettings;
|
18 | 18 | import twg2.text.stringEscape.StringEscapeJson;
|
19 | 19 | import twg2.treeLike.simpleTree.SimpleTree;
|
|
24 | 24 | */
|
25 | 25 | @Immutable
|
26 | 26 | public class FieldDef extends FieldSig {
|
27 |
| - private final @Getter SimpleTree<CodeFragment> initializer; |
| 27 | + private final @Getter SimpleTree<CodeToken> initializer; |
28 | 28 |
|
29 | 29 |
|
30 | 30 | public FieldDef(String name, List<String> fullName, TypeSigSimple fieldType, List<AccessModifier> accessModifiers,
|
31 |
| - List<AnnotationSig> annotations, List<String> comments, SimpleTree<CodeFragment> initializer) { |
| 31 | + List<AnnotationSig> annotations, List<String> comments, SimpleTree<CodeToken> initializer) { |
32 | 32 | super(name, fullName, fieldType, accessModifiers, annotations, comments);
|
33 | 33 | this.initializer = initializer;
|
34 | 34 | }
|
@@ -68,12 +68,12 @@ public String toString() {
|
68 | 68 | /** Write a field initializer to a JSON field named 'initializer' if the value is a number, boolean, string, or null literal, else write it to a field named 'initializerExpression'
|
69 | 69 | * @throws IOException
|
70 | 70 | */
|
71 |
| - public static void initializerToJson(SimpleTree<CodeFragment> astNode, boolean preClosingComma, Appendable dst, WriteSettings st) throws IOException { |
72 |
| - CodeFragment data = null; |
| 71 | + public static void initializerToJson(SimpleTree<CodeToken> astNode, boolean preClosingComma, Appendable dst, WriteSettings st) throws IOException { |
| 72 | + CodeToken data = null; |
73 | 73 | boolean isNumOrBoolOrNull = false;
|
74 | 74 | if(astNode != null && !astNode.hasChildren() && (data = astNode.getData()) != null &&
|
75 |
| - (data.getFragmentType() == CodeFragmentType.STRING || |
76 |
| - (isNumOrBoolOrNull = (data.getFragmentType() == CodeFragmentType.NUMBER || DataTypeExtractor.isBooleanLiteral(data) || DataTypeExtractor.isNullLiteral(data))))) { |
| 75 | + (data.getTokenType() == CodeTokenType.STRING || |
| 76 | + (isNumOrBoolOrNull = (data.getTokenType() == CodeTokenType.NUMBER || DataTypeExtractor.isBooleanLiteral(data) || DataTypeExtractor.isNullLiteral(data))))) { |
77 | 77 | if(preClosingComma) {
|
78 | 78 | dst.append(", ");
|
79 | 79 | }
|
|
0 commit comments