Hi [message #1266775] |
Fri, 07 March 2014 23:54  |
duke vah Messages: 33 Registered: December 2013 |
Member |
|
|
Hi,
I am fascinated by Orion so I want to provide a plugin for my own language.
I could use content assistance and it worked well. However, I could not provide a highlighter. I used documentation but it didn't work for me.
I wonder if there is a good step by step guide with a sample which shows how to highlight some specified keywords.
thanks in advance.
This is my plugin:
<!DOCTYPE html>
<html>
<head>
<script src="plugin.js"></script>
<script type="text/javascript">
/*global window eclipse*/
var provider = new eclipse.PluginProvider();
provider.registerServiceProvider("orion.edit.highlighter",
{
// no service methods
}, {
id: "orion.ump",
contentTypes: { id: "application/ump", extension: ["ump"], "extends": "text/plain"},
patterns: [
{
include: "orion.lib"
}, {
match: "\b(if|while|for|return)\b",
name: "keyword.ump"
}
]
});
provider.connect();
//--------------------------------------------------------
</script>
</head>
<body>
</body>
</html>
[Updated on: Sat, 08 March 2014 00:04] Report message to a moderator
|
|
|
Re: Hi [message #1268732 is a reply to message #1266775] |
Mon, 10 March 2014 23:16  |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi, you need to change a couple of things (these changes are shown at the bottom):
1. The grammar's contentTypes needs to be an array of strings, a content type cannot be declared in-line here. The snippet below first registers an orion.core.contenttype for the type, and orion.edit.highlighter's contentType then just refers to it as "application/ump".
2. Your \b's need double-escaping (the first '\' escapes the second '\' in the JS string, resulting in one '\' in the string).
provider.registerService("orion.core.contenttype", {}, {
contentTypes: [
{
id: "application/ump",
"extends": "text/plain",
name: "ump",
extension: ["ump"]
}
]
});
provider.registerServiceProvider("orion.edit.highlighter",
{
// no service methods
}, {
id: "orion.ump",
contentTypes: ["application/ump"],
patterns: [
{
include: "orion.lib"
}, {
match: "\\b(if|while|for|return)\\b",
name: "keyword.ump"
}
]
}
);
Grant
|
|
|
Powered by
FUDForum. Page generated in 0.01829 seconds