Syntax Coloring for FreeMarker

Without fail, each JavaCC file (and ANTLR file) I have ever found (e.g., for Clojure and Ceylon) has been beaten into submission via this tutorial, which includes a YouTube movie explaining everything:

http://platform.netbeans.org/tutorials/nbm-javacc-lexer.html

Here's FreeMarker in NetBeans IDE, after applying the above tutorial to this file, which I found on-line after googling for about 5 minutes:

https://raw.github.com/freemarker/freemarker/master/src/main/javacc/FTL.jj

Not as pretty nor as complete as it could be, but I've clearly gone some way to getting things to work together.

However, note that in line 6 and 7, I have selected the "p" tag across two lines, meaning that I can change related text across multiple lines, because the block selection feature is a standard part of all editors, including any new editor you create, such as the FreeMarker editor above.

Comments:

Geertjan - any chance that you could share the resulting project somewhere (github/googlecode) ?

Posted by Alex Kochnev on August 30, 2012 at 01:41 PM PDT #

I just wish Netbeans would have proper Freemarker template editing support (syntax highlighting, navigation etc). Either built-in or as a maintained plug-in.

But no progress seems to be made on that front. An issue has been created in 2008 http://netbeans.org/bugzilla/show_bug.cgi?id=144971 but the status is still "NEW". Shame!

Posted by Morten on November 10, 2012 at 03:01 AM PST #

http://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.2/misc/ftl

There's the plugin, the NBM is in the release folder.2

Posted by Geertjan on November 10, 2012 at 05:20 AM PST #

But the problem, Geertjan, is that it doesn't appear to install correctly. I've tried taking installing that .nbm on Netbeans 7.3beta2 but the installer dialog displays the mesage "The plugin Lexer to NetBeans Bridge is requested in implementation version 201207171143." And then the install goes no further (I only have the option to cancel).

I don't "Lexer to NetBeans Bridge" in the list of available plugins. Any idea where I can find it? I have a feeling that I'm overlooking something obvious...

Posted by jim d on November 28, 2012 at 09:07 PM PST #

You can see for yourself, Jim, that this blog entry was written in May of this year. Did NetBeans IDE 7.3 Beta 2 exist at that time?

Posted by Geertjan on November 29, 2012 at 12:11 AM PST #

Thanks Geertjan. Sorry, I should have also mentioned that I tried this with Netbeans 7.2 and Netbeans 7.1.2 (which I asssume is the version you would have been working with, yes?) but unfortunately didn't have any luck. The result for 7.2 was identical to my 7.3beta 2 attempt, and for 7.1.2 there were several messages along the line of "the plugin xyz is requested in version >= 1.234 but only 1.123 was found". I even ran the "check for updates" process and tried again, but to no avail.

Any thoughts on what I'm doing wrong?

Posted by Jim d on November 29, 2012 at 08:34 PM PST #

Can you give me a clue where you're getting the plugin from? I.e., give me a URL pointing to where you're downloading the plugin, please...

Posted by Geertjan on November 29, 2012 at 11:22 PM PST #

Sure thing. First I drilled down to the versions/7.2/misc/ftl/release directory:
http://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.2/misc/ftl/release?rev=425

From there I just downloaded the nbm file:
http://java.net/projects/nb-api-samples/sources/api-samples/content/versions/7.2/misc/ftl/release/org-ftl.nbm?rev=425

Actually I have some good news. Instead of just trying the .nbm file I pulled the whole project and built the plugin with netbeans 7.2.1, and I was indeed able to install the resulting .nbm file. Yay! Colorful .ftl files!!

I'm not sure why the above links did not work (the file sizes are rather different, 90k for the successful nbm and 40k for the unsuccessful nbm) But either way I'm happy that it's working now. Thanks!

Posted by guest on November 30, 2012 at 08:12 PM PST #

I'm also having the same issue as Jim D under NB 7.2.1. I also tried to download and build the ftl project as he suggested and used the resulting nbm, but it is still looking for the "Lexer to NetBeans Bridge" plugin when I try to install.

Interestingly, org-netbeans-modules-lexer-nbbridge.jar is present under ide/modules, so I'm not sure why it's complaining.

Any suggestions on how I could resolve this?

Posted by mcmagi on December 13, 2012 at 01:23 PM PST #

Instead of just trying the .nbm file, pull the whole project and build the plugin with netbeans 7.2.1, and you'll indeed be able to install the resulting .nbm file.

Posted by Geertjan on December 13, 2012 at 01:34 PM PST #

Hi Geertjan - is there any way to stop this plugin screwing up my properties files fonts and colors preferences? I have messed with FontsAndColors1.xml and FreeMarkerUtils.java locally by prefixing "ftl-" in front of all the categories but when I open a .properties file, the foreColor is always magenta. When I look in my Fonts & Colors preferences for Properties files they are still correct by when I open a file then all fore ground colors are magenta. Any ideas? Thanks

Posted by mstewie on December 15, 2012 at 06:43 AM PST #

Hi Geertjan - Finally coming back around to experiment with this since I've been doing a lot of freemarker work. I didn't have much luck with pulling the whole project and building the plugin. I still get the "Lexer to NetBeans Bridge" message when trying to install.

What I think might be a clue is guest's comment (https://blogs.oracle.com/geertjan/entry/syntax_coloring_for_freemarker#comment-1354335170688) that their resulting file is 90k rather than 45k for the nbm packaged in the releases folder. When I build the project, the nbm in the build/cluster folder is still only 45k. Maybe the jar for the "Lexer to Netbeans Bridge" is not getting included in the nbm file?

Thanks in advance for your help.

Posted by mcmagi on April 29, 2013 at 08:18 AM PDT #

Finally coming back around to experiment with this since I've been doing a lot of freemarker work. I didn't have much luck with pulling the whole project and building the plugin manually. I still get the "Lexer to NetBeans Bridge" message when trying to install the nbm file in build/cluster.

What I think might be a clue is guest's comment (https://blogs.oracle.com/geertjan/entry/syntax_coloring_for_freemarker#comment-1354335170688) that their resulting file is 90k rather than 45k for the nbm packaged in the releases folder. When I build the project, the nbm in the build/cluster folder is still only 45k. Maybe the jar for the "Lexer to Netbeans Bridge" is not getting included in the nbm file?

Thanks in advance for your help.

(sorry if this double-posts)

Posted by mcmagi on April 29, 2013 at 08:37 AM PDT #

Okay, so I just got this to work if I choose "Install/Reload in Development IDE" within NetBeans.

Posted by mcmagi on April 29, 2013 at 09:32 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today