orion.edit.highlighter

The orion.edit.highlighter service contributes syntax highlighting rules to the editor. A highlighter service provides a grammar, which is a declarative description of the structure of a language and what CSS classes the different structural pieces correspond to. The service also provides a list of file extensions. When the editor opens a file of a registered extension type, the grammar is applied to the file to obtain the styling.

Service methods

None.

Service attributes

Implementations of orion.edit.highlighter must define the following attributes:

type
String What kind of highlight provider is being registered. For now this should always be "grammar", although future versions may support more.
fileTypes
Array An array of file extensions that this provider will be used for.
grammar
Object An object giving the grammar to be used to assign style classes. This object is expected to be a JavaScript equivalent of the format described here.

Examples

var provider = new eclipse.PluginProvider();
provider.registerServiceProvider("orion.edit.highlighter",
  {
  }, {
    type : "grammar",
    fileTypes : ["html", "htm"],
    grammar: {
      patterns: [
          {  begin: "<!--", 
             end: "-->",
             captures: { "0": "punctuation.definition.comment.html" },
             contentName: "comment.block.html"
          }
      ]
    }
  });
provider.connect();

The above example provides a grammar to be used for .html and .htm files. It will assign the CSS class punctuation-definition-comment-html to the <!-- and --> delimiters, and assign the CSS class comment-block-html to the text inside the delimiters. Consult this reference for a full description of the grammar format.

(Note that some aspects of the grammar format are not supported. See orion.editor.TextMateStyler in the Client API reference for a detailed explanation.)