This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "yaml"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLStyleValidator = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
class YAMLStyleValidator {
|
||||
constructor(settings) {
|
||||
this.forbidMapping = settings.flowMapping === 'forbid';
|
||||
this.forbidSequence = settings.flowSequence === 'forbid';
|
||||
}
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
(0, yaml_1.visit)(yamlDoc.internalDocument, (key, node) => {
|
||||
if (this.forbidMapping && (0, yaml_1.isMap)(node) && node.srcToken?.type === 'flow-collection') {
|
||||
result.push(vscode_languageserver_types_1.Diagnostic.create(this.getRangeOf(document, node.srcToken), 'Flow style mapping is forbidden', vscode_languageserver_types_1.DiagnosticSeverity.Error, 'flowMap'));
|
||||
}
|
||||
if (this.forbidSequence && (0, yaml_1.isSeq)(node) && node.srcToken?.type === 'flow-collection') {
|
||||
result.push(vscode_languageserver_types_1.Diagnostic.create(this.getRangeOf(document, node.srcToken), 'Flow style sequence is forbidden', vscode_languageserver_types_1.DiagnosticSeverity.Error, 'flowSeq'));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
getRangeOf(document, node) {
|
||||
return vscode_languageserver_types_1.Range.create(document.positionAt(node.start.offset), document.positionAt(node.end.pop().offset));
|
||||
}
|
||||
}
|
||||
exports.YAMLStyleValidator = YAMLStyleValidator;
|
||||
});
|
||||
//# sourceMappingURL=yaml-style.js.map
|
||||
Reference in New Issue
Block a user