The IntelliJ plugin for StrataCode supports the most important features which make IntelliJ so powerful for Java programmers. These features are supported on all of the major StrataCode language formats: .sc, .scj, .schtml, and sct. IntelliJ plugins are fairly easy to create for Parselets-based languages because features are moved down to the lowest-level possible - i.e. contained in base classes for specific types of nodes which can be shared or customized as needed for each language element.
First install the plugin itself into IntelliJ:
- Download the sc4idea.jar file
- Go to IntelliJ's Preferences, Plugin tab and choose "Install from disk"
- Select the sc4idea.jar. Enable the StrataCode plugin in the menu and restart IntelliJ.
Option #1: Create a "StrataCode Only" project
Create a directory inside of your ~/IdeaProjects for the project called scTestProject and inside of that a bundles directory. Inside of "bundles" check out the git repositories for the coreFramework:
% cd ~/IdeaProjects/scTestProject/bundles/ % git clone https://github.com/stratacode/coreFramework.git
In IntelliJ create a new Empty StrataCode project (here called "scTestProject") that points to ~/IdeaProjects/scTestProject
If you want, you can additionally check out the examples bundle here:
% cd ~/IdeaProjects/scTestProject/bundles % git clone https://github.com/stratacode/examples.git
To create simple layers of your own without creating a new bundle, place your layer directories into:
Each directory in the layers directory can contain a layer definition file, or it can be a layer group which is a directory containing other layer groups or layer directories.
Option #2: Add a StrataCode module to a Java project
You can create an empty Java project or use an existing one. Add a StrataCode module to the project which points to a directory that has one or more layer bundles using IntelliJ's New->"Module..." option (do not use "New->Module from existing sources). For example, if you have:
use IntelliJ's New->"Module..." and create a module /home/StrataCode. You can then exclude or include bundles in that directory as you'd like to be included in that project.
Option #3: Installation With StrataCode Source
To build and debug StrataCode itself from source, along with the apps built on it, download the 'sc' source distribution. Inside of it there are three directories - coreRuntime, fullRuntime, and system, each organized as separate IntelliJ modules you can import into your project.
From the Project Structure dialog, click on "Modules" and then "+", then "Import module". Import all three IntelliJ modules into your project: fullRuntime/fullRuntime.iml, coreRuntime/coreRuntime.iml and system/sc.iml. This will let you debug the StrataCode source, and ensures that StrataCode uses the debugger source when it runs an application.
In your project, select a Java SDK with version 1.6, 1.7 or 1.8
After importing all three modules, click "Ok" on the Project Structure dialog to save those modules before you try to create an SC module. If it does not find the 'sc' module when it creates a new StrataCode module, it will instead add a dependency on "SCLib" a pre-configured intelliJ library that points to the SC runtime libraries.
If you have already created an SC module and later want to add the "sc" source module, go to the module, remove the dependency on the "SCLib" library and add module dependencies on fullRuntime, coreRuntime and sc/system (in that order). The fullRuntime has to be ahead of coreRuntime in the dependency list so we pick up the complete versions of the runtime apis.
Make the project to compile the StrataCode source (so the StrataCode plugin can find the classes for StrataCode itself).
Option #4: Installation Without StrataCode Source
The sc4idea plugin also will usually be bundled with the sc.jar file so you do not need the StrataCode source to use the IDE.
Just create your StrataCode module in the EmptyProject or create a StrataCode project in one step.
In this case, StrataCode will find the sc.jar in the plugin, it will create a library for this jar in the configuration and add a dependency on that library to each StrataCode module.
Manually Adding StrataCode Source Dependency
If you create a module without the StrataCode source and later change your mind, edit the module's dependencies and remove the SCLib library. Create three module's from existing sources - the coreRuntime, fullRuntime and system(sc) modules. Then add a dependency on the sc module in your project.
NOTE: it's important that fullRuntime be ahead of coreRuntime in the dependency list for IntelliJ.
Also add a dependency on the JLine library. If necessary, add the Jline library (version 2.x) from Maven or from the jar file included in the SC distribution.
Creating a StrataCode Module
Checkout the 'layers' git repository and place that directory inside of your module directory. Accept the defaults - including the source path of 'layers'. That name should match the name of the 'layers' directory you put in your module's directory.
Instructions for Debugging the sc4idea plugin:
- Enable the Groovy plugin
- Install the IntelliJ PluginDev plugin
- Get a copy of the community source for IntelliiJ
- Create an sc4idea module (or import the one here)
- Create a new SDK of type "Plugin" (in "Project Structure", select "SDKs" and "+")
Add the source of the intelliJ community editor to the source path of that plugin
Make sc4idea depend on the "sc" module for the StrataCode source, or create a Library in IntelliJ called sclib that points to the sc.jar file
create a run configuration of type "plugin" for sc4idea
To deploy the plugin:
- in Project View, right click on the sc4idea module and select the Prepare plugin module for deployment menu. The results are in the sc4idea/sc4idea.jar or sc4idea.zip depending on whether or not the sc.jar is a dependency.
NOTE: * If you build from source, note that IntelliJ SDK or someone copies the class files from the intelliJ build directory into some sandbox directory in your home directory (on mac it is:
Also note that when you use sclib and enable a Compile dependency, it will put the library into sandboxDir/.../sc4idea/lib
- There's a problem because coreRuntime and fullRuntime have overlapping files. During the copy this classes folder might end up with the wrong run. Whe installed a simple shell script to workaround this problem - the run configuration for the sc4idea
#!/bin/sh PLUGINDIR=/Users/jvroom/Library/Caches/IntelliJIdea13/plugins-sandbox/plugins/sc4idea/classes BUILDDIR=/jjv/vroomsys/out/production/fullRuntime cp $BUILDDIR/sc/type/PTypeUtil*.class $PLUGINDIR/sc/type/ cp $BUILDDIR/sc/type/Type*.class $PLUGINDIR/sc/type/* There are cases where you need to clean out this directory, like if you rename the module - the one for the old module might still get loaded into the classpath and precede the one you are building. ## Additional settings * In preferences, add "*.dbgidx;*.rdps;*.dep" to the Ignore files and folders in the Editor group's File Types dialog box. * Under Editor, General, Smart Keys, disable "Reformat block on typing '}'"