orion.edit.validator | ||
---|---|---|
![]() |
![]() |
|
orion.edit.highlighter | Updating this document |
An orion.edit.validator service provides a function that can check the contents of a file and return a data structure indicating which lines (if any) have errors, along with the reason for the error. The result of this service is used by the Orion UI to create error annotations in the ruler beside each problematic line.
Implementations of orion.edit.validator must define the following function:
Returns an Object giving the validation result. The returned object must have an errors property whose value is an array giving the errors found in the file. Each error object must have the properties:
Implementations of orion.edit.validator must define the following attributes:
var provider = new eclipse.PluginProvider(); var serviceProvider = provider.registerServiceProvider("orion.edit.validator", { checkSyntax: function(title, contents) { var errors = []; var lines = contents.split(/\r?\n/); for (var i=0; i < lines.length; i++) { var line = lines[i]; var match = /\t \t| \t /.exec(line); if (match) { errors.push({ reason: "Mixed spaces and tabs", line: i+1, character: match.index }); } } var result = { errors: errors }; return result; } }, { pattern: "\\.(txt|js)$" });<!-- service.dispatchEvent = serviceProvider.dispatchEvent;--> provider.connect();
This example will validate .txt and .js files. It finds lines containing a sequence of space-tab-space or tab-space-tab and produces an error on every such line.
![]() |
![]() |
![]() |
orion.edit.highlighter | Updating this document |