orion.edit.validator | ||
---|---|---|
![]() |
![]() |
|
orion.edit.outliner | 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 problems. The result of this service is used by the Orion UI to create annotations in the ruler beside each problematic line, and also to underline the specific portion of a line where the problem occurs.
Implementations of orion.edit.validator must define the following function:
Returns an Object giving the validation result. The returned object must have a problems property whose value is an array giving the problems found in the file. Each problem 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 problems = []; var lines = contents.split(/\r?\n/); for (var i=0; i < lines.length; i++) { var line = linesi; var match = /\t \t| \t /.exec(line); if (match) { problems.push({ description: "Mixed spaces and tabs", line: i + 1, start: match.index + 1, end: match.index + match0.length + 1, severity: "warning" }); } } var result = { problems: problems }; return result; } }, { contentType: "application/javascript" }); provider.connect();
This example will validate JavaScript files. It finds lines containing a sequence of space-tab-space or tab-space-tab and produces a warning on every such line. Note that +1 is necessary because column and line indices in the Orion UI are numbered from 1, not 0.
![]() |
![]() |
![]() |
orion.edit.outliner | Updating this document |