Adding a DRL FileType with Syntax Highlighting to IntelliJ

IntelliJ’s support of JBoss-rules in no way compares to Eclipse, but even that isn’t enough to get me off my butt and move from my fave. That said, I created a semi-literate FileType for the drl files so that IntelliJ will recognize them and you will get a decent amount of syntax highlighting. Is it perfect?

No.

But it will probably get you home. Here’s what you do. Create a new filetype and make sure that it includes ?*.drl files. Once that is created, it makes a filetype with the name you gave it in the

%User%/Library/Preferences/IntellijIDEA%your-release-version-here%/filetypes/%name_of_file.xml%

directory (at least that’s what it looks like on my Mac – I haven’t touched a windows box in years, but it should have some parallels.

Open the XML file and replace anything between the <filetype> nodes with:

<highlighting>
<options>
<option name=”LINE_COMMENT” value=”#” />
<option name=”COMMENT_START” value=”/*” />
<option name=”COMMENT_END” value=”*/” />
<option name=”HEX_PREFIX” value=”” />
<option name=”NUM_POSTFIXES” value=”” />
<option name=”HAS_BRACES” value=”true” />
<option name=”HAS_BRACKETS” value=”true” />
<option name=”HAS_PARENS” value=”true” />
</options>
<keywords ignore_case=”false”>
<keyword name=”agenda-group” />
<keyword name=”assert” />
<keyword name=”auto-focus” />
<keyword name=”duration” />
<keyword name=”eval” />
<keyword name=”function” />
<keyword name=”import” />
<keyword name=”modify” />
<keyword name=”new” />
<keyword name=”no-loop” />
<keyword name=”package” />
<keyword name=”query” />
<keyword name=”retract” />
<keyword name=”return” />
<keyword name=”rule” />
<keyword name=”salience” />
</keywords>
<keywords2>
<keyword name=”end” />
<keyword name=”exists” />
<keyword name=”false” />
<keyword name=”not” />
<keyword name=”or” />
<keyword name=”then” />
<keyword name=”true” />
<keyword name=”when” />
</keywords2>
<keywords3>
<keyword name=”!=” />
<keyword name=”*” />
<keyword name=”->” />
<keyword name=”:” />
<keyword name=”<” />
<keyword name=”<=” />
<keyword name=”=” />
<keyword name=”==” />
<keyword name=”>” />
<keyword name=”>=” />
<keyword name=”contains” />
<keyword name=”excludes” />
<keyword name=”matches” />
</keywords3>
<keywords4>
<keyword name=”Double” />
<keyword name=”Integer” />
<keyword name=”String” />
</keywords4>
</highlighting>

This should get you home. If you have a better one or more highlighting ideas, feel free to drop me note.

Advertisements

5 thoughts on “Adding a DRL FileType with Syntax Highlighting to IntelliJ

  1. I had a few problem using your file, but this one also works with IntelliJ Idea 8:

  2. Thanks for this. Huge help to me. It would be wonderful if someone would build a small compliation and error reporting plugin. 🙂

    A

  3. In my previous comment the content of the file was missing, so here it is. This also works in IDEA 9

  4. No, it seems that XML is not allowed in the comments.
    Sorry about that

    André

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s