Code coverage report for lib/services/cssHover.js

# all files / lib/services/ cssHover.js

37.5% Statements 15/40
16.67% Branches 4/24
66.67% Functions 4/6
38.46% Lines 15/39

    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
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    701×
    1×
    1×
    1×

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

    1×
    1×

    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", "./languageFacts", "vscode-languageserver-types", "./selectorPrinting"], 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 languageFacts = require("./languageFacts");
        var vscode_languageserver_types_1 = require("vscode-languageserver-types");
        var selectorPrinting_1 = require("./selectorPrinting");
        var CSSHover = (function () {
            function CSSHover() {
            }
            CSSHover.prototype.doHover = function (document, position, stylesheet) {
                function getRange(node) {
                    return vscode_languageserver_types_1.Range.create(document.positionAt(node.offset), document.positionAt(node.end));
                }
                var offset = document.offsetAt(position);
                var nodepath = nodes.getNodePath(stylesheet, offset);
                for (var i = 0; i < nodepath.length; i++) {
                    var node = nodepath[i];
                    if (node instanceof nodes.Selector) {
                        return {
                            contents: selectorPrinting_1.selectorToMarkedString(node),
                            range: getRange(node)
                        };
                    }
                    if (node instanceof nodes.SimpleSelector) {
                        return {
                            contents: selectorPrinting_1.simpleSelectorToMarkedString(node),
                            range: getRange(node)
                        };
                    }
                    if (node instanceof nodes.Declaration) {
                        var propertyName = node.getFullPropertyName();
                        var entry = languageFacts.getProperties()[propertyName];
                        if (entry) {
                            var contents = [];
                            if (entry.description) {
                                contents.push(vscode_languageserver_types_1.MarkedString.fromPlainText(entry.description));
                            }
                            var browserLabel = languageFacts.getBrowserLabel(entry.browsers);
                            if (browserLabel) {
                                contents.push(vscode_languageserver_types_1.MarkedString.fromPlainText(browserLabel));
                            }
                            if (contents.length) {
                                return {
                                    contents: contents,
                                    range: getRange(node)
                                };
                            }
                        }
                    }
                }
                return null;
            };
            return CSSHover;
        }());
        exports.CSSHover = CSSHover;
    });
    //# sourceMappingURL=cssHover.js.map