Code coverage report for lib/services/cssValidation.js

# all files / lib/services/ cssValidation.js

86.67% Statements 26/30
57.89% Branches 11/19
100% Functions 8/8
89.29% Lines 25/28

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    501×
    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    2×
    2×

    1×
    2×

    2×
    2×
    2×
    1×
    2×
    2×

    2×

    1×

    1×

     (function (factory) {
        Eif (typeof module === "object" && typeof module.exports === "object") {
            var v = factory(require, exports);
            Iif (v !== undefined) module.exports = v;
        }
        else if (typeof define === "function" && define.amd) {
            define(["require", "exports", "../parser/cssNodes", "vscode-languageserver-types", "./lintRules", "./lint"], factory);
        }
    })(function (require, exports) {
        /*---------------------------------------------------------------------------------------------
         *  Copyright (c) Microsoft Corporation. All rights reserved.
         *  Licensed under the MIT License. See License.txt in the project root for license information.
         *--------------------------------------------------------------------------------------------*/
        'use strict';
        Object.defineProperty(exports, "__esModule", { value: true });
        var nodes = require("../parser/cssNodes");
        var vscode_languageserver_types_1 = require("vscode-languageserver-types");
        var lintRules_1 = require("./lintRules");
        var lint_1 = require("./lint");
        var CSSValidation = (function () {
            function CSSValidation() {
            }
            CSSValidation.prototype.configure = function (raw) {
                this.validationEnabled = !raw || raw.validate !== false;
                this.lintSettings = lintRules_1.sanitize(raw && raw.lint || {});
            };
            CSSValidation.prototype.doValidation = function (document, stylesheet) {
                Iif (!this.validationEnabled) {
                    return [];
                }
                var entries = [];
                entries.push.apply(entries, nodes.ParseErrorCollector.entries(stylesheet));
                entries.push.apply(entries, lint_1.LintVisitor.entries(stylesheet, this.lintSettings));
                function toDiagnostic(marker) {
                    var range = vscode_languageserver_types_1.Range.create(document.positionAt(marker.getOffset()), document.positionAt(marker.getOffset() + marker.getLength()));
                    return {
                        code: marker.getRule().id,
                        source: document.languageId,
                        message: marker.getMessage(),
                        severity: marker.getLevel() === nodes.Level.Warning ? vscode_languageserver_types_1.DiagnosticSeverity.Warning : vscode_languageserver_types_1.DiagnosticSeverity.Error,
                        range: range
                    };
                }
                return entries.filter(function (entry) { return entry.getLevel() !== nodes.Level.Ignore; }).map(toDiagnostic);
            };
            return CSSValidation;
        }());
        exports.CSSValidation = CSSValidation;
    });
    //# sourceMappingURL=cssValidation.js.map