From 585cde59baf04a350957561e8079954298daef34 Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Sat, 29 Jul 2023 16:55:40 +0200 Subject: [PATCH] [refactor] Swap arguments for internal consistency purposes --- .../java/org/exist/xquery/ModuleContext.java | 10 ++++------ .../java/org/exist/xquery/XQueryContext.java | 18 +++++++++--------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/exist-core/src/main/java/org/exist/xquery/ModuleContext.java b/exist-core/src/main/java/org/exist/xquery/ModuleContext.java index 4ae437712b2..858ff2cdf18 100644 --- a/exist-core/src/main/java/org/exist/xquery/ModuleContext.java +++ b/exist-core/src/main/java/org/exist/xquery/ModuleContext.java @@ -58,19 +58,17 @@ public class ModuleContext extends XQueryContext { private static final Logger LOG = LogManager.getLogger(ModuleContext.class); private XQueryContext parentContext; - private String modulePrefix; private String moduleNamespace; + private String modulePrefix; private final String location; - public ModuleContext(final XQueryContext parentContext, final String modulePrefix, final String moduleNamespace, - final String location) { + public ModuleContext(final XQueryContext parentContext, final String moduleNamespace, final String modulePrefix, final String location) { super(parentContext != null ? parentContext.db : null, parentContext != null ? parentContext.getConfiguration() : null, null, false); - - this.modulePrefix = modulePrefix; this.moduleNamespace = moduleNamespace; + this.modulePrefix = modulePrefix; this.location = location; setParentContext(parentContext); @@ -196,7 +194,7 @@ public void updateContext(final XQueryContext from) { @Override public XQueryContext copyContext() { - final ModuleContext ctx = new ModuleContext(parentContext, modulePrefix, moduleNamespace, location); + final ModuleContext ctx = new ModuleContext(parentContext, moduleNamespace, modulePrefix, location); copyFields(ctx); try { ctx.declareNamespace(modulePrefix, moduleNamespace); diff --git a/exist-core/src/main/java/org/exist/xquery/XQueryContext.java b/exist-core/src/main/java/org/exist/xquery/XQueryContext.java index 8a94bc26b59..68256f1a2e3 100644 --- a/exist-core/src/main/java/org/exist/xquery/XQueryContext.java +++ b/exist-core/src/main/java/org/exist/xquery/XQueryContext.java @@ -577,7 +577,7 @@ public Optional getRepository() { // use the resolved file or return null // build a module object from the file final Source src = new FileSource(resolved, false); - return compileOrBorrowModule(prefix, namespace, "", src); + return compileOrBorrowModule(namespace, prefix, "", src); } /** @@ -2516,7 +2516,7 @@ public void mapModule(final String namespace, final XmldbURI uri) { } final Source moduleSource = new DBSource(getBroker().getBrokerPool(), (BinaryDocument) sourceDoc, true); - return compileOrBorrowModule(prefix, namespaceURI, location, moduleSource); + return compileOrBorrowModule(namespaceURI, prefix, location, moduleSource); } catch (final PermissionDeniedException e) { throw moduleLoadException("Permission denied to read module source from location hint URI '" + location + ".", location, e); @@ -2553,7 +2553,7 @@ public void mapModule(final String namespace, final XmldbURI uri) { throw moduleLoadException("Permission denied to read module source from location hint URI '" + location + ".", location, e); } - return compileOrBorrowModule(prefix, namespaceURI, location, moduleSource); + return compileOrBorrowModule(namespaceURI, prefix, location, moduleSource); } protected XPathException moduleLoadException(final String message, final String moduleLocation) @@ -2585,8 +2585,8 @@ public Iterator getMappedModuleURIs() { /** * Compile of borrow an already compile module from the cache. * - * @param prefix the module namespace prefix * @param namespaceURI the module namespace URI + * @param prefix the module namespace prefix * @param location the location hint * @param source the source for the module * @@ -2594,9 +2594,9 @@ public Iterator getMappedModuleURIs() { * * @throws XPathException if the module could not be loaded (XQST0059) or compiled (XPST0003) */ - private ExternalModule compileOrBorrowModule(final String prefix, final String namespaceURI, final String location, + private ExternalModule compileOrBorrowModule(final String namespaceURI, final String prefix, final String location, final Source source) throws XPathException { - final ExternalModule module = compileModule(prefix, namespaceURI, location, source); + final ExternalModule module = compileModule(namespaceURI, prefix, location, source); if (module != null) { addModule(module.getNamespaceURI(), module); declareModuleVars(module); @@ -2607,14 +2607,14 @@ private ExternalModule compileOrBorrowModule(final String prefix, final String n /** * Compile an XQuery Module * - * @param prefix the namespace prefix of the module. * @param namespaceURI the namespace URI of the module. + * @param prefix the namespace prefix of the module. * @param location the location of the module * @param source the source of the module. * @return The compiled module, or null if the source is not a module * @throws XPathException if the module could not be loaded (XQST0059) or compiled (XPST0003) */ - private @Nullable ExternalModule compileModule(final String prefix, String namespaceURI, final String location, + private @Nullable ExternalModule compileModule(String namespaceURI, final String prefix, final String location, final Source source) throws XPathException { if (LOG.isDebugEnabled()) { LOG.debug("Loading module from {}", location); @@ -2635,7 +2635,7 @@ private ExternalModule compileOrBorrowModule(final String prefix, final String n } final ExternalModuleImpl modExternal = new ExternalModuleImpl(namespaceURI, prefix); - final XQueryContext modContext = new ModuleContext(this, prefix, namespaceURI, location); + final XQueryContext modContext = new ModuleContext(this, namespaceURI, prefix, location); modExternal.setContext(modContext); final XQueryLexer lexer = new XQueryLexer(modContext, reader); final XQueryParser parser = new XQueryParser(lexer);