简体   繁体   English

有关开发自定义Eclipse编辑器的教程

[英]Tutorial regarding the development of a custom Eclipse editor

I wish to learn about developing an editor for Eclipse for a particular programming language. 我想学习为特定的编程语言开发Eclipse的编辑器。 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). 这是真正的建议 - 不要选择一个以org.eclipse开头的包名(如ant一个)。 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. eclipse提供了如此多的支持,如果它以另一个包前缀开头,则更容易看到需要编写的代码。 Try looking at the groovy or scala plugins, for example. 例如,尝试查看groovyscala插件。

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). 如果您控制编辑器或编写编辑器的语言的运行时,如果您可以让编译器为您提供IDE将用于呈现给用户所需的所有数据,那么它将使生活变得更加容易(例如令牌列表 - 用于语法着色,工具提示;内容辅助会更好,因为你不是伪造编译器,而是使用真实的编译器;与错误突出显示相同)。

The IDE has the relatively easy job of only displaying errors, and colouring, etc. IDE只有显示错误和着色等相对简单的工作。

Once you have it down to display only, the example XML editor looks quite useful. 只有将其显示为仅显示后,示例XML编辑器才非常有用。

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 我在标准的基于Eclipse文本的编辑器中看到的最好的是

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

(you need to sign up for a free IBM account). (您需要注册免费的IBM帐户)。 Prashant Deva, author of a really nice ANTLR2 plugin did this one. Prashant Deva是一个非常好的ANTLR2插件的作者。

You may also want to look into tools that will generate an editor: 您可能还想查看将生成编辑器的工具:

Eclipse Modeling Project (EMF/TMF/GMF) Eclipse建模项目(EMF / TMF / GMF)

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

TMF helps build textual editors; TMF帮助建立文本编辑; GMF helps build graphical editors. GMF帮助构建图形编辑器。 A pretty good book is available (also on safari books) 一本很好的书(也在野生动物园书籍上)

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

A good intro on GMF: http://www.ibm.com/developerworks/opensource/library/os-ecl-gmf/ 关于GMF的简介: http//www.ibm.com/developerworks/opensource/library/os-ecl-gmf/

Dynamic Languages Tool Kit 动态语言工具包

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

Tutorials available from that site. 该网站提供的教程。 Note that you can use DLTK for static language editing as well; 请注意,您也可以使用DLTK进行静态语言编辑; the "dynamic" part comes from the interpreter configuration and launching. “动态”部分来自解释器配置和启动。

Xtext (now part of TMF) Xtext (现在是TMF的一部分)

http://wiki.eclipse.org/Xtext 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 . 您可能正在寻找类似于使用JFace文本构建Eclipse编辑器的文章 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. 它最近已经更新,而上面提到的是5到10年前。

I'm not actually sure that things have changed that much, but since it was helpful to me, I'm adding it here. 我不确定事情发生了多大的变化,但是因为它对我有帮助,所以我在这里添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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