开发者

How to write a Source code editor for custom Language in Rich Client Plateform?

开发者 https://www.devze.com 2023-03-02 14:43 出处:网络
I am building a tool for acustom language. It will have many components including a source code editor. What are the coponents I will need to build this editor. I would like syntax highlighting, outli

I am building a tool for a custom language. It will have many components including a source code editor. What are the coponents I will need to build this editor. I would like syntax highlighting, outline and formating to start with.

I have alre开发者_开发技巧ady developed a parser using ANTLR.


If you really want to/need to create your DSL and the editor for it "by hand", then I suggest using the JFace Text framework to create the editor.

However, although you said that you already have a parser, I strongly suggest you take a look at Xtext and see if it suits your needs. It gives you a way to define your DSL and automatically generates an editor with syntax highlighting, code completion, and so on. And AFAIK, it uses ANTLR underneath to generate a parser. With Xtext, you can also create a compiler (or interpreter) for your language.


I think Xtext is exactly what you are looking for. With Xtext you define a DSL and then you can launch a custom Eclipse which provides code completion, syntax highlighting etc for the DSL you defined.


Look at the JEditorPane and its associated Document. This can be used to highlight. Also look at http://download.oracle.com/javase/tutorial/uiswing/components/editorpane.html for further information on how to customise the document, specifically, the StyledDocument.

0

精彩评论

暂无评论...
验证码 换一张
取 消