Integrating IntelliJ IDEA

From BaseX Documentation

(Difference between revisions)
Jump to: navigation, search
 
(3 intermediate revisions not shown)
Line 3: Line 3:
* The [https://plugins.jetbrains.com/plugin/8612-xquery-intellij-plugin xquery-intellij-plugin] by Reece H. Dunn.
* The [https://plugins.jetbrains.com/plugin/8612-xquery-intellij-plugin xquery-intellij-plugin] by Reece H. Dunn.
* The [https://plugins.jetbrains.com/plugin/7262-xquery-support XQuery Support] plugin by Grzegorz Ligas.
* The [https://plugins.jetbrains.com/plugin/7262-xquery-support XQuery Support] plugin by Grzegorz Ligas.
-
* Both plugins offer support for XQuery 3.1 and can be run as a client or standalone instance.
+
* Both plugins offer support for XQuery 3.1 and can be run as a client or standalone instance. Please note that the two plugins are mutually exclusive and cannot be activated at the same time in IntelliJ.  
* '''Note:''' BaseX itself is a highly compliant XQuery 3.1 processor. We strongly encourage you to use the [[Graphical_User_Interface#Text_Editor|XML editor]] integrated into the BaseX GUI to edit and query your XML data!<br/><br/>
* '''Note:''' BaseX itself is a highly compliant XQuery 3.1 processor. We strongly encourage you to use the [[Graphical_User_Interface#Text_Editor|XML editor]] integrated into the BaseX GUI to edit and query your XML data!<br/><br/>
Line 67: Line 67:
* In the ''Manage Query Processors'' dialog, click on the {{Code|+}} button.
* In the ''Manage Query Processors'' dialog, click on the {{Code|+}} button.
* In the ''New Query Processor Instance'' dialog, set the following preferences:
* In the ''New Query Processor Instance'' dialog, set the following preferences:
-
** <code>Name = BaseX</code> (optional; if you leave this field blank, <code>[Implementation] [Version]</code> will be used as name)
+
** <code>Description = BaseX</code> (optional; if you leave this field blank, <code>[Implementation] [Version]</code> will be used as description)
** <code>Implementation = BaseX</code> (should be preset!)
** <code>Implementation = BaseX</code> (should be preset!)
** <code>JAR File = BaseX.jar</code> (name and location of the JAR file may differ depending on your BaseX distribution and version)
** <code>JAR File = BaseX.jar</code> (name and location of the JAR file may differ depending on your BaseX distribution and version)
Line 103: Line 103:
==Conclusion==
==Conclusion==
-
The plugin is very well maintained! It adds support for various XQuery Implementations to the IntelliJ IDEA (among them BaseX). It provides syntax highlighting for XQuery and XML and detects syntactical errors while you type offering a description for each error. Queries are executed using Run Configurations for which you can configure various query processors, e.g. BaseX.
+
The plugin is very well maintained! It adds support for various XQuery Implementations to the IntelliJ IDEA (among them BaseX). It provides syntax highlighting for XQuery and XML, code completion and detects syntactical errors while you type offering a description for each error. Queries are executed using Run Configurations for which you can configure various query processors, e.g. BaseX.
-
The plugin contains some minor flaws regarding the static binding of BaseX namespaces. A few namespaces are marked as unknown in the code, however, query execution in the BaseX backend works fine in spite of them. Also, the IntelliJ ''Find Usages'' and ''Go To'' options did not work as expected in some cases, especially with regard to functions and across modules. The plugin does not yet include a code completion feature.
+
BaseX's admin log can be accessed and displayed using the '''Query Log''' button on the bottom left corner of the IntelliJ IDEA project window.
-
Note that the usage of functions from imported or declared namespaces that do not exist in the namespace might not be marked as unknown. To highlight invalid functions, you may enable the ''XPath and XQuery > XPST: XPath static errors > XPST0017: Undefined function'' inspection in the ''Editor > Inspections'' section.
+
The plugin contains some minor flaws regarding the use of functions declared in user-defined modules. Such functions are not included in the code completion list and marked as unknown in the code. However, query execution in the BaseX backend works fine nonetheless.
=XQuery Support Plugin=
=XQuery Support Plugin=

Latest revision as of 09:13, 21 August 2019

This article is part of the Getting Started Section. It describes how to run XPath/XQuery code from within the IntelliJ IDEA IDE. There are currently two XQuery plugins for IntelliJ IDEA on the market:

Contents

[edit] Preparations

The following steps apply to all operating systems and both plugins:

[edit] xquery-intellij-plugin

This section focuses on Reece H. Dunn's xquery-intellij-plugin.

[edit] Installation

After installing IntelliJ IDEA and BaseX, install the xquery-intellij-plugin by one of the following methods:

From the Start Screen

Intellij-startbildschirm.png

From the IntelliJ IDEA Menu

[edit] Configuring The Processor

Intellij-xquery-settings-2.png

[edit] Querying Your Data

Create a New Project

Customize the XQuery Module

Intellij-add-configuration.png

Intellij-new-query-processor.png

Create a Query File

Create a New Configuration

Intellij-xquery-configuration.png

Intellij-run-button.png

Execute Your Query

[edit] Conclusion

The plugin is very well maintained! It adds support for various XQuery Implementations to the IntelliJ IDEA (among them BaseX). It provides syntax highlighting for XQuery and XML, code completion and detects syntactical errors while you type offering a description for each error. Queries are executed using Run Configurations for which you can configure various query processors, e.g. BaseX.

BaseX's admin log can be accessed and displayed using the Query Log button on the bottom left corner of the IntelliJ IDEA project window.

The plugin contains some minor flaws regarding the use of functions declared in user-defined modules. Such functions are not included in the code completion list and marked as unknown in the code. However, query execution in the BaseX backend works fine nonetheless.

[edit] XQuery Support Plugin

This section focuses on Grzegorz Ligas' XQuery Support plugin.

[edit] Installation

After installing IntelliJ IDEA and BaseX, install the XQuery Support plugin by one of the following methods:

From the Start Screen

From the IntelliJ IDEA Menu

[edit] Setting Up

File Extensions and XQuery Flavor

Intellij-xquery-settings.png

[edit] Configuring The Processor

You can set up the plugin as a standalone processor or client.

[edit] Standalone

[edit] Client

This assumes that you already have a BaseX database named factbook.

Intellij-basex-data-source.png

[edit] Querying Your Data

Create a New Project

Customize the XQuery Module

Intellij-add-configuration.png

Create a Query File

Intellij-query.png

Create a New Configuration

Intellij-xquery-configuration2.png

Intellij-run-button.png

Execute Your Query

[edit] Conclusion

The plugin adds support for various XQuery Implementations to the IntelliJ IDEA (among them BaseX). It provides syntax highlighting for XQuery and XML and detects syntactical errors while you type offering a description for each error. Queries are executed using Run Configurations for which you can configure various query processors, e.g. BaseX. The plugin offers code completion for XQuery functions, integrated library modules, such as FunctX or the BaseX Module Library, and user-defined modules. IntelliJ’s Find Usages and Go To options seem to work fine for variables and functions, even across modules. Users can set XQuery-specific code style preferences.

This plugin also has a few minor drawbacks. If no path is specified, syntax highlighting marks user-defined modules as unknown, even if they reside in the designated BaseX module repository. However, the BaseX query processor, resolves them correctly during query execution. Error messages in the editor seem to be kept rather general and should me more specific. Parameter lists of code completion may be quite extensive and clog the screen. Leading tab space can be increased in user-defined steps, but neither decreased in single, nor user-defined steps.

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export