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

  1. Install IntelliJ IDEA (the free or the commercial edition).
  2. Download a BaseX distribution.
  3. If queries are to be run on a BaseX server, start a Database Server: either basexserver, or basexhttp with -L (see Startup).

Installation

  1. Open the Settings dialog: File → Settings… (on macOS: IntelliJ IDEA → Settings…), or Plugins on the welcome screen.
  2. Select Plugins and the Marketplace tab.
  3. Search for “XQuery and XSLT” and click Install.
  4. Restart IntelliJ IDEA if you are prompted to do so.

Configuration

XQuery Settings

  1. In the Settings dialog, select Languages & Frameworks → XQuery.
  2. Choose the following values:
    Field Value
    Implementation BaseX
    Implementation version The most recent BaseX version offered by the plugin
    Default XQuery version The most recent XQuery version offered by the plugin
    Dialects BaseX
  3. Click OK.

Query Processor

  1. Select Run → Edit Configurations…, then Edit configuration templates… and the XQuery template.
  2. Click the … button next to Query Processor, and add a new processor with +:
    Field Value
    Description BaseX (optional)
    Implementation BaseX
    JAR File The BaseX.jar file of your distribution
    Hostname, Database port localhost, 1984
    Username, Password The credentials of a BaseX user
    If Create a standalone instance is checked, queries are run by an embedded BaseX instance, and the connection fields remain empty.
  3. Select the new processor in the Manage Query Processors dialog, and close all dialogs with OK.

Running Queries

  1. Create a project, e.g. with File → New → Project… and Empty Project.
  2. 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.
  3. Select Run → Edit Configurations…, click + and choose XQuery.
  4. 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.
  5. 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