Skip to content

Commit c366862

Browse files
committed
Remove redundant calls to fullErrorText
1 parent 053a141 commit c366862

File tree

1 file changed

+43
-79
lines changed

1 file changed

+43
-79
lines changed

lkql_jit/language/src/main/java/com/adacore/lkql_jit/exception/LKQLRuntimeException.java

Lines changed: 43 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public static LKQLRuntimeException fromMessage(String message) {
7373
@CompilerDirectives.TruffleBoundary
7474
public static LKQLRuntimeException fromJavaException(Throwable e, SourceLocation location) {
7575
LKQLRuntimeException res =
76-
new LKQLRuntimeException(
77-
fullErrorText("Error from Java bindings: " + e.getMessage(), location));
76+
LKQLRuntimeException.fromMessage(
77+
"Error from Java bindings: " + e.getMessage(), location);
7878
res.setStackTrace(e.getStackTrace());
7979
return res;
8080
}
@@ -89,8 +89,8 @@ public static LKQLRuntimeException fromJavaException(Throwable e, SourceLocation
8989
@CompilerDirectives.TruffleBoundary
9090
public static LKQLRuntimeException fromJavaException(Throwable e, Locatable location) {
9191
LKQLRuntimeException res =
92-
new LKQLRuntimeException(
93-
fullErrorText("Error from Java bindings: " + e.getMessage(), location));
92+
LKQLRuntimeException.fromMessage(
93+
"Error from Java bindings: " + e.getMessage(), location);
9494
res.setStackTrace(e.getStackTrace());
9595
return res;
9696
}
@@ -103,7 +103,7 @@ public static LKQLRuntimeException fromJavaException(Throwable e, Locatable loca
103103
*/
104104
@CompilerDirectives.TruffleBoundary
105105
public static LKQLRuntimeException shouldNotExecute(Locatable location) {
106-
return new LKQLRuntimeException(fullErrorText("Should not execute", location));
106+
return LKQLRuntimeException.fromMessage("Should not execute", location);
107107
}
108108

109109
/**
@@ -151,8 +151,8 @@ public static LKQLRuntimeException parsingException(
151151
*/
152152
@CompilerDirectives.TruffleBoundary
153153
public static LKQLRuntimeException regexSyntaxError(String regex, Locatable location) {
154-
return new LKQLRuntimeException(
155-
fullErrorText("Failed to compile regular expression: " + regex, location));
154+
return LKQLRuntimeException.fromMessage(
155+
"Failed to compile regular expression: " + regex, location);
156156
}
157157

158158
/**
@@ -163,9 +163,8 @@ public static LKQLRuntimeException regexSyntaxError(String regex, Locatable loca
163163
*/
164164
@CompilerDirectives.TruffleBoundary
165165
public static LKQLRuntimeException ignoredExpressionReturn(Locatable location) {
166-
return new LKQLRuntimeException(
167-
fullErrorText(
168-
"Can't ignore the return value of an expr in a block expr", location));
166+
return LKQLRuntimeException.fromMessage(
167+
"Can't ignore the return value of an expr in a block expr", location);
169168
}
170169

171170
/** Create a new exception when a key appears many times in the same object literal. */
@@ -187,7 +186,7 @@ public static LKQLRuntimeException multipleSameNameKeys(String key, Locatable lo
187186
*/
188187
@CompilerDirectives.TruffleBoundary
189188
public static LKQLRuntimeException unknownSymbol(String symbol, Locatable location) {
190-
return new LKQLRuntimeException(fullErrorText("Unknown symbol: " + symbol, location));
189+
return LKQLRuntimeException.fromMessage("Unknown symbol: " + symbol, location);
191190
}
192191

193192
/**
@@ -199,8 +198,7 @@ public static LKQLRuntimeException unknownSymbol(String symbol, Locatable locati
199198
*/
200199
@CompilerDirectives.TruffleBoundary
201200
public static LKQLRuntimeException existingSymbol(String symbol, Locatable location) {
202-
return new LKQLRuntimeException(
203-
fullErrorText("Already existing symbol: " + symbol, location));
201+
return LKQLRuntimeException.fromMessage("Already existing symbol: " + symbol, location);
204202
}
205203

206204
/**
@@ -212,8 +210,7 @@ public static LKQLRuntimeException existingSymbol(String symbol, Locatable locat
212210
*/
213211
@CompilerDirectives.TruffleBoundary
214212
public static LKQLRuntimeException existingParameter(String symbol, Locatable location) {
215-
return new LKQLRuntimeException(
216-
fullErrorText("Already existing parameter: " + symbol, location));
213+
return LKQLRuntimeException.fromMessage("Already existing parameter: " + symbol, location);
217214
}
218215

219216
/**
@@ -224,7 +221,7 @@ public static LKQLRuntimeException existingParameter(String symbol, Locatable lo
224221
*/
225222
@CompilerDirectives.TruffleBoundary
226223
public static LKQLRuntimeException invalidKindName(Locatable location) {
227-
return new LKQLRuntimeException(fullErrorText("Invalid kind name", location));
224+
return LKQLRuntimeException.fromMessage("Invalid kind name", location);
228225
}
229226

230227
/**
@@ -236,8 +233,8 @@ public static LKQLRuntimeException invalidKindName(Locatable location) {
236233
*/
237234
@CompilerDirectives.TruffleBoundary
238235
public static LKQLRuntimeException moduleNotFound(String moduleName, Locatable location) {
239-
return new LKQLRuntimeException(
240-
fullErrorText("Cannot import, module not found \"" + moduleName + "\"", location));
236+
return LKQLRuntimeException.fromMessage(
237+
"Cannot import, module not found \"" + moduleName + "\"", location);
241238
}
242239

243240
// --- Typing exception
@@ -253,8 +250,8 @@ public static LKQLRuntimeException moduleNotFound(String moduleName, Locatable l
253250
@CompilerDirectives.TruffleBoundary
254251
public static LKQLRuntimeException wrongType(
255252
String expected, String actual, Locatable location) {
256-
return new LKQLRuntimeException(
257-
fullErrorText("Type error: expected " + expected + " but got " + actual, location));
253+
return LKQLRuntimeException.fromMessage(
254+
"Type error: expected " + expected + " but got " + actual, location);
258255
}
259256

260257
/**
@@ -267,8 +264,8 @@ public static LKQLRuntimeException wrongType(
267264
*/
268265
public static LKQLRuntimeException conversionError(
269266
String source, String target, Locatable location) {
270-
return new LKQLRuntimeException(
271-
fullErrorText("Cannot convert a " + source + " to a " + target, location));
267+
return LKQLRuntimeException.fromMessage(
268+
"Cannot convert a " + source + " to a " + target, location);
272269
}
273270

274271
/**
@@ -279,8 +276,7 @@ public static LKQLRuntimeException conversionError(
279276
*/
280277
@CompilerDirectives.TruffleBoundary
281278
public static LKQLRuntimeException wrongFrom(Locatable location) {
282-
return new LKQLRuntimeException(
283-
fullErrorText("Wrong kind of element in `from clause`", location));
279+
return LKQLRuntimeException.fromMessage("Wrong kind of element in `from clause`", location);
284280
}
285281

286282
/**
@@ -291,35 +287,8 @@ public static LKQLRuntimeException wrongFrom(Locatable location) {
291287
*/
292288
@CompilerDirectives.TruffleBoundary
293289
public static LKQLRuntimeException wrongFromList(Locatable location) {
294-
return new LKQLRuntimeException(
295-
fullErrorText("Wrong kind of element in list for `from clause`", location));
296-
}
297-
298-
/**
299-
* Create an exception from a wrong use of type in a selector.
300-
*
301-
* @param wrongType The used type in the selector.
302-
* @param location The location of the type.
303-
* @return The exception.
304-
*/
305-
@CompilerDirectives.TruffleBoundary
306-
public static LKQLRuntimeException wrongSelectorType(String wrongType, Locatable location) {
307-
return new LKQLRuntimeException(
308-
fullErrorText(
309-
"Cannot use values of kind " + wrongType + " in a selector", location));
310-
}
311-
312-
/**
313-
* Create an exception for a wrong pattern type.
314-
*
315-
* @param wrongType The wrong pattern type in a string.
316-
* @param location The location of the exception.
317-
* @return The exception.
318-
*/
319-
@CompilerDirectives.TruffleBoundary
320-
public static LKQLRuntimeException wrongPatternType(String wrongType, Locatable location) {
321-
return new LKQLRuntimeException(
322-
fullErrorText("Invalid pattern kind: " + wrongType, location));
290+
return LKQLRuntimeException.fromMessage(
291+
"Wrong kind of element in list for `from clause`", location);
323292
}
324293

325294
/**
@@ -331,9 +300,8 @@ public static LKQLRuntimeException wrongPatternType(String wrongType, Locatable
331300
*/
332301
@CompilerDirectives.TruffleBoundary
333302
public static LKQLRuntimeException unsupportedType(String type, Locatable location) {
334-
return new LKQLRuntimeException(
335-
fullErrorText(
336-
"Unsupported value type from the introspection API: " + type, location));
303+
return LKQLRuntimeException.fromMessage(
304+
"Unsupported value type from the introspection API: " + type, location);
337305
}
338306

339307
// --- Operator exception
@@ -350,10 +318,8 @@ public static LKQLRuntimeException unsupportedType(String type, Locatable locati
350318
@CompilerDirectives.TruffleBoundary
351319
public static LKQLRuntimeException unsupportedOperation(
352320
String leftType, String op, String rightType, Locatable location) {
353-
return new LKQLRuntimeException(
354-
fullErrorText(
355-
"Unsupported operation: " + leftType + " " + op + " " + rightType,
356-
location));
321+
return LKQLRuntimeException.fromMessage(
322+
"Unsupported operation: " + leftType + " " + op + " " + rightType, location);
357323
}
358324

359325
/**
@@ -364,7 +330,7 @@ public static LKQLRuntimeException unsupportedOperation(
364330
*/
365331
@CompilerDirectives.TruffleBoundary
366332
public static LKQLRuntimeException divByZero(Locatable location) {
367-
return new LKQLRuntimeException(fullErrorText("Zero division", location));
333+
return LKQLRuntimeException.fromMessage("Zero division", location);
368334
}
369335

370336
/**
@@ -376,7 +342,7 @@ public static LKQLRuntimeException divByZero(Locatable location) {
376342
*/
377343
@CompilerDirectives.TruffleBoundary
378344
public static LKQLRuntimeException invalidIndex(int index, Locatable location) {
379-
return new LKQLRuntimeException(fullErrorText("Invalid index: " + index, location));
345+
return LKQLRuntimeException.fromMessage("Invalid index: " + index, location);
380346
}
381347

382348
/**
@@ -387,7 +353,7 @@ public static LKQLRuntimeException invalidIndex(int index, Locatable location) {
387353
*/
388354
@CompilerDirectives.TruffleBoundary
389355
public static LKQLRuntimeException noSuchMember(Locatable location) {
390-
return new LKQLRuntimeException(fullErrorText("No such member", location));
356+
return LKQLRuntimeException.fromMessage("No such member", location);
391357
}
392358

393359
/**
@@ -398,7 +364,7 @@ public static LKQLRuntimeException noSuchMember(Locatable location) {
398364
*/
399365
@CompilerDirectives.TruffleBoundary
400366
public static LKQLRuntimeException noSuchField(Locatable location) {
401-
return new LKQLRuntimeException(fullErrorText("No such field", location));
367+
return LKQLRuntimeException.fromMessage("No such field", location);
402368
}
403369

404370
/**
@@ -411,8 +377,8 @@ public static LKQLRuntimeException noSuchField(Locatable location) {
411377
*/
412378
@CompilerDirectives.TruffleBoundary
413379
public static LKQLRuntimeException wrongMember(String member, String type, Locatable location) {
414-
return new LKQLRuntimeException(
415-
fullErrorText("Cannot get member " + member + " for " + type + " value", location));
380+
return LKQLRuntimeException.fromMessage(
381+
"Cannot get member " + member + " for " + type + " value", location);
416382
}
417383

418384
/**
@@ -423,7 +389,7 @@ public static LKQLRuntimeException wrongMember(String member, String type, Locat
423389
*/
424390
@CompilerDirectives.TruffleBoundary
425391
public static LKQLRuntimeException nullReceiver(Locatable location) {
426-
return new LKQLRuntimeException(fullErrorText("Null receiver in dot access", location));
392+
return LKQLRuntimeException.fromMessage("Null receiver in dot access", location);
427393
}
428394

429395
// --- Argument exception
@@ -438,8 +404,8 @@ public static LKQLRuntimeException nullReceiver(Locatable location) {
438404
*/
439405
@CompilerDirectives.TruffleBoundary
440406
public static LKQLRuntimeException wrongArity(int expected, int actual, Locatable location) {
441-
return new LKQLRuntimeException(
442-
fullErrorText("Expected " + expected + " arguments but got " + actual, location));
407+
return LKQLRuntimeException.fromMessage(
408+
"Expected " + expected + " arguments but got " + actual, location);
443409
}
444410

445411
/**
@@ -451,8 +417,7 @@ public static LKQLRuntimeException wrongArity(int expected, int actual, Locatabl
451417
*/
452418
@CompilerDirectives.TruffleBoundary
453419
public static LKQLRuntimeException unknownArgument(String unknown, Locatable location) {
454-
return new LKQLRuntimeException(
455-
fullErrorText("Unknown argument name: " + unknown, location));
420+
return LKQLRuntimeException.fromMessage("Unknown argument name: " + unknown, location);
456421
}
457422

458423
/**
@@ -464,8 +429,8 @@ public static LKQLRuntimeException unknownArgument(String unknown, Locatable loc
464429
*/
465430
@CompilerDirectives.TruffleBoundary
466431
public static LKQLRuntimeException missingArgument(int missingIndex, Locatable location) {
467-
return new LKQLRuntimeException(
468-
fullErrorText("Missing value for param # " + missingIndex + " in call", location));
432+
return LKQLRuntimeException.fromMessage(
433+
"Missing value for param # " + missingIndex + " in call", location);
469434
}
470435

471436
/**
@@ -476,8 +441,8 @@ public static LKQLRuntimeException missingArgument(int missingIndex, Locatable l
476441
*/
477442
@CompilerDirectives.TruffleBoundary
478443
public static LKQLRuntimeException selectorWithoutNode(Locatable location) {
479-
return new LKQLRuntimeException(
480-
fullErrorText("Selector call should have a node argument", location));
444+
return LKQLRuntimeException.fromMessage(
445+
"Selector call should have a node argument", location);
481446
}
482447

483448
/**
@@ -488,8 +453,7 @@ public static LKQLRuntimeException selectorWithoutNode(Locatable location) {
488453
*/
489454
@CompilerDirectives.TruffleBoundary
490455
public static LKQLRuntimeException multipleSameNameArgument(Locatable location) {
491-
return new LKQLRuntimeException(
492-
fullErrorText("Multiple arguments with the same name", location));
456+
return LKQLRuntimeException.fromMessage("Multiple arguments with the same name", location);
493457
}
494458

495459
/**
@@ -500,8 +464,8 @@ public static LKQLRuntimeException multipleSameNameArgument(Locatable location)
500464
*/
501465
@CompilerDirectives.TruffleBoundary
502466
public static LKQLRuntimeException positionAfterNamedArgument(Locatable location) {
503-
return new LKQLRuntimeException(
504-
fullErrorText("positional argument after named argument", location));
467+
return LKQLRuntimeException.fromMessage(
468+
"positional argument after named argument", location);
505469
}
506470

507471
// ----- Class methods -----

0 commit comments

Comments
 (0)