Last year I needed to implemented a larger project with Datalog/Soufflé for my Master’s Thesis. Being an avid user of graphical IDEs, my first reflex was to search for a Datalog plugin for IntelliJ to speed up my development process. After a fruitless search and some futile attempts to use some general-purpose language extensions instead, I quickly decided to just implement a suitable Datalog plugin myself. Here’s what it can do and how to get it:

Features

Syntax Highlighting

The plugin features extensive syntax highlighting. In addition it renders identifiers differently based on the semantic information inferred from your code. For instance, variables in relations will use a italic font while instances of components will use an underscore effect.

Syntax Highlighting

As with all common language plugins for JetBrains IDEs, the syntax highlighting is fully customizable and can even be disabled entirely if you like to keep it plain.

Highlighting Options

Reference Resolution

The plugin keeps track of all identifiers and their corresponding declaration-sites, which enables a lot of advanced code editing goodies.

Want to jump to an identifier’s definition? Just click it while pressing CTRL! As you can see in the following example, this also works in the reverse direction: CTRL-click a definition to see a list of its usages.

Reference Resolution

In addition, the plugin also supports most of the common reference-resolution related features found in Jetbrains IDEs which can be triggered by various keyboard shortcuts.

Refactoring

Not happy with your identifiers’ names? Press SHIFT-F6 and rename it in no time!

Refactoring 1

Of course refactoring also works over multiple files, as well as for relations that within components.

Refactoring 2

Quick Definition and Documentation

Use the IDEs quick-definition keyboard shortcuts to view an identifiers definition, without jumping to a different code section.

Quick-Definition

Annotate your code with JavaDoc-style comments to provide documentation for relations, components and even preprocessor definitions.

Quick-Documentation 1

The documentation for an identifier can be queried by the IDEs quick-documentation keyboard shortcut.

Quick-Documentation 2

Code Completion and Parameter Hints

One of the features I love most about IDEs from JetBrains is their context-sensitive auto-completion. While typing, the IDE will show you a list of suggestions that might complete your current input. Wherever possible, it will only suggest completions that make sense semantically.

Code Completion

When filling in the parameters of a function or relation and unsure, press CTRL-P to see the signature of the relation.

Parameter Hints

Code Analysis

In order to find bugs in the code before it is passed to Soufflé, the plugin will highlight potential errors.

For instance, undefined identifiers will be highlighted.

Missing Declaration

Missing parameters will be reported…

Missing Parameter

…as will be superfluous parameters.

Superfluous Parameter

Furthermore, the IDE will issue a warning when variables are used only once in a relation rule.

Unused Variable

Automatic Formatting

Admittedly, this feature is not quite mature yet, but the plugin also supports automatic code formatting. For instance, new lines will be correctly indented when defining rules for a relation.

Formatting 1

Code formatting can also be triggered manually for a whole file.

Formatting 2

How to Get It

The plugin supports all JetBrains IDEs (i.e. IntelliJ, PyCharm, WebStorm, etc.) and can be obtained via their built-in plugin manager. Just search for Datalog Language Support in the marketplace section of the plugin dialog.

The plugin is listed on the JetBrains plugin repo.

Its source code is available on GitHub.