orion.edit.highlighter | ||
---|---|---|
![]() |
![]() |
|
orion.edit.editor | orion.edit.model |
Note that this section has been rewritten for the new syntax styling service in the Orion 5.0 release. The implementation of the older syntax styling service is also in Orion 5.0 in order to preserve backwards-compatibility, but is considered deprecated. Documentation for this old service can be found here. All new syntax styling declaration should be implemented in terms of the new styling service that is described below.
The orion.edit.highlighter
service contributes syntax styling patterns to the editor. This is done by passing a grammar, which is a declarative description of a language's syntax. The grammar tells the Orion editor how to recognize and style language constructs in a file.
The service also provides a list of content types. When the editor opens a file of a registered content type, the provider is invoked to obtain the styling.
None. This service is purely declarative.
Implementations of orion.edit.highlighter
define the following attributes:
String
A name that uniquely identifies this grammar.String[]
An array of
Content Type IDs that this grammar will be used for.
Object[]
An array of pattern objects to be used to assign style classes. Pattern objects are described below.Object
Optional. A set of named pattern objects that can be referenced by this grammar and others.
Patterns are defined in a similar way to TextMate language rules, with some minor variation to adapt to the context of Orion:
The TextMate naming conventions are followed by the text styler. In addition to visual styling, the following styles can be used to provide semantic info about matches:
Many of the patterns that were defined for Orion's core language stylings are applicable across many languages (for example, strings, numbers, etc.). In order to make these patterns easily re-usable, two generic grammars are defined that contain them and can be inherited by other language grammars either in whole or in part. These grammars are:
A grammar can include the full set of patterns from orion.lib with "include: 'orion.lib'". That grammar could then override any of the included patterns, including an override to no-op, by specifying a pattern with the same name in its repository section.
For an example of including most patterns from orion.c-like see Orion's Java syntax styling. The orion.lib and orion.c-like grammars are defined here.
provider.registerServiceProvider("orion.edit.highlighter", { // no service methods }, { id: "orion.json", contentTypes: ["application/json"], patterns: [ { include: "orion.lib" }, { match: "\\b(?:false|true)\\b", name: "keyword.json" } ] });
The above example shows Orion's grammar for styling of .json files. Since .json has many language constructs that are found in other languages it is able to inherit most of its styling from Orion's provided orion.lib grammar. The .json grammar supplements this by defining a pattern for styling false and true as keywords (an alternate styling name for these could have been constant.language).
![]() |
![]() |
![]() |
orion.edit.editor | orion.edit.model |