In IntelliJ IDEA, projects are consisting of one or more modules, which are separated different parts. A simple example would be a Wolfram package that uses Java to provide additional features through JLink. In such a setting, you usually have two different modules:
- A Java module that contains all the Java sources and settings to compile the code into a
- A Wolfram Language module that contains all the Wolfram package code
This provides a clear separation so that you can work on the Java module independently.
You can easily set up an artifact that places the compiled Java
.jar in the correct directory inside the Wolfram
module so that the integration is seamlessly.
However, the Wolfram Language Plugin does not require a particular module structure and you can edit any Wolfram Language file within your project. Additionally, not all IntelliJ IDE’s (like PyCharm) support a project/module structure like IDEA does.
The advantage of setting up a Wolfram module for your project is that helps the plugin to understand which Wolfram sources belong together. Also, you can add other Wolfram packages as Dependencies to enable auto-completion and code navigation. To edit the structure of you project, go to File | Project Structure…
To explain some details, the IGraphM package is used as an example.
The important parts are:
- There is a Wolfram Language module called
IGraphM. Note the wolf logo in front of the name which indicates that it is indeed a Wolfram module and not a Java, Kotlin, Android, etc. module. This is important for the plugin to provide cross-file code completion and refactoring.
- Within a Wolfram module, you can set the module language level which is used to check your code against a specific version. See the Language Version Inspection for details.
IGraphMfolder is marked as sources in blue, but two subfolders are excluded. This indicates where the source files of your package reside.
Testsfolder is marked as tests in green which is of importance to separate package- from test-code.
- In the Dependencies tab, you can set the module’s Wolfram SDK and define other Wolfram packages as external libraries. While the SDK is of no great importance in a non-compiled language like the Wolfram Language, external packages are used for code completion, highlighting and navigation.
As you can see above, the
IGraphM package relies on the
Since the plugin now knows about this dependency, it can highlight usages of
LTemplate functions within the
package correctly and you can jump to their definition.
Below, you see that the plugin recognizes these external usages and underlines them instead of marking them as unresolved.