| orion.core.astprovider | ||
|---|---|---|
|
|
|
| The Editor Context object | orion.edit.command | |
The orion.core.astprovider service allows plugins to provide ASTs (<dfn>Abstract Syntax Trees</dfn>) for specific
content types.
Implementations of orion.core.astprovider must define the following function:
text argument that contains the entire source from the current editor context.Implementations of orion.core.astprovider may define the following attributes:
Array An array of
Content Type IDs for which this command is valid.
The following example is how Orion uses the Esprima parser internally to provide ASTs for JavaScript:
var provider = new orion.PluginProvider();
provider.registerService('orion.core.astprovider',
{
computeAST: function(astContext) {
var ast = esprima.parse(astContext.text, {
loc: true,
range: true,
raw: true,
tokens: true,
comment: true,
tolerant: true
});
if (ast.errors) {
ast.errors = ast.errors.map(serialize.serializeError);
}
return ast;
}
}, {
contentType: ['application/javascript']
});
provider.connect();
|
|
|
| The Editor Context object | orion.edit.command |