Main Page » Getting Started » Integrating IntelliJ IDEA
Integrating IntelliJ IDEA
This article describes how to run XQuery code from within the IntelliJ IDEA IDE with the XQuery and XSLT plugin (xquery-intellij-plugin) by Reece H. Dunn. The plugin offers syntax highlighting, code completion and error detection, and it runs queries with BaseX, either as client of a BaseX server or as standalone instance.
Note: The XQuery Support plugin by Grzegorz Ligas is no longer maintained: its last version supports IntelliJ IDEA 2019.1. We also encourage you to use the editor of the BaseX GUI, which supports all features of XQuery 4.0 and BaseX.
Preparations
- Install IntelliJ IDEA (the free or the commercial edition).
- Download a BaseX distribution.
- If queries are to be run on a BaseX server, start a Database Server: either
basexserver, orbasexhttpwith-L(see Startup).
Installation
- Open the Settings dialog: File → Settings… (on macOS: IntelliJ IDEA → Settings…), or Plugins on the welcome screen.
- Select Plugins and the Marketplace tab.
- Search for “XQuery and XSLT” and click Install.
- Restart IntelliJ IDEA if you are prompted to do so.
Configuration
XQuery Settings
- In the Settings dialog, select Languages & Frameworks → XQuery.
- Choose the following values:
Field Value Implementation BaseXImplementation version The most recent BaseX version offered by the plugin Default XQuery version The most recent XQuery version offered by the plugin Dialects BaseX - Click OK.
Query Processor
- Select Run → Edit Configurations…, then Edit configuration templates… and the XQuery template.
- Click the
…button next to Query Processor, and add a new processor with+:
If Create a standalone instance is checked, queries are run by an embedded BaseX instance, and the connection fields remain empty.Field Value Description BaseX(optional)Implementation BaseXJAR File The BaseX.jarfile of your distributionHostname, Database port localhost,1984Username, Password The credentials of a BaseX user - Select the new processor in the Manage Query Processors dialog, and close all dialogs with OK.
Running Queries
- Create a project, e.g. with File → New → Project… and Empty Project.
- Create a query file in the project view (New → File, e.g.
query.xq), enter a query, e.g.db:get('factbook'), and save it. - Select Run → Edit Configurations…, click
+and choose XQuery. - Enter a name, check that the BaseX processor is selected, and choose under Run the query from either the query file (Local file) or Active editor file. Click OK.
- Run the query with Run → Run (Shift F10). If the processor is a client, the BaseX server must be running.
The database log of the server can be displayed with the Query Log button in the lower left corner of the project window.
⚡Generated with XQuery