Skip to content

Commit 50130c3

Browse files
joewizclaude
andcommitted
[refactor] Address review feedback from @reinhapa
Convert version if-else chain in XQueryTree.g to switch-as-expression. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ba34ead commit 50130c3

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

  • exist-core/src/main/antlr/org/exist/xquery/parser

exist-core/src/main/antlr/org/exist/xquery/parser/XQueryTree.g

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -451,17 +451,13 @@ throws PermissionDeniedException, EXistException, XPathException
451451
v:VERSION_DECL
452452
{
453453
final String version = v.getText();
454-
if (version.equals("4.0")) {
455-
context.setXQueryVersion(40);
456-
} else if (version.equals("3.1")) {
457-
context.setXQueryVersion(31);
458-
} else if (version.equals("3.0")) {
459-
context.setXQueryVersion(30);
460-
} else if (version.equals("1.0")) {
461-
context.setXQueryVersion(10);
462-
} else {
463-
throw new XPathException(v, ErrorCodes.XQST0031, "Wrong XQuery version: require 1.0, 3.0, 3.1, or 4.0");
464-
}
454+
context.setXQueryVersion(switch (version) {
455+
case "4.0" -> 40;
456+
case "3.1" -> 31;
457+
case "3.0" -> 30;
458+
case "1.0" -> 10;
459+
default -> throw new XPathException(v, ErrorCodes.XQST0031, "Wrong XQuery version: require 1.0, 3.0, 3.1, or 4.0");
460+
});
465461
}
466462
( enc:STRING_LITERAL )?
467463
{

0 commit comments

Comments
 (0)