XQuery + MarkLogic — VSCode ExtensionRich XQuery editing support for Visual Studio Code, with full coverage of the
MarkLogic Features
Supported file extensions
Supported dialects
InstallationFrom the VS Code Marketplace
From a
|
| Trigger | What you get |
|---|---|
Type xdmp: |
All xdmp: functions with snippet insertion |
Type cts: |
All cts: search functions |
Type fn: |
W3C standard fn: functions |
Type xs: |
All xs: constructor functions |
Type $ |
Variables declared above the cursor |
Type % |
XQuery 3.0 annotation names |
After as |
Built-in types (xs:string, item(), node()…) |
Snippets
| Prefix | Expands to |
|---|---|
xqversion |
xquery version "1.0-ml"; |
module |
Module namespace declaration |
import |
Import module statement |
fn |
Declare function scaffold |
var |
Declare variable |
flwor |
Full FLWOR expression |
if |
If-then-else |
typeswitch |
Typeswitch with cases |
try |
Try-catch block |
log |
xdmp:log(…) |
search |
cts:search(…) |
eval |
xdmp:eval(…) |
Go to Definition
- Ctrl+Click (or F12) on a local function call → jumps to its
declare function - Ctrl+Click on a
$variable→ jumps to itslet,for, ordeclare variablebinding - Ctrl+Click on a namespace prefix in
import module namespace pfx = … at "path.xqy"→ opens the target file if it exists in the workspace (supports both relative and server-absolute paths)
Diagnostics
The extension runs a multi-phase linting engine automatically as you type and on save.
Real-time checks (debounced, 500 ms):
| Check | What it catches |
|---|---|
| Unclosed comment | Unmatched (: / :) |
| Unclosed string | Unclosed " or ' (handles doubled-delimiter escapes) |
| Unmatched brackets | Unmatched { } and ( ) |
| Unclosed XML element | Tags opened but never closed |
| Missing semicolon | Declaration or statement missing ; |
| Invalid version | Version string other than "1.0", "1.0-ml", "3.0", "3.1" |
| Variable before declaration | Using $var before it is declared |
| Duplicate functions | Same function declared twice in the same file |
| Unused declared variables | declare variable never referenced |
| Unused functions | declare function never called |
| Unused function parameters | Parameter declared but not used in its function body |
| Empty catch | catch block with no error handling |
| Deprecated functions | Calls to deprecated MarkLogic functions |
| Unused namespace declarations | declare namespace prefix never used |
| Namespace conflict | Conflicting declare default function namespace |
| Missing return type | declare function without an explicit return type |
| MarkLogic in standard mode | MarkLogic-specific constructs in a non-1.0-ml file |
| Unresolved variables | Reference to an undefined variable |
| Unresolved functions | Call to a function not declared or imported |
| Unresolved XML namespaces | XML element/attribute prefix not declared |
On-save checks (cross-file):
| Check | What it catches |
|---|---|
| Cross-file duplicate functions | Function name conflicts across imported modules |
| Cross-file unresolved functions | Calls to functions not found in any imported module |
Scope
This extension covers language editing only: syntax highlighting, completions, hover, signature help, go-to-definition, document symbols, diagnostics, and snippets.
The following are out of scope for this extension:
- Database connections and query execution
- Debugging
- Cross-file import resolution without a local
at "..."path
Not yet implemented:
- Code folding (planned)
Contributing
- Fork the repository
npm install- Open in VS Code and press
F5to launch the Extension Development Host - Make changes, run
npm run compileto type-check,npm run buildto bundle - Submit a pull request
License
Apache 2.0 — see LICENSE and NOTICE.
This project is a derivative work of the marklogic-intellij-plugin by Grzegorz Ligas and contributors, also licensed under Apache 2.0.
"MarkLogic" is a registered trademark of Progress Software Corporation. This is an independent community project, not affiliated with or endorsed by Progress Software Corporation.