Skip to content

Commit 66c0f97

Browse files
committed
Add String parser overload when SourceLocation is not available
1 parent c93fd5a commit 66c0f97

2 files changed

Lines changed: 23 additions & 19 deletions

File tree

src/main/java/graphql/parser/StringValueParsing.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,8 @@ public static String parseSingleQuotedString(String string, SourceLocation sourc
148148
}
149149
return writer.toString();
150150
}
151+
152+
public static String parseSingleQuotedString(String string) {
153+
return parseSingleQuotedString(string, null);
154+
}
151155
}

src/test/groovy/graphql/parser/StringValueParsingUnicodeTest.groovy

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class StringValueParsingUnicodeTest extends Specification {
2525
def input = '''"\\u{1F37A} hello"'''
2626

2727
when:
28-
String parsed = StringValueParsing.parseSingleQuotedString(input, null)
28+
String parsed = StringValueParsing.parseSingleQuotedString(input)
2929

3030
then:
3131
parsed == '''🍺 hello''' // contains the beer icon U+1F37A : http://www.charbase.com/1f37a-unicode-beer-mug
@@ -36,7 +36,7 @@ class StringValueParsingUnicodeTest extends Specification {
3636
def input = '''"🍺 hello"'''
3737

3838
when:
39-
String parsed = StringValueParsing.parseSingleQuotedString(input, null)
39+
String parsed = StringValueParsing.parseSingleQuotedString(input)
4040

4141
then:
4242
parsed == '''🍺 hello''' // contains the beer icon U+1F37A : http://www.charbase.com/1f37a-unicode-beer-mug
@@ -60,7 +60,7 @@ class StringValueParsingUnicodeTest extends Specification {
6060
def input = '''"\\uD83D hello"'''
6161

6262
when:
63-
StringValueParsing.parseSingleQuotedString(input, null)
63+
StringValueParsing.parseSingleQuotedString(input)
6464

6565
then:
6666
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -72,7 +72,7 @@ class StringValueParsingUnicodeTest extends Specification {
7272
def input = '''"\\uD83D"'''
7373

7474
when:
75-
StringValueParsing.parseSingleQuotedString(input, null)
75+
StringValueParsing.parseSingleQuotedString(input)
7676

7777
then:
7878
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -84,7 +84,7 @@ class StringValueParsingUnicodeTest extends Specification {
8484
def input = '''"\\uD83D\\uDBFF"'''
8585

8686
when:
87-
StringValueParsing.parseSingleQuotedString(input, null)
87+
StringValueParsing.parseSingleQuotedString(input)
8888

8989
then:
9090
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -96,7 +96,7 @@ class StringValueParsingUnicodeTest extends Specification {
9696
def input = '''"\\uDC00"'''
9797

9898
when:
99-
StringValueParsing.parseSingleQuotedString(input, null)
99+
StringValueParsing.parseSingleQuotedString(input)
100100

101101
then:
102102
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -108,7 +108,7 @@ class StringValueParsingUnicodeTest extends Specification {
108108
def input = '''"\\uD700\\uDC00"'''
109109

110110
when:
111-
StringValueParsing.parseSingleQuotedString(input, null)
111+
StringValueParsing.parseSingleQuotedString(input)
112112

113113
then:
114114
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -120,7 +120,7 @@ class StringValueParsingUnicodeTest extends Specification {
120120
def input = '''"hello \\u{d83c}\\udf7a"'''
121121

122122
when:
123-
String parsed = StringValueParsing.parseSingleQuotedString(input, null)
123+
String parsed = StringValueParsing.parseSingleQuotedString(input)
124124

125125
then:
126126
parsed == '''hello 🍺''' // contains the beer icon U+1F37 A : http://www.charbase.com/1f37a-unicode-beer-mug
@@ -131,7 +131,7 @@ class StringValueParsingUnicodeTest extends Specification {
131131
def input = '''"hello \\ud83c\\u{df7a}"'''
132132

133133
when:
134-
String parsed = StringValueParsing.parseSingleQuotedString(input, null)
134+
String parsed = StringValueParsing.parseSingleQuotedString(input)
135135

136136
then:
137137
parsed == '''hello 🍺''' // contains the beer icon U+1F37A : http://www.charbase.com/1f37a-unicode-beer-mug
@@ -142,7 +142,7 @@ class StringValueParsingUnicodeTest extends Specification {
142142
def input = '''"hello \\u{d83c}\\u{df7a}"'''
143143

144144
when:
145-
String parsed = StringValueParsing.parseSingleQuotedString(input, null)
145+
String parsed = StringValueParsing.parseSingleQuotedString(input)
146146

147147
then:
148148
parsed == '''hello 🍺''' // contains the beer icon U+1F37A : http://www.charbase.com/1f37a-unicode-beer-mug
@@ -153,7 +153,7 @@ class StringValueParsingUnicodeTest extends Specification {
153153
def input = '''"hello \\u{d83c}\\"'''
154154

155155
when:
156-
StringValueParsing.parseSingleQuotedString(input, null)
156+
StringValueParsing.parseSingleQuotedString(input)
157157

158158
then:
159159
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -165,7 +165,7 @@ class StringValueParsingUnicodeTest extends Specification {
165165
def input = '''"hello \\u{d83c}\\u"'''
166166

167167
when:
168-
StringValueParsing.parseSingleQuotedString(input, null)
168+
StringValueParsing.parseSingleQuotedString(input)
169169

170170
then:
171171
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -177,7 +177,7 @@ class StringValueParsingUnicodeTest extends Specification {
177177
def input = '''"hello \\u{d83c}\\u{df7a"'''
178178

179179
when:
180-
StringValueParsing.parseSingleQuotedString(input, null)
180+
StringValueParsing.parseSingleQuotedString(input)
181181

182182
then:
183183
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -189,7 +189,7 @@ class StringValueParsingUnicodeTest extends Specification {
189189
def input = '''"hello \\u{d83c}{df7a}"'''
190190

191191
when:
192-
StringValueParsing.parseSingleQuotedString(input, null)
192+
StringValueParsing.parseSingleQuotedString(input)
193193

194194
then:
195195
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -201,7 +201,7 @@ class StringValueParsingUnicodeTest extends Specification {
201201
def input = '''"hello \\u{d83c}df7a"'''
202202

203203
when:
204-
StringValueParsing.parseSingleQuotedString(input, null)
204+
StringValueParsing.parseSingleQuotedString(input)
205205

206206
then:
207207
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -213,7 +213,7 @@ class StringValueParsingUnicodeTest extends Specification {
213213
def input = '''"hello d83c\\u{df7a}"'''
214214

215215
when:
216-
StringValueParsing.parseSingleQuotedString(input, null)
216+
StringValueParsing.parseSingleQuotedString(input)
217217

218218
then:
219219
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -225,7 +225,7 @@ class StringValueParsingUnicodeTest extends Specification {
225225
def input = '''"\\u{5B57}\\uDC00"'''
226226

227227
when:
228-
StringValueParsing.parseSingleQuotedString(input, null)
228+
StringValueParsing.parseSingleQuotedString(input)
229229

230230
then:
231231
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -237,7 +237,7 @@ class StringValueParsingUnicodeTest extends Specification {
237237
def input = '''"\\uD83D\\u{DBFF}"'''
238238

239239
when:
240-
StringValueParsing.parseSingleQuotedString(input, null)
240+
StringValueParsing.parseSingleQuotedString(input)
241241

242242
then:
243243
InvalidSyntaxException e = thrown(InvalidSyntaxException)
@@ -249,7 +249,7 @@ class StringValueParsingUnicodeTest extends Specification {
249249
def input = '''"\\u{fffffff}"'''
250250

251251
when:
252-
StringValueParsing.parseSingleQuotedString(input, null)
252+
StringValueParsing.parseSingleQuotedString(input)
253253

254254
then:
255255
InvalidSyntaxException e = thrown(InvalidSyntaxException)

0 commit comments

Comments
 (0)