wed
Version:
Wed is a schema-aware editor for XML documents.
55 lines • 1.89 kB
JavaScript
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This task processes the new validation errors that have not been processed
* yet.
*/
class ProcessValidationErrors {
constructor(controller) {
this.controller = controller;
this.errors = [];
}
reset() {
this.errors = this.controller.copyErrorList();
}
cycle() {
const controller = this.controller;
const errors = this.errors;
if (errors.length === 0) {
return false;
}
// The figure in the next line is arbitrary.
let count = Math.min(errors.length, 30);
const items = [];
const markers = [];
let ix = 0;
while (count !== 0) {
count--;
const error = errors[ix];
if (controller.processError(error)) {
errors.splice(ix, 1);
const item = error.item;
if (item === undefined) {
throw new Error("there should be an item");
}
items.push(item);
const marker = error.marker;
// There may be no marker set.
if (marker != null) {
markers.push(marker);
}
}
else {
++ix;
}
}
controller.appendItems(items);
controller.appendMarkers(markers);
return errors.length !== 0;
}
}
exports.ProcessValidationErrors = ProcessValidationErrors;
});
// LocalWords: MPL
//# sourceMappingURL=process-validation-errors.js.map