简体   繁体   中英

Tutorial regarding the development of a custom Eclipse editor

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.

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 (eg 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.

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!

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.

All of these answers are good, and I looked at, and used, the tutorials linked above myself.

I'd add this one , from Charles University in Prague. It's been updated recently, whereas the ones mentioned above are from 5-10 years ago.

I'm not actually sure that things have changed that much, but since it was helpful to me, I'm adding it here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM