UNPKG

vscode-css-languageservice

Version:
39 lines 2.03 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; import * as nodes from '../parser/cssNodes'; import { Range, DiagnosticSeverity } from 'vscode-languageserver-types'; import { LintConfigurationSettings } from './lintRules'; import { LintVisitor } from './lint'; var CSSValidation = /** @class */ (function () { function CSSValidation() { } CSSValidation.prototype.configure = function (settings) { this.settings = settings; }; CSSValidation.prototype.doValidation = function (document, stylesheet, settings) { if (settings === void 0) { settings = this.settings; } if (settings && settings.validate === false) { return []; } var entries = []; entries.push.apply(entries, nodes.ParseErrorCollector.entries(stylesheet)); entries.push.apply(entries, LintVisitor.entries(stylesheet, document, new LintConfigurationSettings(settings && settings.lint))); function toDiagnostic(marker) { var range = Range.create(document.positionAt(marker.getOffset()), document.positionAt(marker.getOffset() + marker.getLength())); return { code: marker.getRule().id, source: document.languageId, message: marker.getMessage() + " (" + marker.getRule().id + ")", severity: marker.getLevel() === nodes.Level.Warning ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error, range: range }; } return entries.filter(function (entry) { return entry.getLevel() !== nodes.Level.Ignore; }).map(toDiagnostic); }; return CSSValidation; }()); export { CSSValidation }; //# sourceMappingURL=cssValidation.js.map