|
5 | 5 | import graphql.Assert; |
6 | 6 | import graphql.Internal; |
7 | 7 | import graphql.collect.ImmutableKit; |
| 8 | +import graphql.i18n.I18n; |
8 | 9 | import graphql.language.Argument; |
9 | 10 | import graphql.language.ArrayValue; |
10 | 11 | import graphql.language.BooleanValue; |
@@ -91,44 +92,16 @@ public class GraphqlAntlrToLanguage { |
91 | 92 | private final CommonTokenStream tokens; |
92 | 93 | private final MultiSourceReader multiSourceReader; |
93 | 94 | private final ParserOptions parserOptions; |
94 | | - |
95 | 95 | private final Map<Node<?>, ParserRuleContext> nodeToRuleMap; |
| 96 | + private final I18n i18N; |
96 | 97 |
|
97 | | - /** |
98 | | - * @param tokens the token stream |
99 | | - * @param multiSourceReader the source of the query document |
100 | | - */ |
101 | | - public GraphqlAntlrToLanguage(CommonTokenStream tokens, MultiSourceReader multiSourceReader) { |
102 | | - this(tokens, multiSourceReader, null); |
103 | | - } |
104 | | - |
105 | | - /** |
106 | | - * @param tokens the token stream |
107 | | - * @param multiSourceReader the source of the query document |
108 | | - * @param parserOptions the parser options |
109 | | - */ |
110 | | - public GraphqlAntlrToLanguage(CommonTokenStream tokens, MultiSourceReader multiSourceReader, ParserOptions parserOptions) { |
111 | | - this(tokens, multiSourceReader, parserOptions, null); |
112 | | - } |
113 | | - |
114 | | - /** |
115 | | - * @param tokens the token stream |
116 | | - * @param multiSourceReader the source of the query document |
117 | | - * @param parserOptions the parser options |
118 | | - * @param nodeToRuleMap a map that will be used to accumulate the ParserRuleContext associated with each node. |
119 | | - * This information can be used after the parsing process is done to access some elements |
120 | | - * that are usually lost during parsing. If the map is "null", no accumulation will be performed. |
121 | | - */ |
122 | | - public GraphqlAntlrToLanguage( |
123 | | - CommonTokenStream tokens, |
124 | | - MultiSourceReader multiSourceReader, |
125 | | - ParserOptions parserOptions, |
126 | | - @Nullable Map<Node<?>, ParserRuleContext> nodeToRuleMap |
127 | | - ) { |
| 98 | + public GraphqlAntlrToLanguage(CommonTokenStream tokens, MultiSourceReader multiSourceReader, ParserOptions parserOptions, I18n i18N, @Nullable Map<Node<?>, ParserRuleContext> nodeToRuleMap) { |
128 | 99 | this.tokens = tokens; |
129 | 100 | this.multiSourceReader = multiSourceReader; |
130 | 101 | this.parserOptions = ofNullable(parserOptions).orElse(ParserOptions.getDefaultParserOptions()); |
| 102 | + this.i18N = i18N; |
131 | 103 | this.nodeToRuleMap = nodeToRuleMap; |
| 104 | + |
132 | 105 | } |
133 | 106 |
|
134 | 107 | public ParserOptions getParserOptions() { |
@@ -244,7 +217,7 @@ protected SelectionSet createSelectionSet(GraphqlParser.SelectionSetContext ctx) |
244 | 217 | if (selectionContext.inlineFragment() != null) { |
245 | 218 | return createInlineFragment(selectionContext.inlineFragment()); |
246 | 219 | } |
247 | | - return (Selection) Assert.assertShouldNeverHappen(); |
| 220 | + return Assert.assertShouldNeverHappen(); |
248 | 221 |
|
249 | 222 | }); |
250 | 223 | builder.selections(selections); |
@@ -803,7 +776,7 @@ protected String quotedString(TerminalNode terminalNode) { |
803 | 776 | if (multiLine) { |
804 | 777 | return parseTripleQuotedString(strText); |
805 | 778 | } else { |
806 | | - return parseSingleQuotedString(strText, sourceLocation); |
| 779 | + return parseSingleQuotedString(i18N, strText, sourceLocation); |
807 | 780 | } |
808 | 781 | } |
809 | 782 |
|
@@ -880,7 +853,7 @@ protected Description newDescription(GraphqlParser.DescriptionContext descriptio |
880 | 853 | if (multiLine) { |
881 | 854 | content = parseTripleQuotedString(content); |
882 | 855 | } else { |
883 | | - content = parseSingleQuotedString(content, sourceLocation); |
| 856 | + content = parseSingleQuotedString(i18N, content, sourceLocation); |
884 | 857 | } |
885 | 858 | return new Description(content, sourceLocation, multiLine); |
886 | 859 | } |
|
0 commit comments