有没有一种方法可以通过给出不同关键字、块开始等的列表来向 Eclipse 添加非常简单的代码突出显示?
我想为 elcipse 中开发的新语言提供一些非常简单的编辑器支持。只是基本的关键字突出显示、大括号匹配或者块折叠。
在大多数编辑器(vim、emacs 或 notpad++)中,我可以通过或多或少给出带有一些简单指令的关键字列表来相对简单地完成此任务。然而,我在 Eclipse 中看到的所有内容都需要真正解析 antlr 语法或直接从编译器进行翻译。
这当然很强大,但对于我打算支持的语言来说,工作量太大了,因为正如所说的,该语言正在开发中发生变化(并且没有那么多使用)。因此,在 Eclipse 中创建完整的 IDE 编辑器的工作并没有真正得到回报。
所以我的问题是:向 Eclipse 编辑器添加关键字语法着色的最简单方法是什么?
谢谢
I want to provide a bit of very simple editor support for a new language which is in development in elcipse. Just basic key-wordhighlight, brace matching maybe block folding.
In most editors (vim, emacs or notpad++) I can acomplish that reltively simple by more or less giving a list of keyword with some simple directives. However eveything I looked at in eclipse needs real parsing an antlr-grammar or directly translating from the compilers.
This is certainly powerful, but just too much work for the language I indent to support,because as said the languag is in develompment changes (and is not that much used). So the work for a full IDE-Editor in eclipse does not realy pay off.
So my question is: What is the simplest way to add syntaxcoloring for keywords to an eclipse editor?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您愿意编写自己的插件,Eclipse 有一个名为“Plug-in with an editor”的示例插件项目,其中包含简单的硬编码语法突出显示。您可以调整它以从文件中读取关键字列表。导出的插件 jar 可以放入您的 IDE dropin 目录。
创建示例:
您将需要编辑
XMLPartitionScanner.java
以提供您自己的语法规则。请参阅
IPredicateRule
实现。If you're willing to write your own plug-in, Eclipse has a sample plug-in project called Plug-in with an editor that contains simple, hard-coded syntax highlighting. You could adapt this to read a list of keywords from a file. Exported plugin jars can be dropped into your IDE dropin directory.
To create the sample:
You will need to edit
XMLPartitionScanner.java
to provide your own syntax rules.See
IPredicateRule
implementations.您可以尝试 xtext - eclipse 插件来创建 DSL 语言。但它不会像关键字列表那么简单。
You can try xtext - eclipse plugin for creating DSL languages. But it would not be as simple as a list of keywords.