views:

2162

answers:

4

I wish to learn about developing an editor for Eclipse for a particular programming language. Is there a tutorial available to help me with this? It would be beneficial if it covered such topics as syntax highlighting and auto-completion.

A: 

Have you tried installing a plugin for Eclipse that meets your needs?

http://eclipse-plugins.info/eclipse/plugin_details.jsp?id=266

FortunateDuke
+2  A: 

You're probably looking for something like this article on building Eclipse editors with JFace text. It's got enough to get you started and it goes through syntax highlighting, content assist, content outline, and error markers.

gcastro
+3  A: 

I started at this one. It was a year out of date when I used it, but the concepts have stayed the same.

The best thing I can suggest in lieu of a how-to would be to take find a language that is already integrated, and see how they do it. Here's the real advice - don't pick one with a package name that begins with org.eclipse (like the ant one). There are so much support provided by eclipse, it is much easier to see what code you need to write if it starts with another package prefix. Try looking at the groovy or scala plugins, for example.

In my experience, it is the error highlighting which is the hardest to do accurately; next hardest is content assist.

If you are in control of the compiler or runtime of the language that you're writing an editor, it makes life a lot easier if you can get the compiler to give you all the data your IDE will need to present it to the user (e.g. list of tokens - for syntax colouring, tooltips; content assist will be much better, because you're not faking a compiler, but using the real one instead; same with error highlighting).

The IDE has the relatively easy job of only displaying errors, and colouring, etc.

Once you have it down to display only, the example XML editor looks quite useful.

Much of the partitioning rules I have found less useful; I've always ended up building my own - binary search over a list of tokens is extremely useful.

jamesh
+3  A: 

The best one I've seen for a standard Eclipse text-based editor is

http://www.ibm.com/developerworks/edu/os-dw-os-ecl-commplgin1.html

(you need to sign up for a free IBM account). Prashant Deva, author of a really nice ANTLR2 plugin did this one.

You may also want to look into tools that will generate an editor:

Eclipse Modeling Project (EMF/TMF/GMF)

http://www.eclipse.org/modeling/

TMF helps build textual editors; GMF helps build graphical editors. A pretty good book is available (also on safari books)

Tutorial at: http://wiki.eclipse.org/index.php/GMF_Tutorial

A good intro on GMF: http://www.ibm.com/developerworks/opensource/library/os-ecl-gmf/

Dynamic Languages Tool Kit

http://www.eclipse.org/dltk/

Tutorials available from that site. Note that you can use DLTK for static language editing as well; the "dynamic" part comes from the interpreter configuration and launching.

Xtext (now part of TMF)

http://wiki.eclipse.org/Xtext

Note: good content assist can be quite difficult; it really involves follow-set analysis for every terminal in your grammar. You can simplify it quite a bit by just keeping track of defined symbols and keywords and just suggesting all that match the existing prefix. The generators above make this a little easier, but aren't perfect.

Good luck!

Scott Stanchfield