/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ define('vs/language/css/workerManager',["require", "exports", "./fillers/monaco-editor-core"], function (require, exports, monaco_editor_core_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WorkerManager = void 0; var STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min var WorkerManager = /** @class */ (function () { function WorkerManager(defaults) { var _this = this; this._defaults = defaults; this._worker = null; this._idleCheckInterval = window.setInterval(function () { return _this._checkIfIdle(); }, 30 * 1000); this._lastUsedTime = 0; this._configChangeListener = this._defaults.onDidChange(function () { return _this._stopWorker(); }); } WorkerManager.prototype._stopWorker = function () { if (this._worker) { this._worker.dispose(); this._worker = null; } this._client = null; }; WorkerManager.prototype.dispose = function () { clearInterval(this._idleCheckInterval); this._configChangeListener.dispose(); this._stopWorker(); }; WorkerManager.prototype._checkIfIdle = function () { if (!this._worker) { return; } var timePassedSinceLastUsed = Date.now() - this._lastUsedTime; if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) { this._stopWorker(); } }; WorkerManager.prototype._getClient = function () { this._lastUsedTime = Date.now(); if (!this._client) { this._worker = monaco_editor_core_1.editor.createWebWorker({ // module that exports the create() method and returns a `CSSWorker` instance moduleId: 'vs/language/css/cssWorker', label: this._defaults.languageId, // passed in to the create() method createData: { options: this._defaults.options, languageId: this._defaults.languageId } }); this._client = this._worker.getProxy(); } return this._client; }; WorkerManager.prototype.getLanguageServiceWorker = function () { var _this = this; var resources = []; for (var _i = 0; _i < arguments.length; _i++) { resources[_i] = arguments[_i]; } var _client; return this._getClient() .then(function (client) { _client = client; }) .then(function (_) { return _this._worker.withSyncedResources(resources); }) .then(function (_) { return _client; }); }; return WorkerManager; }()); exports.WorkerManager = WorkerManager; }); (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('vscode-css-languageservice/parser/cssScanner',["require", "exports"], 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 }); exports.Scanner = exports.MultiLineStream = exports.TokenType = void 0; var TokenType; (function (TokenType) { TokenType[TokenType["Ident"] = 0] = "Ident"; TokenType[TokenType["AtKeyword"] = 1] = "AtKeyword"; TokenType[TokenType["String"] = 2] = "String"; TokenType[TokenType["BadString"] = 3] = "BadString"; TokenType[TokenType["UnquotedString"] = 4] = "UnquotedString"; TokenType[TokenType["Hash"] = 5] = "Hash"; TokenType[TokenType["Num"] = 6] = "Num"; TokenType[TokenType["Percentage"] = 7] = "Percentage"; TokenType[TokenType["Dimension"] = 8] = "Dimension"; TokenType[TokenType["UnicodeRange"] = 9] = "UnicodeRange"; TokenType[TokenType["CDO"] = 10] = "CDO"; TokenType[TokenType["CDC"] = 11] = "CDC"; TokenType[TokenType["Colon"] = 12] = "Colon"; TokenType[TokenType["SemiColon"] = 13] = "SemiColon"; TokenType[TokenType["CurlyL"] = 14] = "CurlyL"; TokenType[TokenType["CurlyR"] = 15] = "CurlyR"; TokenType[TokenType["ParenthesisL"] = 16] = "ParenthesisL"; TokenType[TokenType["ParenthesisR"] = 17] = "ParenthesisR"; TokenType[TokenType["BracketL"] = 18] = "BracketL"; TokenType[TokenType["BracketR"] = 19] = "BracketR"; TokenType[TokenType["Whitespace"] = 20] = "Whitespace"; TokenType[TokenType["Includes"] = 21] = "Includes"; TokenType[TokenType["Dashmatch"] = 22] = "Dashmatch"; TokenType[TokenType["SubstringOperator"] = 23] = "SubstringOperator"; TokenType[TokenType["PrefixOperator"] = 24] = "PrefixOperator"; TokenType[TokenType["SuffixOperator"] = 25] = "SuffixOperator"; TokenType[TokenType["Delim"] = 26] = "Delim"; TokenType[TokenType["EMS"] = 27] = "EMS"; TokenType[TokenType["EXS"] = 28] = "EXS"; TokenType[TokenType["Length"] = 29] = "Length"; TokenType[TokenType["Angle"] = 30] = "Angle"; TokenType[TokenType["Time"] = 31] = "Time"; TokenType[TokenType["Freq"] = 32] = "Freq"; TokenType[TokenType["Exclamation"] = 33] = "Exclamation"; TokenType[TokenType["Resolution"] = 34] = "Resolution"; TokenType[TokenType["Comma"] = 35] = "Comma"; TokenType[TokenType["Charset"] = 36] = "Charset"; TokenType[TokenType["EscapedJavaScript"] = 37] = "EscapedJavaScript"; TokenType[TokenType["BadEscapedJavaScript"] = 38] = "BadEscapedJavaScript"; TokenType[TokenType["Comment"] = 39] = "Comment"; TokenType[TokenType["SingleLineComment"] = 40] = "SingleLineComment"; TokenType[TokenType["EOF"] = 41] = "EOF"; TokenType[TokenType["CustomToken"] = 42] = "CustomToken"; })(TokenType = exports.TokenType || (exports.TokenType = {})); var MultiLineStream = /** @class */ (function () { function MultiLineStream(source) { this.source = source; this.len = source.length; this.position = 0; } MultiLineStream.prototype.substring = function (from, to) { if (to === void 0) { to = this.position; } return this.source.substring(from, to); }; MultiLineStream.prototype.eos = function () { return this.len <= this.position; }; MultiLineStream.prototype.pos = function () { return this.position; }; MultiLineStream.prototype.goBackTo = function (pos) { this.position = pos; }; MultiLineStream.prototype.goBack = function (n) { this.position -= n; }; MultiLineStream.prototype.advance = function (n) { this.position += n; }; MultiLineStream.prototype.nextChar = function () { return this.source.charCodeAt(this.position++) || 0; }; MultiLineStream.prototype.peekChar = function (n) { if (n === void 0) { n = 0; } return this.source.charCodeAt(this.position + n) || 0; }; MultiLineStream.prototype.lookbackChar = function (n) { if (n === void 0) { n = 0; } return this.source.charCodeAt(this.position - n) || 0; }; MultiLineStream.prototype.advanceIfChar = function (ch) { if (ch === this.source.charCodeAt(this.position)) { this.position++; return true; } return false; }; MultiLineStream.prototype.advanceIfChars = function (ch) { if (this.position + ch.length > this.source.length) { return false; } var i = 0; for (; i < ch.length; i++) { if (this.source.charCodeAt(this.position + i) !== ch[i]) { return false; } } this.advance(i); return true; }; MultiLineStream.prototype.advanceWhileChar = function (condition) { var posNow = this.position; while (this.position < this.len && condition(this.source.charCodeAt(this.position))) { this.position++; } return this.position - posNow; }; return MultiLineStream; }()); exports.MultiLineStream = MultiLineStream; var _a = 'a'.charCodeAt(0); var _f = 'f'.charCodeAt(0); var _z = 'z'.charCodeAt(0); var _A = 'A'.charCodeAt(0); var _F = 'F'.charCodeAt(0); var _Z = 'Z'.charCodeAt(0); var _0 = '0'.charCodeAt(0); var _9 = '9'.charCodeAt(0); var _TLD = '~'.charCodeAt(0); var _HAT = '^'.charCodeAt(0); var _EQS = '='.charCodeAt(0); var _PIP = '|'.charCodeAt(0); var _MIN = '-'.charCodeAt(0); var _USC = '_'.charCodeAt(0); var _PRC = '%'.charCodeAt(0); var _MUL = '*'.charCodeAt(0); var _LPA = '('.charCodeAt(0); var _RPA = ')'.charCodeAt(0); var _LAN = '<'.charCodeAt(0); var _RAN = '>'.charCodeAt(0); var _ATS = '@'.charCodeAt(0); var _HSH = '#'.charCodeAt(0); var _DLR = '$'.charCodeAt(0); var _BSL = '\\'.charCodeAt(0); var _FSL = '/'.charCodeAt(0); var _NWL = '\n'.charCodeAt(0); var _CAR = '\r'.charCodeAt(0); var _LFD = '\f'.charCodeAt(0); var _DQO = '"'.charCodeAt(0); var _SQO = '\''.charCodeAt(0); var _WSP = ' '.charCodeAt(0); var _TAB = '\t'.charCodeAt(0); var _SEM = ';'.charCodeAt(0); var _COL = ':'.charCodeAt(0); var _CUL = '{'.charCodeAt(0); var _CUR = '}'.charCodeAt(0); var _BRL = '['.charCodeAt(0); var _BRR = ']'.charCodeAt(0); var _CMA = ','.charCodeAt(0); var _DOT = '.'.charCodeAt(0); var _BNG = '!'.charCodeAt(0); var staticTokenTable = {}; staticTokenTable[_SEM] = TokenType.SemiColon; staticTokenTable[_COL] = TokenType.Colon; staticTokenTable[_CUL] = TokenType.CurlyL; staticTokenTable[_CUR] = TokenType.CurlyR; staticTokenTable[_BRR] = TokenType.BracketR; staticTokenTable[_BRL] = TokenType.BracketL; staticTokenTable[_LPA] = TokenType.ParenthesisL; staticTokenTable[_RPA] = TokenType.ParenthesisR; staticTokenTable[_CMA] = TokenType.Comma; var staticUnitTable = {}; staticUnitTable['em'] = TokenType.EMS; staticUnitTable['ex'] = TokenType.EXS; staticUnitTable['px'] = TokenType.Length; staticUnitTable['cm'] = TokenType.Length; staticUnitTable['mm'] = TokenType.Length; staticUnitTable['in'] = TokenType.Length; staticUnitTable['pt'] = TokenType.Length; staticUnitTable['pc'] = TokenType.Length; staticUnitTable['deg'] = TokenType.Angle; staticUnitTable['rad'] = TokenType.Angle; staticUnitTable['grad'] = TokenType.Angle; staticUnitTable['ms'] = TokenType.Time; staticUnitTable['s'] = TokenType.Time; staticUnitTable['hz'] = TokenType.Freq; staticUnitTable['khz'] = TokenType.Freq; staticUnitTable['%'] = TokenType.Percentage; staticUnitTable['fr'] = TokenType.Percentage; staticUnitTable['dpi'] = TokenType.Resolution; staticUnitTable['dpcm'] = TokenType.Resolution; var Scanner = /** @class */ (function () { function Scanner() { this.stream = new MultiLineStream(''); this.ignoreComment = true; this.ignoreWhitespace = true; this.inURL = false; } Scanner.prototype.setSource = function (input) { this.stream = new MultiLineStream(input); }; Scanner.prototype.finishToken = function (offset, type, text) { return { offset: offset, len: this.stream.pos() - offset, type: type, text: text || this.stream.substring(offset) }; }; Scanner.prototype.substring = function (offset, len) { return this.stream.substring(offset, offset + len); }; Scanner.prototype.pos = function () { return this.stream.pos(); }; Scanner.prototype.goBackTo = function (pos) { this.stream.goBackTo(pos); }; Scanner.prototype.scanUnquotedString = function () { var offset = this.stream.pos(); var content = []; if (this._unquotedString(content)) { return this.finishToken(offset, TokenType.UnquotedString, content.join('')); } return null; }; Scanner.prototype.scan = function () { // processes all whitespaces and comments var triviaToken = this.trivia(); if (triviaToken !== null) { return triviaToken; } var offset = this.stream.pos(); // End of file/input if (this.stream.eos()) { return this.finishToken(offset, TokenType.EOF); } return this.scanNext(offset); }; Scanner.prototype.scanNext = function (offset) { // CDO if (this.stream.advanceIfChars([_MIN, _MIN, _RAN])) { return this.finishToken(offset, TokenType.CDC); } var content = []; if (this.ident(content)) { return this.finishToken(offset, TokenType.Ident, content.join('')); } // at-keyword if (this.stream.advanceIfChar(_ATS)) { content = ['@']; if (this._name(content)) { var keywordText = content.join(''); if (keywordText === '@charset') { return this.finishToken(offset, TokenType.Charset, keywordText); } return this.finishToken(offset, TokenType.AtKeyword, keywordText); } else { return this.finishToken(offset, TokenType.Delim); } } // hash if (this.stream.advanceIfChar(_HSH)) { content = ['#']; if (this._name(content)) { return this.finishToken(offset, TokenType.Hash, content.join('')); } else { return this.finishToken(offset, TokenType.Delim); } } // Important if (this.stream.advanceIfChar(_BNG)) { return this.finishToken(offset, TokenType.Exclamation); } // Numbers if (this._number()) { var pos = this.stream.pos(); content = [this.stream.substring(offset, pos)]; if (this.stream.advanceIfChar(_PRC)) { // Percentage 43% return this.finishToken(offset, TokenType.Percentage); } else if (this.ident(content)) { var dim = this.stream.substring(pos).toLowerCase(); var tokenType_1 = staticUnitTable[dim]; if (typeof tokenType_1 !== 'undefined') { // Known dimension 43px return this.finishToken(offset, tokenType_1, content.join('')); } else { // Unknown dimension 43ft return this.finishToken(offset, TokenType.Dimension, content.join('')); } } return this.finishToken(offset, TokenType.Num); } // String, BadString content = []; var tokenType = this._string(content); if (tokenType !== null) { return this.finishToken(offset, tokenType, content.join('')); } // single character tokens tokenType = staticTokenTable[this.stream.peekChar()]; if (typeof tokenType !== 'undefined') { this.stream.advance(1); return this.finishToken(offset, tokenType); } // includes ~= if (this.stream.peekChar(0) === _TLD && this.stream.peekChar(1) === _EQS) { this.stream.advance(2); return this.finishToken(offset, TokenType.Includes); } // DashMatch |= if (this.stream.peekChar(0) === _PIP && this.stream.peekChar(1) === _EQS) { this.stream.advance(2); return this.finishToken(offset, TokenType.Dashmatch); } // Substring operator *= if (this.stream.peekChar(0) === _MUL && this.stream.peekChar(1) === _EQS) { this.stream.advance(2); return this.finishToken(offset, TokenType.SubstringOperator); } // Substring operator ^= if (this.stream.peekChar(0) === _HAT && this.stream.peekChar(1) === _EQS) { this.stream.advance(2); return this.finishToken(offset, TokenType.PrefixOperator); } // Substring operator $= if (this.stream.peekChar(0) === _DLR && this.stream.peekChar(1) === _EQS) { this.stream.advance(2); return this.finishToken(offset, TokenType.SuffixOperator); } // Delim this.stream.nextChar(); return this.finishToken(offset, TokenType.Delim); }; Scanner.prototype.trivia = function () { while (true) { var offset = this.stream.pos(); if (this._whitespace()) { if (!this.ignoreWhitespace) { return this.finishToken(offset, TokenType.Whitespace); } } else if (this.comment()) { if (!this.ignoreComment) { return this.finishToken(offset, TokenType.Comment); } } else { return null; } } }; Scanner.prototype.comment = function () { if (this.stream.advanceIfChars([_FSL, _MUL])) { var success_1 = false, hot_1 = false; this.stream.advanceWhileChar(function (ch) { if (hot_1 && ch === _FSL) { success_1 = true; return false; } hot_1 = ch === _MUL; return true; }); if (success_1) { this.stream.advance(1); } return true; } return false; }; Scanner.prototype._number = function () { var npeek = 0, ch; if (this.stream.peekChar() === _DOT) { npeek = 1; } ch = this.stream.peekChar(npeek); if (ch >= _0 && ch <= _9) { this.stream.advance(npeek + 1); this.stream.advanceWhileChar(function (ch) { return ch >= _0 && ch <= _9 || npeek === 0 && ch === _DOT; }); return true; } return false; }; Scanner.prototype._newline = function (result) { var ch = this.stream.peekChar(); switch (ch) { case _CAR: case _LFD: case _NWL: this.stream.advance(1); result.push(String.fromCharCode(ch)); if (ch === _CAR && this.stream.advanceIfChar(_NWL)) { result.push('\n'); } return true; } return false; }; Scanner.prototype._escape = function (result, includeNewLines) { var ch = this.stream.peekChar(); if (ch === _BSL) { this.stream.advance(1); ch = this.stream.peekChar(); var hexNumCount = 0; while (hexNumCount < 6 && (ch >= _0 && ch <= _9 || ch >= _a && ch <= _f || ch >= _A && ch <= _F)) { this.stream.advance(1); ch = this.stream.peekChar(); hexNumCount++; } if (hexNumCount > 0) { try { var hexVal = parseInt(this.stream.substring(this.stream.pos() - hexNumCount), 16); if (hexVal) { result.push(String.fromCharCode(hexVal)); } } catch (e) { // ignore } // optional whitespace or new line, not part of result text if (ch === _WSP || ch === _TAB) { this.stream.advance(1); } else { this._newline([]); } return true; } if (ch !== _CAR && ch !== _LFD && ch !== _NWL) { this.stream.advance(1); result.push(String.fromCharCode(ch)); return true; } else if (includeNewLines) { return this._newline(result); } } return false; }; Scanner.prototype._stringChar = function (closeQuote, result) { // not closeQuote, not backslash, not newline var ch = this.stream.peekChar(); if (ch !== 0 && ch !== closeQuote && ch !== _BSL && ch !== _CAR && ch !== _LFD && ch !== _NWL) { this.stream.advance(1); result.push(String.fromCharCode(ch)); return true; } return false; }; Scanner.prototype._string = function (result) { if (this.stream.peekChar() === _SQO || this.stream.peekChar() === _DQO) { var closeQuote = this.stream.nextChar(); result.push(String.fromCharCode(closeQuote)); while (this._stringChar(closeQuote, result) || this._escape(result, true)) { // loop } if (this.stream.peekChar() === closeQuote) { this.stream.nextChar(); result.push(String.fromCharCode(closeQuote)); return TokenType.String; } else { return TokenType.BadString; } } return null; }; Scanner.prototype._unquotedChar = function (result) { // not closeQuote, not backslash, not newline var ch = this.stream.peekChar(); if (ch !== 0 && ch !== _BSL && ch !== _SQO && ch !== _DQO && ch !== _LPA && ch !== _RPA && ch !== _WSP && ch !== _TAB && ch !== _NWL && ch !== _LFD && ch !== _CAR) { this.stream.advance(1); result.push(String.fromCharCode(ch)); return true; } return false; }; Scanner.prototype._unquotedString = function (result) { var hasContent = false; while (this._unquotedChar(result) || this._escape(result)) { hasContent = true; } return hasContent; }; Scanner.prototype._whitespace = function () { var n = this.stream.advanceWhileChar(function (ch) { return ch === _WSP || ch === _TAB || ch === _NWL || ch === _LFD || ch === _CAR; }); return n > 0; }; Scanner.prototype._name = function (result) { var matched = false; while (this._identChar(result) || this._escape(result)) { matched = true; } return matched; }; Scanner.prototype.ident = function (result) { var pos = this.stream.pos(); var hasMinus = this._minus(result); if (hasMinus && this._minus(result) /* -- */) { if (this._identFirstChar(result) || this._escape(result)) { while (this._identChar(result) || this._escape(result)) { // loop } return true; } } else if (this._identFirstChar(result) || this._escape(result)) { while (this._identChar(result) || this._escape(result)) { // loop } return true; } this.stream.goBackTo(pos); return false; }; Scanner.prototype._identFirstChar = function (result) { var ch = this.stream.peekChar(); if (ch === _USC || // _ ch >= _a && ch <= _z || // a-z ch >= _A && ch <= _Z || // A-Z ch >= 0x80 && ch <= 0xFFFF) { // nonascii this.stream.advance(1); result.push(String.fromCharCode(ch)); return true; } return false; }; Scanner.prototype._minus = function (result) { var ch = this.stream.peekChar(); if (ch === _MIN) { this.stream.advance(1); result.push(String.fromCharCode(ch)); return true; } return false; }; Scanner.prototype._identChar = function (result) { var ch = this.stream.peekChar(); if (ch === _USC || // _ ch === _MIN || // - ch >= _a && ch <= _z || // a-z ch >= _A && ch <= _Z || // A-Z ch >= _0 && ch <= _9 || // 0/9 ch >= 0x80 && ch <= 0xFFFF) { // nonascii this.stream.advance(1); result.push(String.fromCharCode(ch)); return true; } return false; }; return Scanner; }()); exports.Scanner = Scanner; }); (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('vscode-css-languageservice/utils/strings',["require", "exports"], 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 }); exports.trim = exports.getLimitedString = exports.difference = exports.endsWith = exports.startsWith = void 0; function startsWith(haystack, needle) { if (haystack.length < needle.length) { return false; } for (var i = 0; i < needle.length; i++) { if (haystack[i] !== needle[i]) { return false; } } return true; } exports.startsWith = startsWith; /** * Determines if haystack ends with needle. */ function endsWith(haystack, needle) { var diff = haystack.length - needle.length; if (diff > 0) { return haystack.lastIndexOf(needle) === diff; } else if (diff === 0) { return haystack === needle; } else { return false; } } exports.endsWith = endsWith; /** * Computes the difference score for two strings. More similar strings have a higher score. * We use largest common subsequence dynamic programming approach but penalize in the end for length differences. * Strings that have a large length difference will get a bad default score 0. * Complexity - both time and space O(first.length * second.length) * Dynamic programming LCS computation http://en.wikipedia.org/wiki/Longest_common_subsequence_problem * * @param first a string * @param second a string */ function difference(first, second, maxLenDelta) { if (maxLenDelta === void 0) { maxLenDelta = 4; } var lengthDifference = Math.abs(first.length - second.length); // We only compute score if length of the currentWord and length of entry.name are similar. if (lengthDifference > maxLenDelta) { return 0; } // Initialize LCS (largest common subsequence) matrix. var LCS = []; var zeroArray = []; var i, j; for (i = 0; i < second.length + 1; ++i) { zeroArray.push(0); } for (i = 0; i < first.length + 1; ++i) { LCS.push(zeroArray); } for (i = 1; i < first.length + 1; ++i) { for (j = 1; j < second.length + 1; ++j) { if (first[i - 1] === second[j - 1]) { LCS[i][j] = LCS[i - 1][j - 1] + 1; } else { LCS[i][j] = Math.max(LCS[i - 1][j], LCS[i][j - 1]); } } } return LCS[first.length][second.length] - Math.sqrt(lengthDifference); } exports.difference = difference; /** * Limit of string length. */ function getLimitedString(str, ellipsis) { if (ellipsis === void 0) { ellipsis = true; } if (!str) { return ''; } if (str.length < 140) { return str; } return str.slice(0, 140) + (ellipsis ? '\u2026' : ''); } exports.getLimitedString = getLimitedString; /** * Limit of string length. */ function trim(str, regexp) { var m = regexp.exec(str); if (m && m[0].length) { return str.substr(0, str.length - m[0].length); } return str; } exports.trim = trim; }); var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); (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('vscode-css-languageservice/parser/cssNodes',["require", "exports", "../utils/strings"], 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 }); exports.ParseErrorCollector = exports.Marker = exports.Level = exports.Module = exports.GuardCondition = exports.LessGuard = exports.ListEntry = exports.UnknownAtRule = exports.MixinDeclaration = exports.MixinReference = exports.MixinContentDeclaration = exports.MixinContentReference = exports.ExtendsReference = exports.Variable = exports.Interpolation = exports.VariableDeclaration = exports.NumericValue = exports.HexColorValue = exports.Operator = exports.AttributeSelector = exports.Term = exports.BinaryExpression = exports.Expression = exports.PageBoxMarginBox = exports.Page = exports.SupportsCondition = exports.MediaQuery = exports.Medialist = exports.Document = exports.Supports = exports.Media = exports.Namespace = exports.ForwardVisibility = exports.Forward = exports.ModuleConfiguration = exports.Use = exports.Import = exports.KeyframeSelector = exports.Keyframe = exports.NestedProperties = exports.FontFace = exports.ViewPort = exports.FunctionDeclaration = exports.ElseStatement = exports.WhileStatement = exports.EachStatement = exports.ForStatement = exports.IfStatement = exports.FunctionArgument = exports.FunctionParameter = exports.Function = exports.Invocation = exports.Property = exports.CustomPropertyDeclaration = exports.Declaration = exports.CustomPropertySet = exports.AbstractDeclaration = exports.AtApplyRule = exports.SimpleSelector = exports.Selector = exports.RuleSet = exports.BodyDeclaration = exports.Declarations = exports.Stylesheet = exports.Identifier = exports.Nodelist = exports.Node = exports.getParentDeclaration = exports.getNodePath = exports.getNodeAtOffset = exports.ReferenceType = exports.NodeType = void 0; var strings_1 = require("../utils/strings"); /// /// Nodes for the css 2.1 specification. See for reference: /// http://www.w3.org/TR/CSS21/grammar.html#grammar /// var NodeType; (function (NodeType) { NodeType[NodeType["Undefined"] = 0] = "Undefined"; NodeType[NodeType["Identifier"] = 1] = "Identifier"; NodeType[NodeType["Stylesheet"] = 2] = "Stylesheet"; NodeType[NodeType["Ruleset"] = 3] = "Ruleset"; NodeType[NodeType["Selector"] = 4] = "Selector"; NodeType[NodeType["SimpleSelector"] = 5] = "SimpleSelector"; NodeType[NodeType["SelectorInterpolation"] = 6] = "SelectorInterpolation"; NodeType[NodeType["SelectorCombinator"] = 7] = "SelectorCombinator"; NodeType[NodeType["SelectorCombinatorParent"] = 8] = "SelectorCombinatorParent"; NodeType[NodeType["SelectorCombinatorSibling"] = 9] = "SelectorCombinatorSibling"; NodeType[NodeType["SelectorCombinatorAllSiblings"] = 10] = "SelectorCombinatorAllSiblings"; NodeType[NodeType["SelectorCombinatorShadowPiercingDescendant"] = 11] = "SelectorCombinatorShadowPiercingDescendant"; NodeType[NodeType["Page"] = 12] = "Page"; NodeType[NodeType["PageBoxMarginBox"] = 13] = "PageBoxMarginBox"; NodeType[NodeType["ClassSelector"] = 14] = "ClassSelector"; NodeType[NodeType["IdentifierSelector"] = 15] = "IdentifierSelector"; NodeType[NodeType["ElementNameSelector"] = 16] = "ElementNameSelector"; NodeType[NodeType["PseudoSelector"] = 17] = "PseudoSelector"; NodeType[NodeType["AttributeSelector"] = 18] = "AttributeSelector"; NodeType[NodeType["Declaration"] = 19] = "Declaration"; NodeType[NodeType["Declarations"] = 20] = "Declarations"; NodeType[NodeType["Property"] = 21] = "Property"; NodeType[NodeType["Expression"] = 22] = "Expression"; NodeType[NodeType["BinaryExpression"] = 23] = "BinaryExpression"; NodeType[NodeType["Term"] = 24] = "Term"; NodeType[NodeType["Operator"] = 25] = "Operator"; NodeType[NodeType["Value"] = 26] = "Value"; NodeType[NodeType["StringLiteral"] = 27] = "StringLiteral"; NodeType[NodeType["URILiteral"] = 28] = "URILiteral"; NodeType[NodeType["EscapedValue"] = 29] = "EscapedValue"; NodeType[NodeType["Function"] = 30] = "Function"; NodeType[NodeType["NumericValue"] = 31] = "NumericValue"; NodeType[NodeType["HexColorValue"] = 32] = "HexColorValue"; NodeType[NodeType["MixinDeclaration"] = 33] = "MixinDeclaration"; NodeType[NodeType["MixinReference"] = 34] = "MixinReference"; NodeType[NodeType["VariableName"] = 35] = "VariableName"; NodeType[NodeType["VariableDeclaration"] = 36] = "VariableDeclaration"; NodeType[NodeType["Prio"] = 37] = "Prio"; NodeType[NodeType["Interpolation"] = 38] = "Interpolation"; NodeType[NodeType["NestedProperties"] = 39] = "NestedProperties"; NodeType[NodeType["ExtendsReference"] = 40] = "ExtendsReference"; NodeType[NodeType["SelectorPlaceholder"] = 41] = "SelectorPlaceholder"; NodeType[NodeType["Debug"] = 42] = "Debug"; NodeType[NodeType["If"] = 43] = "If"; NodeType[NodeType["Else"] = 44] = "Else"; NodeType[NodeType["For"] = 45] = "For"; NodeType[NodeType["Each"] = 46] = "Each"; NodeType[NodeType["While"] = 47] = "While"; NodeType[NodeType["MixinContentReference"] = 48] = "MixinContentReference"; NodeType[NodeType["MixinContentDeclaration"] = 49] = "MixinContentDeclaration"; NodeType[NodeType["Media"] = 50] = "Media"; NodeType[NodeType["Keyframe"] = 51] = "Keyframe"; NodeType[NodeType["FontFace"] = 52] = "FontFace"; NodeType[NodeType["Import"] = 53] = "Import"; NodeType[NodeType["Namespace"] = 54] = "Namespace"; NodeType[NodeType["Invocation"] = 55] = "Invocation"; NodeType[NodeType["FunctionDeclaration"] = 56] = "FunctionDeclaration"; NodeType[NodeType["ReturnStatement"] = 57] = "ReturnStatement"; NodeType[NodeType["MediaQuery"] = 58] = "MediaQuery"; NodeType[NodeType["FunctionParameter"] = 59] = "FunctionParameter"; NodeType[NodeType["FunctionArgument"] = 60] = "FunctionArgument"; NodeType[NodeType["KeyframeSelector"] = 61] = "KeyframeSelector"; NodeType[NodeType["ViewPort"] = 62] = "ViewPort"; NodeType[NodeType["Document"] = 63] = "Document"; NodeType[NodeType["AtApplyRule"] = 64] = "AtApplyRule"; NodeType[NodeType["CustomPropertyDeclaration"] = 65] = "CustomPropertyDeclaration"; NodeType[NodeType["CustomPropertySet"] = 66] = "CustomPropertySet"; NodeType[NodeType["ListEntry"] = 67] = "ListEntry"; NodeType[NodeType["Supports"] = 68] = "Supports"; NodeType[NodeType["SupportsCondition"] = 69] = "SupportsCondition"; NodeType[NodeType["NamespacePrefix"] = 70] = "NamespacePrefix"; NodeType[NodeType["GridLine"] = 71] = "GridLine"; NodeType[NodeType["Plugin"] = 72] = "Plugin"; NodeType[NodeType["UnknownAtRule"] = 73] = "UnknownAtRule"; NodeType[NodeType["Use"] = 74] = "Use"; NodeType[NodeType["ModuleConfiguration"] = 75] = "ModuleConfiguration"; NodeType[NodeType["Forward"] = 76] = "Forward"; NodeType[NodeType["ForwardVisibility"] = 77] = "ForwardVisibility"; NodeType[NodeType["Module"] = 78] = "Module"; })(NodeType = exports.NodeType || (exports.NodeType = {})); var ReferenceType; (function (ReferenceType) { ReferenceType[ReferenceType["Mixin"] = 0] = "Mixin"; ReferenceType[ReferenceType["Rule"] = 1] = "Rule"; ReferenceType[ReferenceType["Variable"] = 2] = "Variable"; ReferenceType[ReferenceType["Function"] = 3] = "Function"; ReferenceType[ReferenceType["Keyframe"] = 4] = "Keyframe"; ReferenceType[ReferenceType["Unknown"] = 5] = "Unknown"; ReferenceType[ReferenceType["Module"] = 6] = "Module"; ReferenceType[ReferenceType["Forward"] = 7] = "Forward"; ReferenceType[ReferenceType["ForwardVisibility"] = 8] = "ForwardVisibility"; })(ReferenceType = exports.ReferenceType || (exports.ReferenceType = {})); function getNodeAtOffset(node, offset) { var candidate = null; if (!node || offset < node.offset || offset > node.end) { return null; } // Find the shortest node at the position node.accept(function (node) { if (node.offset === -1 && node.length === -1) { return true; } if (node.offset <= offset && node.end >= offset) { if (!candidate) { candidate = node; } else if (node.length <= candidate.length) { candidate = node; } return true; } return false; }); return candidate; } exports.getNodeAtOffset = getNodeAtOffset; function getNodePath(node, offset) { var candidate = getNodeAtOffset(node, offset); var path = []; while (candidate) { path.unshift(candidate); candidate = candidate.parent; } return path; } exports.getNodePath = getNodePath; function getParentDeclaration(node) { var decl = node.findParent(NodeType.Declaration); var value = decl && decl.getValue(); if (value && value.encloses(node)) { return decl; } return null; } exports.getParentDeclaration = getParentDeclaration; var Node = /** @class */ (function () { function Node(offset, len, nodeType) { if (offset === void 0) { offset = -1; } if (len === void 0) { len = -1; } this.parent = null; this.offset = offset; this.length = len; if (nodeType) { this.nodeType = nodeType; } } Object.defineProperty(Node.prototype, "end", { get: function () { return this.offset + this.length; }, enumerable: false, configurable: true }); Object.defineProperty(Node.prototype, "type", { get: function () { return this.nodeType || NodeType.Undefined; }, set: function (type) { this.nodeType = type; }, enumerable: false, configurable: true }); Node.prototype.getTextProvider = function () { var node = this; while (node && !node.textProvider) { node = node.parent; } if (node) { return node.textProvider; } return function () { return 'unknown'; }; }; Node.prototype.getText = function () { return this.getTextProvider()(this.offset, this.length); }; Node.prototype.matches = function (str) { return this.length === str.length && this.getTextProvider()(this.offset, this.length) === str; }; Node.prototype.startsWith = function (str) { return this.length >= str.length && this.getTextProvider()(this.offset, str.length) === str; }; Node.prototype.endsWith = function (str) { return this.length >= str.length && this.getTextProvider()(this.end - str.length, str.length) === str; }; Node.prototype.accept = function (visitor) { if (visitor(this) && this.children) { for (var _i = 0, _a = this.children; _i < _a.length; _i++) { var child = _a[_i]; child.accept(visitor); } } }; Node.prototype.acceptVisitor = function (visitor) { this.accept(visitor.visitNode.bind(visitor)); }; Node.prototype.adoptChild = function (node, index) { if (index === void 0) { index = -1; } if (node.parent && node.parent.children) { var idx = node.parent.children.indexOf(node); if (idx >= 0) { node.parent.children.splice(idx, 1); } } node.parent = this; var children = this.children; if (!children) { children = this.children = []; } if (index !== -1) { children.splice(index, 0, node); } else { children.push(node); } return node; }; Node.prototype.attachTo = function (parent, index) { if (index === void 0) { index = -1; } if (parent) { parent.adoptChild(this, index); } return this; }; Node.prototype.collectIssues = function (results) { if (this.issues) { results.push.apply(results, this.issues); } }; Node.prototype.addIssue = function (issue) { if (!this.issues) { this.issues = []; } this.issues.push(issue); }; Node.prototype.hasIssue = function (rule) { return Array.isArray(this.issues) && this.issues.some(function (i) { return i.getRule() === rule; }); }; Node.prototype.isErroneous = function (recursive) { if (recursive === void 0) { recursive = false; } if (this.issues && this.issues.length > 0) { return true; } return recursive && Array.isArray(this.children) && this.children.some(function (c) { return c.isErroneous(true); }); }; Node.prototype.setNode = function (field, node, index) { if (index === void 0) { index = -1; } if (node) { node.attachTo(this, index); this[field] = node; return true; } return false; }; Node.prototype.addChild = function (node) { if (node) { if (!this.children) { this.children = []; } node.attachTo(this); this.updateOffsetAndLength(node); return true; } return false; }; Node.prototype.updateOffsetAndLength = function (node) { if (node.offset < this.offset || this.offset === -1) { this.offset = node.offset; } var nodeEnd = node.end; if ((nodeEnd > this.end) || this.length === -1) { this.length = nodeEnd - this.offset; } }; Node.prototype.hasChildren = function () { return !!this.children && this.children.length > 0; }; Node.prototype.getChildren = function () { return this.children ? this.children.slice(0) : []; }; Node.prototype.getChild = function (index) { if (this.children && index < this.children.length) { return this.children[index]; } return null; }; Node.prototype.addChildren = function (nodes) { for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { var node = nodes_1[_i]; this.addChild(node); } }; Node.prototype.findFirstChildBeforeOffset = function (offset) { if (this.children) { var current = null; for (var i = this.children.length - 1; i >= 0; i--) { // iterate until we find a child that has a start offset smaller than the input offset current = this.children[i]; if (current.offset <= offset) { return current; } } } return null; }; Node.prototype.findChildAtOffset = function (offset, goDeep) { var current = this.findFirstChildBeforeOffset(offset); if (current && current.end >= offset) { if (goDeep) { return current.findChildAtOffset(offset, true) || current; } return current; } return null; }; Node.prototype.encloses = function (candidate) { return this.offset <= candidate.offset && this.offset + this.length >= candidate.offset + candidate.length; }; Node.prototype.getParent = function () { var result = this.parent; while (result instanceof Nodelist) { result = result.parent; } return result; }; Node.prototype.findParent = function (type) { var result = this; while (result && result.type !== type) { result = result.parent; } return result; }; Node.prototype.findAParent = function () { var types = []; for (var _i = 0; _i < arguments.length; _i++) { types[_i] = arguments[_i]; } var result = this; while (result && !types.some(function (t) { return result.type === t; })) { result = result.parent; } return result; }; Node.prototype.setData = function (key, value) { if (!this.options) { this.options = {}; } this.options[key] = value; }; Node.prototype.getData = function (key) { if (!this.options || !this.options.hasOwnProperty(key)) { return null; } return this.options[key]; }; return Node; }()); exports.Node = Node; var Nodelist = /** @class */ (function (_super) { __extends(Nodelist, _super); function Nodelist(parent, index) { if (index === void 0) { index = -1; } var _this = _super.call(this, -1, -1) || this; _this.attachTo(parent, index); _this.offset = -1; _this.length = -1; return _this; } return Nodelist; }(Node)); exports.Nodelist = Nodelist; var Identifier = /** @class */ (function (_super) { __extends(Identifier, _super); function Identifier(offset, length) { var _this = _super.call(this, offset, length) || this; _this.isCustomProperty = false; return _this; } Object.defineProperty(Identifier.prototype, "type", { get: function () { return NodeType.Identifier; }, enumerable: false, configurable: true }); Identifier.prototype.containsInterpolation = function () { return this.hasChildren(); }; return Identifier; }(Node)); exports.Identifier = Identifier; var Stylesheet = /** @class */ (function (_super) { __extends(Stylesheet, _super); function Stylesheet(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Stylesheet.prototype, "type", { get: function () { return NodeType.Stylesheet; }, enumerable: false, configurable: true }); return Stylesheet; }(Node)); exports.Stylesheet = Stylesheet; var Declarations = /** @class */ (function (_super) { __extends(Declarations, _super); function Declarations(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Declarations.prototype, "type", { get: function () { return NodeType.Declarations; }, enumerable: false, configurable: true }); return Declarations; }(Node)); exports.Declarations = Declarations; var BodyDeclaration = /** @class */ (function (_super) { __extends(BodyDeclaration, _super); function BodyDeclaration(offset, length) { return _super.call(this, offset, length) || this; } BodyDeclaration.prototype.getDeclarations = function () { return this.declarations; }; BodyDeclaration.prototype.setDeclarations = function (decls) { return this.setNode('declarations', decls); }; return BodyDeclaration; }(Node)); exports.BodyDeclaration = BodyDeclaration; var RuleSet = /** @class */ (function (_super) { __extends(RuleSet, _super); function RuleSet(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(RuleSet.prototype, "type", { get: function () { return NodeType.Ruleset; }, enumerable: false, configurable: true }); RuleSet.prototype.getSelectors = function () { if (!this.selectors) { this.selectors = new Nodelist(this); } return this.selectors; }; RuleSet.prototype.isNested = function () { return !!this.parent && this.parent.findParent(NodeType.Declarations) !== null; }; return RuleSet; }(BodyDeclaration)); exports.RuleSet = RuleSet; var Selector = /** @class */ (function (_super) { __extends(Selector, _super); function Selector(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Selector.prototype, "type", { get: function () { return NodeType.Selector; }, enumerable: false, configurable: true }); return Selector; }(Node)); exports.Selector = Selector; var SimpleSelector = /** @class */ (function (_super) { __extends(SimpleSelector, _super); function SimpleSelector(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(SimpleSelector.prototype, "type", { get: function () { return NodeType.SimpleSelector; }, enumerable: false, configurable: true }); return SimpleSelector; }(Node)); exports.SimpleSelector = SimpleSelector; var AtApplyRule = /** @class */ (function (_super) { __extends(AtApplyRule, _super); function AtApplyRule(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(AtApplyRule.prototype, "type", { get: function () { return NodeType.AtApplyRule; }, enumerable: false, configurable: true }); AtApplyRule.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; AtApplyRule.prototype.getIdentifier = function () { return this.identifier; }; AtApplyRule.prototype.getName = function () { return this.identifier ? this.identifier.getText() : ''; }; return AtApplyRule; }(Node)); exports.AtApplyRule = AtApplyRule; var AbstractDeclaration = /** @class */ (function (_super) { __extends(AbstractDeclaration, _super); function AbstractDeclaration(offset, length) { return _super.call(this, offset, length) || this; } return AbstractDeclaration; }(Node)); exports.AbstractDeclaration = AbstractDeclaration; var CustomPropertySet = /** @class */ (function (_super) { __extends(CustomPropertySet, _super); function CustomPropertySet(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(CustomPropertySet.prototype, "type", { get: function () { return NodeType.CustomPropertySet; }, enumerable: false, configurable: true }); return CustomPropertySet; }(BodyDeclaration)); exports.CustomPropertySet = CustomPropertySet; var Declaration = /** @class */ (function (_super) { __extends(Declaration, _super); function Declaration(offset, length) { var _this = _super.call(this, offset, length) || this; _this.property = null; return _this; } Object.defineProperty(Declaration.prototype, "type", { get: function () { return NodeType.Declaration; }, enumerable: false, configurable: true }); Declaration.prototype.setProperty = function (node) { return this.setNode('property', node); }; Declaration.prototype.getProperty = function () { return this.property; }; Declaration.prototype.getFullPropertyName = function () { var propertyName = this.property ? this.property.getName() : 'unknown'; if (this.parent instanceof Declarations && this.parent.getParent() instanceof NestedProperties) { var parentDecl = this.parent.getParent().getParent(); if (parentDecl instanceof Declaration) { return parentDecl.getFullPropertyName() + propertyName; } } return propertyName; }; Declaration.prototype.getNonPrefixedPropertyName = function () { var propertyName = this.getFullPropertyName(); if (propertyName && propertyName.charAt(0) === '-') { var vendorPrefixEnd = propertyName.indexOf('-', 1); if (vendorPrefixEnd !== -1) { return propertyName.substring(vendorPrefixEnd + 1); } } return propertyName; }; Declaration.prototype.setValue = function (value) { return this.setNode('value', value); }; Declaration.prototype.getValue = function () { return this.value; }; Declaration.prototype.setNestedProperties = function (value) { return this.setNode('nestedProperties', value); }; Declaration.prototype.getNestedProperties = function () { return this.nestedProperties; }; return Declaration; }(AbstractDeclaration)); exports.Declaration = Declaration; var CustomPropertyDeclaration = /** @class */ (function (_super) { __extends(CustomPropertyDeclaration, _super); function CustomPropertyDeclaration(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(CustomPropertyDeclaration.prototype, "type", { get: function () { return NodeType.CustomPropertyDeclaration; }, enumerable: false, configurable: true }); CustomPropertyDeclaration.prototype.setPropertySet = function (value) { return this.setNode('propertySet', value); }; CustomPropertyDeclaration.prototype.getPropertySet = function () { return this.propertySet; }; return CustomPropertyDeclaration; }(Declaration)); exports.CustomPropertyDeclaration = CustomPropertyDeclaration; var Property = /** @class */ (function (_super) { __extends(Property, _super); function Property(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Property.prototype, "type", { get: function () { return NodeType.Property; }, enumerable: false, configurable: true }); Property.prototype.setIdentifier = function (value) { return this.setNode('identifier', value); }; Property.prototype.getIdentifier = function () { return this.identifier; }; Property.prototype.getName = function () { return (0, strings_1.trim)(this.getText(), /[_\+]+$/); /* +_: less merge */ }; Property.prototype.isCustomProperty = function () { return !!this.identifier && this.identifier.isCustomProperty; }; return Property; }(Node)); exports.Property = Property; var Invocation = /** @class */ (function (_super) { __extends(Invocation, _super); function Invocation(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Invocation.prototype, "type", { get: function () { return NodeType.Invocation; }, enumerable: false, configurable: true }); Invocation.prototype.getArguments = function () { if (!this.arguments) { this.arguments = new Nodelist(this); } return this.arguments; }; return Invocation; }(Node)); exports.Invocation = Invocation; var Function = /** @class */ (function (_super) { __extends(Function, _super); function Function(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Function.prototype, "type", { get: function () { return NodeType.Function; }, enumerable: false, configurable: true }); Function.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; Function.prototype.getIdentifier = function () { return this.identifier; }; Function.prototype.getName = function () { return this.identifier ? this.identifier.getText() : ''; }; return Function; }(Invocation)); exports.Function = Function; var FunctionParameter = /** @class */ (function (_super) { __extends(FunctionParameter, _super); function FunctionParameter(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(FunctionParameter.prototype, "type", { get: function () { return NodeType.FunctionParameter; }, enumerable: false, configurable: true }); FunctionParameter.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; FunctionParameter.prototype.getIdentifier = function () { return this.identifier; }; FunctionParameter.prototype.getName = function () { return this.identifier ? this.identifier.getText() : ''; }; FunctionParameter.prototype.setDefaultValue = function (node) { return this.setNode('defaultValue', node, 0); }; FunctionParameter.prototype.getDefaultValue = function () { return this.defaultValue; }; return FunctionParameter; }(Node)); exports.FunctionParameter = FunctionParameter; var FunctionArgument = /** @class */ (function (_super) { __extends(FunctionArgument, _super); function FunctionArgument(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(FunctionArgument.prototype, "type", { get: function () { return NodeType.FunctionArgument; }, enumerable: false, configurable: true }); FunctionArgument.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; FunctionArgument.prototype.getIdentifier = function () { return this.identifier; }; FunctionArgument.prototype.getName = function () { return this.identifier ? this.identifier.getText() : ''; }; FunctionArgument.prototype.setValue = function (node) { return this.setNode('value', node, 0); }; FunctionArgument.prototype.getValue = function () { return this.value; }; return FunctionArgument; }(Node)); exports.FunctionArgument = FunctionArgument; var IfStatement = /** @class */ (function (_super) { __extends(IfStatement, _super); function IfStatement(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(IfStatement.prototype, "type", { get: function () { return NodeType.If; }, enumerable: false, configurable: true }); IfStatement.prototype.setExpression = function (node) { return this.setNode('expression', node, 0); }; IfStatement.prototype.setElseClause = function (elseClause) { return this.setNode('elseClause', elseClause); }; return IfStatement; }(BodyDeclaration)); exports.IfStatement = IfStatement; var ForStatement = /** @class */ (function (_super) { __extends(ForStatement, _super); function ForStatement(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(ForStatement.prototype, "type", { get: function () { return NodeType.For; }, enumerable: false, configurable: true }); ForStatement.prototype.setVariable = function (node) { return this.setNode('variable', node, 0); }; return ForStatement; }(BodyDeclaration)); exports.ForStatement = ForStatement; var EachStatement = /** @class */ (function (_super) { __extends(EachStatement, _super); function EachStatement(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(EachStatement.prototype, "type", { get: function () { return NodeType.Each; }, enumerable: false, configurable: true }); EachStatement.prototype.getVariables = function () { if (!this.variables) { this.variables = new Nodelist(this); } return this.variables; }; return EachStatement; }(BodyDeclaration)); exports.EachStatement = EachStatement; var WhileStatement = /** @class */ (function (_super) { __extends(WhileStatement, _super); function WhileStatement(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(WhileStatement.prototype, "type", { get: function () { return NodeType.While; }, enumerable: false, configurable: true }); return WhileStatement; }(BodyDeclaration)); exports.WhileStatement = WhileStatement; var ElseStatement = /** @class */ (function (_super) { __extends(ElseStatement, _super); function ElseStatement(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(ElseStatement.prototype, "type", { get: function () { return NodeType.Else; }, enumerable: false, configurable: true }); return ElseStatement; }(BodyDeclaration)); exports.ElseStatement = ElseStatement; var FunctionDeclaration = /** @class */ (function (_super) { __extends(FunctionDeclaration, _super); function FunctionDeclaration(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(FunctionDeclaration.prototype, "type", { get: function () { return NodeType.FunctionDeclaration; }, enumerable: false, configurable: true }); FunctionDeclaration.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; FunctionDeclaration.prototype.getIdentifier = function () { return this.identifier; }; FunctionDeclaration.prototype.getName = function () { return this.identifier ? this.identifier.getText() : ''; }; FunctionDeclaration.prototype.getParameters = function () { if (!this.parameters) { this.parameters = new Nodelist(this); } return this.parameters; }; return FunctionDeclaration; }(BodyDeclaration)); exports.FunctionDeclaration = FunctionDeclaration; var ViewPort = /** @class */ (function (_super) { __extends(ViewPort, _super); function ViewPort(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(ViewPort.prototype, "type", { get: function () { return NodeType.ViewPort; }, enumerable: false, configurable: true }); return ViewPort; }(BodyDeclaration)); exports.ViewPort = ViewPort; var FontFace = /** @class */ (function (_super) { __extends(FontFace, _super); function FontFace(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(FontFace.prototype, "type", { get: function () { return NodeType.FontFace; }, enumerable: false, configurable: true }); return FontFace; }(BodyDeclaration)); exports.FontFace = FontFace; var NestedProperties = /** @class */ (function (_super) { __extends(NestedProperties, _super); function NestedProperties(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(NestedProperties.prototype, "type", { get: function () { return NodeType.NestedProperties; }, enumerable: false, configurable: true }); return NestedProperties; }(BodyDeclaration)); exports.NestedProperties = NestedProperties; var Keyframe = /** @class */ (function (_super) { __extends(Keyframe, _super); function Keyframe(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Keyframe.prototype, "type", { get: function () { return NodeType.Keyframe; }, enumerable: false, configurable: true }); Keyframe.prototype.setKeyword = function (keyword) { return this.setNode('keyword', keyword, 0); }; Keyframe.prototype.getKeyword = function () { return this.keyword; }; Keyframe.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; Keyframe.prototype.getIdentifier = function () { return this.identifier; }; Keyframe.prototype.getName = function () { return this.identifier ? this.identifier.getText() : ''; }; return Keyframe; }(BodyDeclaration)); exports.Keyframe = Keyframe; var KeyframeSelector = /** @class */ (function (_super) { __extends(KeyframeSelector, _super); function KeyframeSelector(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(KeyframeSelector.prototype, "type", { get: function () { return NodeType.KeyframeSelector; }, enumerable: false, configurable: true }); return KeyframeSelector; }(BodyDeclaration)); exports.KeyframeSelector = KeyframeSelector; var Import = /** @class */ (function (_super) { __extends(Import, _super); function Import(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Import.prototype, "type", { get: function () { return NodeType.Import; }, enumerable: false, configurable: true }); Import.prototype.setMedialist = function (node) { if (node) { node.attachTo(this); return true; } return false; }; return Import; }(Node)); exports.Import = Import; var Use = /** @class */ (function (_super) { __extends(Use, _super); function Use() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Use.prototype, "type", { get: function () { return NodeType.Use; }, enumerable: false, configurable: true }); Use.prototype.getParameters = function () { if (!this.parameters) { this.parameters = new Nodelist(this); } return this.parameters; }; Use.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; Use.prototype.getIdentifier = function () { return this.identifier; }; return Use; }(Node)); exports.Use = Use; var ModuleConfiguration = /** @class */ (function (_super) { __extends(ModuleConfiguration, _super); function ModuleConfiguration() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(ModuleConfiguration.prototype, "type", { get: function () { return NodeType.ModuleConfiguration; }, enumerable: false, configurable: true }); ModuleConfiguration.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; ModuleConfiguration.prototype.getIdentifier = function () { return this.identifier; }; ModuleConfiguration.prototype.getName = function () { return this.identifier ? this.identifier.getText() : ''; }; ModuleConfiguration.prototype.setValue = function (node) { return this.setNode('value', node, 0); }; ModuleConfiguration.prototype.getValue = function () { return this.value; }; return ModuleConfiguration; }(Node)); exports.ModuleConfiguration = ModuleConfiguration; var Forward = /** @class */ (function (_super) { __extends(Forward, _super); function Forward() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Forward.prototype, "type", { get: function () { return NodeType.Forward; }, enumerable: false, configurable: true }); Forward.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; Forward.prototype.getIdentifier = function () { return this.identifier; }; Forward.prototype.getMembers = function () { if (!this.members) { this.members = new Nodelist(this); } return this.members; }; Forward.prototype.getParameters = function () { if (!this.parameters) { this.parameters = new Nodelist(this); } return this.parameters; }; return Forward; }(Node)); exports.Forward = Forward; var ForwardVisibility = /** @class */ (function (_super) { __extends(ForwardVisibility, _super); function ForwardVisibility() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(ForwardVisibility.prototype, "type", { get: function () { return NodeType.ForwardVisibility; }, enumerable: false, configurable: true }); ForwardVisibility.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; ForwardVisibility.prototype.getIdentifier = function () { return this.identifier; }; return ForwardVisibility; }(Node)); exports.ForwardVisibility = ForwardVisibility; var Namespace = /** @class */ (function (_super) { __extends(Namespace, _super); function Namespace(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Namespace.prototype, "type", { get: function () { return NodeType.Namespace; }, enumerable: false, configurable: true }); return Namespace; }(Node)); exports.Namespace = Namespace; var Media = /** @class */ (function (_super) { __extends(Media, _super); function Media(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Media.prototype, "type", { get: function () { return NodeType.Media; }, enumerable: false, configurable: true }); return Media; }(BodyDeclaration)); exports.Media = Media; var Supports = /** @class */ (function (_super) { __extends(Supports, _super); function Supports(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Supports.prototype, "type", { get: function () { return NodeType.Supports; }, enumerable: false, configurable: true }); return Supports; }(BodyDeclaration)); exports.Supports = Supports; var Document = /** @class */ (function (_super) { __extends(Document, _super); function Document(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Document.prototype, "type", { get: function () { return NodeType.Document; }, enumerable: false, configurable: true }); return Document; }(BodyDeclaration)); exports.Document = Document; var Medialist = /** @class */ (function (_super) { __extends(Medialist, _super); function Medialist(offset, length) { return _super.call(this, offset, length) || this; } Medialist.prototype.getMediums = function () { if (!this.mediums) { this.mediums = new Nodelist(this); } return this.mediums; }; return Medialist; }(Node)); exports.Medialist = Medialist; var MediaQuery = /** @class */ (function (_super) { __extends(MediaQuery, _super); function MediaQuery(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(MediaQuery.prototype, "type", { get: function () { return NodeType.MediaQuery; }, enumerable: false, configurable: true }); return MediaQuery; }(Node)); exports.MediaQuery = MediaQuery; var SupportsCondition = /** @class */ (function (_super) { __extends(SupportsCondition, _super); function SupportsCondition(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(SupportsCondition.prototype, "type", { get: function () { return NodeType.SupportsCondition; }, enumerable: false, configurable: true }); return SupportsCondition; }(Node)); exports.SupportsCondition = SupportsCondition; var Page = /** @class */ (function (_super) { __extends(Page, _super); function Page(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Page.prototype, "type", { get: function () { return NodeType.Page; }, enumerable: false, configurable: true }); return Page; }(BodyDeclaration)); exports.Page = Page; var PageBoxMarginBox = /** @class */ (function (_super) { __extends(PageBoxMarginBox, _super); function PageBoxMarginBox(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(PageBoxMarginBox.prototype, "type", { get: function () { return NodeType.PageBoxMarginBox; }, enumerable: false, configurable: true }); return PageBoxMarginBox; }(BodyDeclaration)); exports.PageBoxMarginBox = PageBoxMarginBox; var Expression = /** @class */ (function (_super) { __extends(Expression, _super); function Expression(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Expression.prototype, "type", { get: function () { return NodeType.Expression; }, enumerable: false, configurable: true }); return Expression; }(Node)); exports.Expression = Expression; var BinaryExpression = /** @class */ (function (_super) { __extends(BinaryExpression, _super); function BinaryExpression(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(BinaryExpression.prototype, "type", { get: function () { return NodeType.BinaryExpression; }, enumerable: false, configurable: true }); BinaryExpression.prototype.setLeft = function (left) { return this.setNode('left', left); }; BinaryExpression.prototype.getLeft = function () { return this.left; }; BinaryExpression.prototype.setRight = function (right) { return this.setNode('right', right); }; BinaryExpression.prototype.getRight = function () { return this.right; }; BinaryExpression.prototype.setOperator = function (value) { return this.setNode('operator', value); }; BinaryExpression.prototype.getOperator = function () { return this.operator; }; return BinaryExpression; }(Node)); exports.BinaryExpression = BinaryExpression; var Term = /** @class */ (function (_super) { __extends(Term, _super); function Term(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Term.prototype, "type", { get: function () { return NodeType.Term; }, enumerable: false, configurable: true }); Term.prototype.setOperator = function (value) { return this.setNode('operator', value); }; Term.prototype.getOperator = function () { return this.operator; }; Term.prototype.setExpression = function (value) { return this.setNode('expression', value); }; Term.prototype.getExpression = function () { return this.expression; }; return Term; }(Node)); exports.Term = Term; var AttributeSelector = /** @class */ (function (_super) { __extends(AttributeSelector, _super); function AttributeSelector(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(AttributeSelector.prototype, "type", { get: function () { return NodeType.AttributeSelector; }, enumerable: false, configurable: true }); AttributeSelector.prototype.setNamespacePrefix = function (value) { return this.setNode('namespacePrefix', value); }; AttributeSelector.prototype.getNamespacePrefix = function () { return this.namespacePrefix; }; AttributeSelector.prototype.setIdentifier = function (value) { return this.setNode('identifier', value); }; AttributeSelector.prototype.getIdentifier = function () { return this.identifier; }; AttributeSelector.prototype.setOperator = function (operator) { return this.setNode('operator', operator); }; AttributeSelector.prototype.getOperator = function () { return this.operator; }; AttributeSelector.prototype.setValue = function (value) { return this.setNode('value', value); }; AttributeSelector.prototype.getValue = function () { return this.value; }; return AttributeSelector; }(Node)); exports.AttributeSelector = AttributeSelector; var Operator = /** @class */ (function (_super) { __extends(Operator, _super); function Operator(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Operator.prototype, "type", { get: function () { return NodeType.Operator; }, enumerable: false, configurable: true }); return Operator; }(Node)); exports.Operator = Operator; var HexColorValue = /** @class */ (function (_super) { __extends(HexColorValue, _super); function HexColorValue(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(HexColorValue.prototype, "type", { get: function () { return NodeType.HexColorValue; }, enumerable: false, configurable: true }); return HexColorValue; }(Node)); exports.HexColorValue = HexColorValue; var _dot = '.'.charCodeAt(0), _0 = '0'.charCodeAt(0), _9 = '9'.charCodeAt(0); var NumericValue = /** @class */ (function (_super) { __extends(NumericValue, _super); function NumericValue(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(NumericValue.prototype, "type", { get: function () { return NodeType.NumericValue; }, enumerable: false, configurable: true }); NumericValue.prototype.getValue = function () { var raw = this.getText(); var unitIdx = 0; var code; for (var i = 0, len = raw.length; i < len; i++) { code = raw.charCodeAt(i); if (!(_0 <= code && code <= _9 || code === _dot)) { break; } unitIdx += 1; } return { value: raw.substring(0, unitIdx), unit: unitIdx < raw.length ? raw.substring(unitIdx) : undefined }; }; return NumericValue; }(Node)); exports.NumericValue = NumericValue; var VariableDeclaration = /** @class */ (function (_super) { __extends(VariableDeclaration, _super); function VariableDeclaration(offset, length) { var _this = _super.call(this, offset, length) || this; _this.variable = null; _this.value = null; _this.needsSemicolon = true; return _this; } Object.defineProperty(VariableDeclaration.prototype, "type", { get: function () { return NodeType.VariableDeclaration; }, enumerable: false, configurable: true }); VariableDeclaration.prototype.setVariable = function (node) { if (node) { node.attachTo(this); this.variable = node; return true; } return false; }; VariableDeclaration.prototype.getVariable = function () { return this.variable; }; VariableDeclaration.prototype.getName = function () { return this.variable ? this.variable.getName() : ''; }; VariableDeclaration.prototype.setValue = function (node) { if (node) { node.attachTo(this); this.value = node; return true; } return false; }; VariableDeclaration.prototype.getValue = function () { return this.value; }; return VariableDeclaration; }(AbstractDeclaration)); exports.VariableDeclaration = VariableDeclaration; var Interpolation = /** @class */ (function (_super) { __extends(Interpolation, _super); // private _interpolations: void; // workaround for https://github.com/Microsoft/TypeScript/issues/18276 function Interpolation(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Interpolation.prototype, "type", { get: function () { return NodeType.Interpolation; }, enumerable: false, configurable: true }); return Interpolation; }(Node)); exports.Interpolation = Interpolation; var Variable = /** @class */ (function (_super) { __extends(Variable, _super); function Variable(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(Variable.prototype, "type", { get: function () { return NodeType.VariableName; }, enumerable: false, configurable: true }); Variable.prototype.getName = function () { return this.getText(); }; return Variable; }(Node)); exports.Variable = Variable; var ExtendsReference = /** @class */ (function (_super) { __extends(ExtendsReference, _super); function ExtendsReference(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(ExtendsReference.prototype, "type", { get: function () { return NodeType.ExtendsReference; }, enumerable: false, configurable: true }); ExtendsReference.prototype.getSelectors = function () { if (!this.selectors) { this.selectors = new Nodelist(this); } return this.selectors; }; return ExtendsReference; }(Node)); exports.ExtendsReference = ExtendsReference; var MixinContentReference = /** @class */ (function (_super) { __extends(MixinContentReference, _super); function MixinContentReference(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(MixinContentReference.prototype, "type", { get: function () { return NodeType.MixinContentReference; }, enumerable: false, configurable: true }); MixinContentReference.prototype.getArguments = function () { if (!this.arguments) { this.arguments = new Nodelist(this); } return this.arguments; }; return MixinContentReference; }(Node)); exports.MixinContentReference = MixinContentReference; var MixinContentDeclaration = /** @class */ (function (_super) { __extends(MixinContentDeclaration, _super); function MixinContentDeclaration(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(MixinContentDeclaration.prototype, "type", { get: function () { return NodeType.MixinContentReference; }, enumerable: false, configurable: true }); MixinContentDeclaration.prototype.getParameters = function () { if (!this.parameters) { this.parameters = new Nodelist(this); } return this.parameters; }; return MixinContentDeclaration; }(BodyDeclaration)); exports.MixinContentDeclaration = MixinContentDeclaration; var MixinReference = /** @class */ (function (_super) { __extends(MixinReference, _super); function MixinReference(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(MixinReference.prototype, "type", { get: function () { return NodeType.MixinReference; }, enumerable: false, configurable: true }); MixinReference.prototype.getNamespaces = function () { if (!this.namespaces) { this.namespaces = new Nodelist(this); } return this.namespaces; }; MixinReference.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; MixinReference.prototype.getIdentifier = function () { return this.identifier; }; MixinReference.prototype.getName = function () { return this.identifier ? this.identifier.getText() : ''; }; MixinReference.prototype.getArguments = function () { if (!this.arguments) { this.arguments = new Nodelist(this); } return this.arguments; }; MixinReference.prototype.setContent = function (node) { return this.setNode('content', node); }; MixinReference.prototype.getContent = function () { return this.content; }; return MixinReference; }(Node)); exports.MixinReference = MixinReference; var MixinDeclaration = /** @class */ (function (_super) { __extends(MixinDeclaration, _super); function MixinDeclaration(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(MixinDeclaration.prototype, "type", { get: function () { return NodeType.MixinDeclaration; }, enumerable: false, configurable: true }); MixinDeclaration.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; MixinDeclaration.prototype.getIdentifier = function () { return this.identifier; }; MixinDeclaration.prototype.getName = function () { return this.identifier ? this.identifier.getText() : ''; }; MixinDeclaration.prototype.getParameters = function () { if (!this.parameters) { this.parameters = new Nodelist(this); } return this.parameters; }; MixinDeclaration.prototype.setGuard = function (node) { if (node) { node.attachTo(this); this.guard = node; } return false; }; return MixinDeclaration; }(BodyDeclaration)); exports.MixinDeclaration = MixinDeclaration; var UnknownAtRule = /** @class */ (function (_super) { __extends(UnknownAtRule, _super); function UnknownAtRule(offset, length) { return _super.call(this, offset, length) || this; } Object.defineProperty(UnknownAtRule.prototype, "type", { get: function () { return NodeType.UnknownAtRule; }, enumerable: false, configurable: true }); UnknownAtRule.prototype.setAtRuleName = function (atRuleName) { this.atRuleName = atRuleName; }; UnknownAtRule.prototype.getAtRuleName = function () { return this.atRuleName; }; return UnknownAtRule; }(BodyDeclaration)); exports.UnknownAtRule = UnknownAtRule; var ListEntry = /** @class */ (function (_super) { __extends(ListEntry, _super); function ListEntry() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(ListEntry.prototype, "type", { get: function () { return NodeType.ListEntry; }, enumerable: false, configurable: true }); ListEntry.prototype.setKey = function (node) { return this.setNode('key', node, 0); }; ListEntry.prototype.setValue = function (node) { return this.setNode('value', node, 1); }; return ListEntry; }(Node)); exports.ListEntry = ListEntry; var LessGuard = /** @class */ (function (_super) { __extends(LessGuard, _super); function LessGuard() { return _super !== null && _super.apply(this, arguments) || this; } LessGuard.prototype.getConditions = function () { if (!this.conditions) { this.conditions = new Nodelist(this); } return this.conditions; }; return LessGuard; }(Node)); exports.LessGuard = LessGuard; var GuardCondition = /** @class */ (function (_super) { __extends(GuardCondition, _super); function GuardCondition() { return _super !== null && _super.apply(this, arguments) || this; } GuardCondition.prototype.setVariable = function (node) { return this.setNode('variable', node); }; return GuardCondition; }(Node)); exports.GuardCondition = GuardCondition; var Module = /** @class */ (function (_super) { __extends(Module, _super); function Module() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(Module.prototype, "type", { get: function () { return NodeType.Module; }, enumerable: false, configurable: true }); Module.prototype.setIdentifier = function (node) { return this.setNode('identifier', node, 0); }; Module.prototype.getIdentifier = function () { return this.identifier; }; return Module; }(Node)); exports.Module = Module; var Level; (function (Level) { Level[Level["Ignore"] = 1] = "Ignore"; Level[Level["Warning"] = 2] = "Warning"; Level[Level["Error"] = 4] = "Error"; })(Level = exports.Level || (exports.Level = {})); var Marker = /** @class */ (function () { function Marker(node, rule, level, message, offset, length) { if (offset === void 0) { offset = node.offset; } if (length === void 0) { length = node.length; } this.node = node; this.rule = rule; this.level = level; this.message = message || rule.message; this.offset = offset; this.length = length; } Marker.prototype.getRule = function () { return this.rule; }; Marker.prototype.getLevel = function () { return this.level; }; Marker.prototype.getOffset = function () { return this.offset; }; Marker.prototype.getLength = function () { return this.length; }; Marker.prototype.getNode = function () { return this.node; }; Marker.prototype.getMessage = function () { return this.message; }; return Marker; }()); exports.Marker = Marker; /* export class DefaultVisitor implements IVisitor { public visitNode(node:Node):boolean { switch (node.type) { case NodeType.Stylesheet: return this.visitStylesheet( node); case NodeType.FontFace: return this.visitFontFace( node); case NodeType.Ruleset: return this.visitRuleSet( node); case NodeType.Selector: return this.visitSelector( node); case NodeType.SimpleSelector: return this.visitSimpleSelector( node); case NodeType.Declaration: return this.visitDeclaration( node); case NodeType.Function: return this.visitFunction( node); case NodeType.FunctionDeclaration: return this.visitFunctionDeclaration( node); case NodeType.FunctionParameter: return this.visitFunctionParameter( node); case NodeType.FunctionArgument: return this.visitFunctionArgument( node); case NodeType.Term: return this.visitTerm( node); case NodeType.Declaration: return this.visitExpression( node); case NodeType.NumericValue: return this.visitNumericValue( node); case NodeType.Page: return this.visitPage( node); case NodeType.PageBoxMarginBox: return this.visitPageBoxMarginBox( node); case NodeType.Property: return this.visitProperty( node); case NodeType.NumericValue: return this.visitNodelist( node); case NodeType.Import: return this.visitImport( node); case NodeType.Namespace: return this.visitNamespace( node); case NodeType.Keyframe: return this.visitKeyframe( node); case NodeType.KeyframeSelector: return this.visitKeyframeSelector( node); case NodeType.MixinDeclaration: return this.visitMixinDeclaration( node); case NodeType.MixinReference: return this.visitMixinReference( node); case NodeType.Variable: return this.visitVariable( node); case NodeType.VariableDeclaration: return this.visitVariableDeclaration( node); } return this.visitUnknownNode(node); } public visitFontFace(node:FontFace):boolean { return true; } public visitKeyframe(node:Keyframe):boolean { return true; } public visitKeyframeSelector(node:KeyframeSelector):boolean { return true; } public visitStylesheet(node:Stylesheet):boolean { return true; } public visitProperty(Node:Property):boolean { return true; } public visitRuleSet(node:RuleSet):boolean { return true; } public visitSelector(node:Selector):boolean { return true; } public visitSimpleSelector(node:SimpleSelector):boolean { return true; } public visitDeclaration(node:Declaration):boolean { return true; } public visitFunction(node:Function):boolean { return true; } public visitFunctionDeclaration(node:FunctionDeclaration):boolean { return true; } public visitInvocation(node:Invocation):boolean { return true; } public visitTerm(node:Term):boolean { return true; } public visitImport(node:Import):boolean { return true; } public visitNamespace(node:Namespace):boolean { return true; } public visitExpression(node:Expression):boolean { return true; } public visitNumericValue(node:NumericValue):boolean { return true; } public visitPage(node:Page):boolean { return true; } public visitPageBoxMarginBox(node:PageBoxMarginBox):boolean { return true; } public visitNodelist(node:Nodelist):boolean { return true; } public visitVariableDeclaration(node:VariableDeclaration):boolean { return true; } public visitVariable(node:Variable):boolean { return true; } public visitMixinDeclaration(node:MixinDeclaration):boolean { return true; } public visitMixinReference(node:MixinReference):boolean { return true; } public visitUnknownNode(node:Node):boolean { return true; } } */ var ParseErrorCollector = /** @class */ (function () { function ParseErrorCollector() { this.entries = []; } ParseErrorCollector.entries = function (node) { var visitor = new ParseErrorCollector(); node.acceptVisitor(visitor); return visitor.entries; }; ParseErrorCollector.prototype.visitNode = function (node) { if (node.isErroneous()) { node.collectIssues(this.entries); } return true; }; return ParseErrorCollector; }()); exports.ParseErrorCollector = ParseErrorCollector; }); /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ define('vscode-nls/vscode-nls',["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.config = exports.loadMessageBundle = void 0; function format(message, args) { var result; if (args.length === 0) { result = message; } else { result = message.replace(/\{(\d+)\}/g, function (match, rest) { var index = rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; }); } return result; } function localize(key, message) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } return format(message, args); } function loadMessageBundle(file) { return localize; } exports.loadMessageBundle = loadMessageBundle; function config(opt) { return loadMessageBundle; } exports.config = config; }); define('vscode-nls', ['vscode-nls/vscode-nls'], function (main) { return main; }); (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('vscode-css-languageservice/parser/cssErrors',["require", "exports", "vscode-nls"], 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 }); exports.ParseError = exports.CSSIssueType = void 0; var nls = require("vscode-nls"); var localize = nls.loadMessageBundle(); var CSSIssueType = /** @class */ (function () { function CSSIssueType(id, message) { this.id = id; this.message = message; } return CSSIssueType; }()); exports.CSSIssueType = CSSIssueType; exports.ParseError = { NumberExpected: new CSSIssueType('css-numberexpected', localize('expected.number', "number expected")), ConditionExpected: new CSSIssueType('css-conditionexpected', localize('expected.condt', "condition expected")), RuleOrSelectorExpected: new CSSIssueType('css-ruleorselectorexpected', localize('expected.ruleorselector', "at-rule or selector expected")), DotExpected: new CSSIssueType('css-dotexpected', localize('expected.dot', "dot expected")), ColonExpected: new CSSIssueType('css-colonexpected', localize('expected.colon', "colon expected")), SemiColonExpected: new CSSIssueType('css-semicolonexpected', localize('expected.semicolon', "semi-colon expected")), TermExpected: new CSSIssueType('css-termexpected', localize('expected.term', "term expected")), ExpressionExpected: new CSSIssueType('css-expressionexpected', localize('expected.expression', "expression expected")), OperatorExpected: new CSSIssueType('css-operatorexpected', localize('expected.operator', "operator expected")), IdentifierExpected: new CSSIssueType('css-identifierexpected', localize('expected.ident', "identifier expected")), PercentageExpected: new CSSIssueType('css-percentageexpected', localize('expected.percentage', "percentage expected")), URIOrStringExpected: new CSSIssueType('css-uriorstringexpected', localize('expected.uriorstring', "uri or string expected")), URIExpected: new CSSIssueType('css-uriexpected', localize('expected.uri', "URI expected")), VariableNameExpected: new CSSIssueType('css-varnameexpected', localize('expected.varname', "variable name expected")), VariableValueExpected: new CSSIssueType('css-varvalueexpected', localize('expected.varvalue', "variable value expected")), PropertyValueExpected: new CSSIssueType('css-propertyvalueexpected', localize('expected.propvalue', "property value expected")), LeftCurlyExpected: new CSSIssueType('css-lcurlyexpected', localize('expected.lcurly', "{ expected")), RightCurlyExpected: new CSSIssueType('css-rcurlyexpected', localize('expected.rcurly', "} expected")), LeftSquareBracketExpected: new CSSIssueType('css-rbracketexpected', localize('expected.lsquare', "[ expected")), RightSquareBracketExpected: new CSSIssueType('css-lbracketexpected', localize('expected.rsquare', "] expected")), LeftParenthesisExpected: new CSSIssueType('css-lparentexpected', localize('expected.lparen', "( expected")), RightParenthesisExpected: new CSSIssueType('css-rparentexpected', localize('expected.rparent', ") expected")), CommaExpected: new CSSIssueType('css-commaexpected', localize('expected.comma', "comma expected")), PageDirectiveOrDeclarationExpected: new CSSIssueType('css-pagedirordeclexpected', localize('expected.pagedirordecl', "page directive or declaraton expected")), UnknownAtRule: new CSSIssueType('css-unknownatrule', localize('unknown.atrule', "at-rule unknown")), UnknownKeyword: new CSSIssueType('css-unknownkeyword', localize('unknown.keyword', "unknown keyword")), SelectorExpected: new CSSIssueType('css-selectorexpected', localize('expected.selector', "selector expected")), StringLiteralExpected: new CSSIssueType('css-stringliteralexpected', localize('expected.stringliteral', "string literal expected")), WhitespaceExpected: new CSSIssueType('css-whitespaceexpected', localize('expected.whitespace', "whitespace expected")), MediaQueryExpected: new CSSIssueType('css-mediaqueryexpected', localize('expected.mediaquery', "media query expected")), IdentifierOrWildcardExpected: new CSSIssueType('css-idorwildcardexpected', localize('expected.idorwildcard', "identifier or wildcard expected")), WildcardExpected: new CSSIssueType('css-wildcardexpected', localize('expected.wildcard', "wildcard expected")), IdentifierOrVariableExpected: new CSSIssueType('css-idorvarexpected', localize('expected.idorvar', "identifier or variable expected")), }; }); (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('vscode-css-languageservice/languageFacts/entry',["require", "exports"], 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 }); exports.getBrowserLabel = exports.textToMarkedString = exports.getEntryDescription = exports.browserNames = void 0; exports.browserNames = { E: 'Edge', FF: 'Firefox', S: 'Safari', C: 'Chrome', IE: 'IE', O: 'Opera' }; function getEntryStatus(status) { switch (status) { case 'experimental': return '⚠️ Property is experimental. Be cautious when using it.️\n\n'; case 'nonstandard': return '🚨️ Property is nonstandard. Avoid using it.\n\n'; case 'obsolete': return '🚨️️️ Property is obsolete. Avoid using it.\n\n'; default: return ''; } } function getEntryDescription(entry, doesSupportMarkdown, settings) { var result; if (doesSupportMarkdown) { result = { kind: 'markdown', value: getEntryMarkdownDescription(entry, settings) }; } else { result = { kind: 'plaintext', value: getEntryStringDescription(entry, settings) }; } if (result.value === '') { return undefined; } return result; } exports.getEntryDescription = getEntryDescription; function textToMarkedString(text) { text = text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash return text.replace(//g, '>'); } exports.textToMarkedString = textToMarkedString; function getEntryStringDescription(entry, settings) { if (!entry.description || entry.description === '') { return ''; } if (typeof entry.description !== 'string') { return entry.description.value; } var result = ''; if ((settings === null || settings === void 0 ? void 0 : settings.documentation) !== false) { if (entry.status) { result += getEntryStatus(entry.status); } result += entry.description; var browserLabel = getBrowserLabel(entry.browsers); if (browserLabel) { result += '\n(' + browserLabel + ')'; } if ('syntax' in entry) { result += "\n\nSyntax: " + entry.syntax; } } if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) { if (result.length > 0) { result += '\n\n'; } result += entry.references.map(function (r) { return r.name + ": " + r.url; }).join(' | '); } return result; } function getEntryMarkdownDescription(entry, settings) { if (!entry.description || entry.description === '') { return ''; } var result = ''; if ((settings === null || settings === void 0 ? void 0 : settings.documentation) !== false) { if (entry.status) { result += getEntryStatus(entry.status); } var description = typeof entry.description === 'string' ? entry.description : entry.description.value; result += textToMarkedString(description); var browserLabel = getBrowserLabel(entry.browsers); if (browserLabel) { result += '\n\n(' + textToMarkedString(browserLabel) + ')'; } if ('syntax' in entry && entry.syntax) { result += "\n\nSyntax: " + textToMarkedString(entry.syntax); } } if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) { if (result.length > 0) { result += '\n\n'; } result += entry.references.map(function (r) { return "[" + r.name + "](" + r.url + ")"; }).join(' | '); } return result; } /** * Input is like `["E12","FF49","C47","IE","O"]` * Output is like `Edge 12, Firefox 49, Chrome 47, IE, Opera` */ function getBrowserLabel(browsers) { if (browsers === void 0) { browsers = []; } if (browsers.length === 0) { return null; } return browsers .map(function (b) { var result = ''; var matches = b.match(/([A-Z]+)(\d+)?/); var name = matches[1]; var version = matches[2]; if (name in exports.browserNames) { result += exports.browserNames[name]; } if (version) { result += ' ' + version; } return result; }) .join(', '); } exports.getBrowserLabel = getBrowserLabel; }); /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ (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('vscode-css-languageservice/languageFacts/colors',["require", "exports", "../parser/cssNodes", "vscode-nls"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getColorValue = exports.hslFromColor = exports.colorFromHSL = exports.colorFrom256RGB = exports.colorFromHex = exports.hexDigit = exports.isColorValue = exports.isColorConstructor = exports.colorKeywords = exports.colors = exports.colorFunctions = void 0; var nodes = require("../parser/cssNodes"); var nls = require("vscode-nls"); var localize = nls.loadMessageBundle(); exports.colorFunctions = [ { func: 'rgb($red, $green, $blue)', desc: localize('css.builtin.rgb', 'Creates a Color from red, green, and blue values.') }, { func: 'rgba($red, $green, $blue, $alpha)', desc: localize('css.builtin.rgba', 'Creates a Color from red, green, blue, and alpha values.') }, { func: 'hsl($hue, $saturation, $lightness)', desc: localize('css.builtin.hsl', 'Creates a Color from hue, saturation, and lightness values.') }, { func: 'hsla($hue, $saturation, $lightness, $alpha)', desc: localize('css.builtin.hsla', 'Creates a Color from hue, saturation, lightness, and alpha values.') } ]; exports.colors = { aliceblue: '#f0f8ff', antiquewhite: '#faebd7', aqua: '#00ffff', aquamarine: '#7fffd4', azure: '#f0ffff', beige: '#f5f5dc', bisque: '#ffe4c4', black: '#000000', blanchedalmond: '#ffebcd', blue: '#0000ff', blueviolet: '#8a2be2', brown: '#a52a2a', burlywood: '#deb887', cadetblue: '#5f9ea0', chartreuse: '#7fff00', chocolate: '#d2691e', coral: '#ff7f50', cornflowerblue: '#6495ed', cornsilk: '#fff8dc', crimson: '#dc143c', cyan: '#00ffff', darkblue: '#00008b', darkcyan: '#008b8b', darkgoldenrod: '#b8860b', darkgray: '#a9a9a9', darkgrey: '#a9a9a9', darkgreen: '#006400', darkkhaki: '#bdb76b', darkmagenta: '#8b008b', darkolivegreen: '#556b2f', darkorange: '#ff8c00', darkorchid: '#9932cc', darkred: '#8b0000', darksalmon: '#e9967a', darkseagreen: '#8fbc8f', darkslateblue: '#483d8b', darkslategray: '#2f4f4f', darkslategrey: '#2f4f4f', darkturquoise: '#00ced1', darkviolet: '#9400d3', deeppink: '#ff1493', deepskyblue: '#00bfff', dimgray: '#696969', dimgrey: '#696969', dodgerblue: '#1e90ff', firebrick: '#b22222', floralwhite: '#fffaf0', forestgreen: '#228b22', fuchsia: '#ff00ff', gainsboro: '#dcdcdc', ghostwhite: '#f8f8ff', gold: '#ffd700', goldenrod: '#daa520', gray: '#808080', grey: '#808080', green: '#008000', greenyellow: '#adff2f', honeydew: '#f0fff0', hotpink: '#ff69b4', indianred: '#cd5c5c', indigo: '#4b0082', ivory: '#fffff0', khaki: '#f0e68c', lavender: '#e6e6fa', lavenderblush: '#fff0f5', lawngreen: '#7cfc00', lemonchiffon: '#fffacd', lightblue: '#add8e6', lightcoral: '#f08080', lightcyan: '#e0ffff', lightgoldenrodyellow: '#fafad2', lightgray: '#d3d3d3', lightgrey: '#d3d3d3', lightgreen: '#90ee90', lightpink: '#ffb6c1', lightsalmon: '#ffa07a', lightseagreen: '#20b2aa', lightskyblue: '#87cefa', lightslategray: '#778899', lightslategrey: '#778899', lightsteelblue: '#b0c4de', lightyellow: '#ffffe0', lime: '#00ff00', limegreen: '#32cd32', linen: '#faf0e6', magenta: '#ff00ff', maroon: '#800000', mediumaquamarine: '#66cdaa', mediumblue: '#0000cd', mediumorchid: '#ba55d3', mediumpurple: '#9370d8', mediumseagreen: '#3cb371', mediumslateblue: '#7b68ee', mediumspringgreen: '#00fa9a', mediumturquoise: '#48d1cc', mediumvioletred: '#c71585', midnightblue: '#191970', mintcream: '#f5fffa', mistyrose: '#ffe4e1', moccasin: '#ffe4b5', navajowhite: '#ffdead', navy: '#000080', oldlace: '#fdf5e6', olive: '#808000', olivedrab: '#6b8e23', orange: '#ffa500', orangered: '#ff4500', orchid: '#da70d6', palegoldenrod: '#eee8aa', palegreen: '#98fb98', paleturquoise: '#afeeee', palevioletred: '#d87093', papayawhip: '#ffefd5', peachpuff: '#ffdab9', peru: '#cd853f', pink: '#ffc0cb', plum: '#dda0dd', powderblue: '#b0e0e6', purple: '#800080', red: '#ff0000', rebeccapurple: '#663399', rosybrown: '#bc8f8f', royalblue: '#4169e1', saddlebrown: '#8b4513', salmon: '#fa8072', sandybrown: '#f4a460', seagreen: '#2e8b57', seashell: '#fff5ee', sienna: '#a0522d', silver: '#c0c0c0', skyblue: '#87ceeb', slateblue: '#6a5acd', slategray: '#708090', slategrey: '#708090', snow: '#fffafa', springgreen: '#00ff7f', steelblue: '#4682b4', tan: '#d2b48c', teal: '#008080', thistle: '#d8bfd8', tomato: '#ff6347', turquoise: '#40e0d0', violet: '#ee82ee', wheat: '#f5deb3', white: '#ffffff', whitesmoke: '#f5f5f5', yellow: '#ffff00', yellowgreen: '#9acd32' }; exports.colorKeywords = { 'currentColor': 'The value of the \'color\' property. The computed value of the \'currentColor\' keyword is the computed value of the \'color\' property. If the \'currentColor\' keyword is set on the \'color\' property itself, it is treated as \'color:inherit\' at parse time.', 'transparent': 'Fully transparent. This keyword can be considered a shorthand for rgba(0,0,0,0) which is its computed value.', }; function getNumericValue(node, factor) { var val = node.getText(); var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(%?)$/); if (m) { if (m[2]) { factor = 100.0; } var result = parseFloat(m[1]) / factor; if (result >= 0 && result <= 1) { return result; } } throw new Error(); } function getAngle(node) { var val = node.getText(); var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg)?$/); if (m) { return parseFloat(val) % 360; } throw new Error(); } function isColorConstructor(node) { var name = node.getName(); if (!name) { return false; } return /^(rgb|rgba|hsl|hsla)$/gi.test(name); } exports.isColorConstructor = isColorConstructor; /** * Returns true if the node is a color value - either * defined a hex number, as rgb or rgba function, or * as color name. */ function isColorValue(node) { if (node.type === nodes.NodeType.HexColorValue) { return true; } else if (node.type === nodes.NodeType.Function) { return isColorConstructor(node); } else if (node.type === nodes.NodeType.Identifier) { if (node.parent && node.parent.type !== nodes.NodeType.Term) { return false; } var candidateColor = node.getText().toLowerCase(); if (candidateColor === 'none') { return false; } if (exports.colors[candidateColor]) { return true; } } return false; } exports.isColorValue = isColorValue; var Digit0 = 48; var Digit9 = 57; var A = 65; var F = 70; var a = 97; var f = 102; function hexDigit(charCode) { if (charCode < Digit0) { return 0; } if (charCode <= Digit9) { return charCode - Digit0; } if (charCode < a) { charCode += (a - A); } if (charCode >= a && charCode <= f) { return charCode - a + 10; } return 0; } exports.hexDigit = hexDigit; function colorFromHex(text) { if (text[0] !== '#') { return null; } switch (text.length) { case 4: return { red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0, green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0, blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0, alpha: 1 }; case 5: return { red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0, green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0, blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0, alpha: (hexDigit(text.charCodeAt(4)) * 0x11) / 255.0, }; case 7: return { red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0, green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0, blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0, alpha: 1 }; case 9: return { red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0, green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0, blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0, alpha: (hexDigit(text.charCodeAt(7)) * 0x10 + hexDigit(text.charCodeAt(8))) / 255.0 }; } return null; } exports.colorFromHex = colorFromHex; function colorFrom256RGB(red, green, blue, alpha) { if (alpha === void 0) { alpha = 1.0; } return { red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: alpha }; } exports.colorFrom256RGB = colorFrom256RGB; function colorFromHSL(hue, sat, light, alpha) { if (alpha === void 0) { alpha = 1.0; } hue = hue / 60.0; if (sat === 0) { return { red: light, green: light, blue: light, alpha: alpha }; } else { var hueToRgb = function (t1, t2, hue) { while (hue < 0) { hue += 6; } while (hue >= 6) { hue -= 6; } if (hue < 1) { return (t2 - t1) * hue + t1; } if (hue < 3) { return t2; } if (hue < 4) { return (t2 - t1) * (4 - hue) + t1; } return t1; }; var t2 = light <= 0.5 ? (light * (sat + 1)) : (light + sat - (light * sat)); var t1 = light * 2 - t2; return { red: hueToRgb(t1, t2, hue + 2), green: hueToRgb(t1, t2, hue), blue: hueToRgb(t1, t2, hue - 2), alpha: alpha }; } } exports.colorFromHSL = colorFromHSL; function hslFromColor(rgba) { var r = rgba.red; var g = rgba.green; var b = rgba.blue; var a = rgba.alpha; var max = Math.max(r, g, b); var min = Math.min(r, g, b); var h = 0; var s = 0; var l = (min + max) / 2; var chroma = max - min; if (chroma > 0) { s = Math.min((l <= 0.5 ? chroma / (2 * l) : chroma / (2 - (2 * l))), 1); switch (max) { case r: h = (g - b) / chroma + (g < b ? 6 : 0); break; case g: h = (b - r) / chroma + 2; break; case b: h = (r - g) / chroma + 4; break; } h *= 60; h = Math.round(h); } return { h: h, s: s, l: l, a: a }; } exports.hslFromColor = hslFromColor; function getColorValue(node) { if (node.type === nodes.NodeType.HexColorValue) { var text = node.getText(); return colorFromHex(text); } else if (node.type === nodes.NodeType.Function) { var functionNode = node; var name = functionNode.getName(); var colorValues = functionNode.getArguments().getChildren(); if (!name || colorValues.length < 3 || colorValues.length > 4) { return null; } try { var alpha = colorValues.length === 4 ? getNumericValue(colorValues[3], 1) : 1; if (name === 'rgb' || name === 'rgba') { return { red: getNumericValue(colorValues[0], 255.0), green: getNumericValue(colorValues[1], 255.0), blue: getNumericValue(colorValues[2], 255.0), alpha: alpha }; } else if (name === 'hsl' || name === 'hsla') { var h = getAngle(colorValues[0]); var s = getNumericValue(colorValues[1], 100.0); var l = getNumericValue(colorValues[2], 100.0); return colorFromHSL(h, s, l, alpha); } } catch (e) { // parse error on numeric value return null; } } else if (node.type === nodes.NodeType.Identifier) { if (node.parent && node.parent.type !== nodes.NodeType.Term) { return null; } var term = node.parent; if (term && term.parent && term.parent.type === nodes.NodeType.BinaryExpression) { var expression = term.parent; if (expression.parent && expression.parent.type === nodes.NodeType.ListEntry && expression.parent.key === expression) { return null; } } var candidateColor = node.getText().toLowerCase(); if (candidateColor === 'none') { return null; } var colorHex = exports.colors[candidateColor]; if (colorHex) { return colorFromHex(colorHex); } } return null; } exports.getColorValue = getColorValue; }); (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('vscode-css-languageservice/languageFacts/builtinData',["require", "exports"], 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 }); exports.pageBoxDirectives = exports.svgElements = exports.html5Tags = exports.units = exports.basicShapeFunctions = exports.transitionTimingFunctions = exports.imageFunctions = exports.cssWideKeywords = exports.geometryBoxKeywords = exports.boxKeywords = exports.lineWidthKeywords = exports.lineStyleKeywords = exports.repeatStyleKeywords = exports.positionKeywords = void 0; exports.positionKeywords = { 'bottom': 'Computes to ‘100%’ for the vertical position if one or two values are given, otherwise specifies the bottom edge as the origin for the next offset.', 'center': 'Computes to ‘50%’ (‘left 50%’) for the horizontal position if the horizontal position is not otherwise specified, or ‘50%’ (‘top 50%’) for the vertical position if it is.', 'left': 'Computes to ‘0%’ for the horizontal position if one or two values are given, otherwise specifies the left edge as the origin for the next offset.', 'right': 'Computes to ‘100%’ for the horizontal position if one or two values are given, otherwise specifies the right edge as the origin for the next offset.', 'top': 'Computes to ‘0%’ for the vertical position if one or two values are given, otherwise specifies the top edge as the origin for the next offset.' }; exports.repeatStyleKeywords = { 'no-repeat': 'Placed once and not repeated in this direction.', 'repeat': 'Repeated in this direction as often as needed to cover the background painting area.', 'repeat-x': 'Computes to ‘repeat no-repeat’.', 'repeat-y': 'Computes to ‘no-repeat repeat’.', 'round': 'Repeated as often as will fit within the background positioning area. If it doesn’t fit a whole number of times, it is rescaled so that it does.', 'space': 'Repeated as often as will fit within the background positioning area without being clipped and then the images are spaced out to fill the area.' }; exports.lineStyleKeywords = { 'dashed': 'A series of square-ended dashes.', 'dotted': 'A series of round dots.', 'double': 'Two parallel solid lines with some space between them.', 'groove': 'Looks as if it were carved in the canvas.', 'hidden': 'Same as ‘none’, but has different behavior in the border conflict resolution rules for border-collapsed tables.', 'inset': 'Looks as if the content on the inside of the border is sunken into the canvas.', 'none': 'No border. Color and width are ignored.', 'outset': 'Looks as if the content on the inside of the border is coming out of the canvas.', 'ridge': 'Looks as if it were coming out of the canvas.', 'solid': 'A single line segment.' }; exports.lineWidthKeywords = ['medium', 'thick', 'thin']; exports.boxKeywords = { 'border-box': 'The background is painted within (clipped to) the border box.', 'content-box': 'The background is painted within (clipped to) the content box.', 'padding-box': 'The background is painted within (clipped to) the padding box.' }; exports.geometryBoxKeywords = { 'margin-box': 'Uses the margin box as reference box.', 'fill-box': 'Uses the object bounding box as reference box.', 'stroke-box': 'Uses the stroke bounding box as reference box.', 'view-box': 'Uses the nearest SVG viewport as reference box.' }; exports.cssWideKeywords = { 'initial': 'Represents the value specified as the property’s initial value.', 'inherit': 'Represents the computed value of the property on the element’s parent.', 'unset': 'Acts as either `inherit` or `initial`, depending on whether the property is inherited or not.' }; exports.imageFunctions = { 'url()': 'Reference an image file by URL', 'image()': 'Provide image fallbacks and annotations.', '-webkit-image-set()': 'Provide multiple resolutions. Remember to use unprefixed image-set() in addition.', 'image-set()': 'Provide multiple resolutions of an image and const the UA decide which is most appropriate in a given situation.', '-moz-element()': 'Use an element in the document as an image. Remember to use unprefixed element() in addition.', 'element()': 'Use an element in the document as an image.', 'cross-fade()': 'Indicates the two images to be combined and how far along in the transition the combination is.', '-webkit-gradient()': 'Deprecated. Use modern linear-gradient() or radial-gradient() instead.', '-webkit-linear-gradient()': 'Linear gradient. Remember to use unprefixed version in addition.', '-moz-linear-gradient()': 'Linear gradient. Remember to use unprefixed version in addition.', '-o-linear-gradient()': 'Linear gradient. Remember to use unprefixed version in addition.', 'linear-gradient()': 'A linear gradient is created by specifying a straight gradient line, and then several colors placed along that line.', '-webkit-repeating-linear-gradient()': 'Repeating Linear gradient. Remember to use unprefixed version in addition.', '-moz-repeating-linear-gradient()': 'Repeating Linear gradient. Remember to use unprefixed version in addition.', '-o-repeating-linear-gradient()': 'Repeating Linear gradient. Remember to use unprefixed version in addition.', 'repeating-linear-gradient()': 'Same as linear-gradient, except the color-stops are repeated infinitely in both directions, with their positions shifted by multiples of the difference between the last specified color-stop’s position and the first specified color-stop’s position.', '-webkit-radial-gradient()': 'Radial gradient. Remember to use unprefixed version in addition.', '-moz-radial-gradient()': 'Radial gradient. Remember to use unprefixed version in addition.', 'radial-gradient()': 'Colors emerge from a single point and smoothly spread outward in a circular or elliptical shape.', '-webkit-repeating-radial-gradient()': 'Repeating radial gradient. Remember to use unprefixed version in addition.', '-moz-repeating-radial-gradient()': 'Repeating radial gradient. Remember to use unprefixed version in addition.', 'repeating-radial-gradient()': 'Same as radial-gradient, except the color-stops are repeated infinitely in both directions, with their positions shifted by multiples of the difference between the last specified color-stop’s position and the first specified color-stop’s position.' }; exports.transitionTimingFunctions = { 'ease': 'Equivalent to cubic-bezier(0.25, 0.1, 0.25, 1.0).', 'ease-in': 'Equivalent to cubic-bezier(0.42, 0, 1.0, 1.0).', 'ease-in-out': 'Equivalent to cubic-bezier(0.42, 0, 0.58, 1.0).', 'ease-out': 'Equivalent to cubic-bezier(0, 0, 0.58, 1.0).', 'linear': 'Equivalent to cubic-bezier(0.0, 0.0, 1.0, 1.0).', 'step-end': 'Equivalent to steps(1, end).', 'step-start': 'Equivalent to steps(1, start).', 'steps()': 'The first parameter specifies the number of intervals in the function. The second parameter, which is optional, is either the value “start” or “end”.', 'cubic-bezier()': 'Specifies a cubic-bezier curve. The four values specify points P1 and P2 of the curve as (x1, y1, x2, y2).', 'cubic-bezier(0.6, -0.28, 0.735, 0.045)': 'Ease-in Back. Overshoots.', 'cubic-bezier(0.68, -0.55, 0.265, 1.55)': 'Ease-in-out Back. Overshoots.', 'cubic-bezier(0.175, 0.885, 0.32, 1.275)': 'Ease-out Back. Overshoots.', 'cubic-bezier(0.6, 0.04, 0.98, 0.335)': 'Ease-in Circular. Based on half circle.', 'cubic-bezier(0.785, 0.135, 0.15, 0.86)': 'Ease-in-out Circular. Based on half circle.', 'cubic-bezier(0.075, 0.82, 0.165, 1)': 'Ease-out Circular. Based on half circle.', 'cubic-bezier(0.55, 0.055, 0.675, 0.19)': 'Ease-in Cubic. Based on power of three.', 'cubic-bezier(0.645, 0.045, 0.355, 1)': 'Ease-in-out Cubic. Based on power of three.', 'cubic-bezier(0.215, 0.610, 0.355, 1)': 'Ease-out Cubic. Based on power of three.', 'cubic-bezier(0.95, 0.05, 0.795, 0.035)': 'Ease-in Exponential. Based on two to the power ten.', 'cubic-bezier(1, 0, 0, 1)': 'Ease-in-out Exponential. Based on two to the power ten.', 'cubic-bezier(0.19, 1, 0.22, 1)': 'Ease-out Exponential. Based on two to the power ten.', 'cubic-bezier(0.47, 0, 0.745, 0.715)': 'Ease-in Sine.', 'cubic-bezier(0.445, 0.05, 0.55, 0.95)': 'Ease-in-out Sine.', 'cubic-bezier(0.39, 0.575, 0.565, 1)': 'Ease-out Sine.', 'cubic-bezier(0.55, 0.085, 0.68, 0.53)': 'Ease-in Quadratic. Based on power of two.', 'cubic-bezier(0.455, 0.03, 0.515, 0.955)': 'Ease-in-out Quadratic. Based on power of two.', 'cubic-bezier(0.25, 0.46, 0.45, 0.94)': 'Ease-out Quadratic. Based on power of two.', 'cubic-bezier(0.895, 0.03, 0.685, 0.22)': 'Ease-in Quartic. Based on power of four.', 'cubic-bezier(0.77, 0, 0.175, 1)': 'Ease-in-out Quartic. Based on power of four.', 'cubic-bezier(0.165, 0.84, 0.44, 1)': 'Ease-out Quartic. Based on power of four.', 'cubic-bezier(0.755, 0.05, 0.855, 0.06)': 'Ease-in Quintic. Based on power of five.', 'cubic-bezier(0.86, 0, 0.07, 1)': 'Ease-in-out Quintic. Based on power of five.', 'cubic-bezier(0.23, 1, 0.320, 1)': 'Ease-out Quintic. Based on power of five.' }; exports.basicShapeFunctions = { 'circle()': 'Defines a circle.', 'ellipse()': 'Defines an ellipse.', 'inset()': 'Defines an inset rectangle.', 'polygon()': 'Defines a polygon.' }; exports.units = { 'length': ['em', 'rem', 'ex', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ch', 'vw', 'vh', 'vmin', 'vmax'], 'angle': ['deg', 'rad', 'grad', 'turn'], 'time': ['ms', 's'], 'frequency': ['Hz', 'kHz'], 'resolution': ['dpi', 'dpcm', 'dppx'], 'percentage': ['%', 'fr'] }; exports.html5Tags = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'const', 'video', 'wbr']; exports.svgElements = ['circle', 'clipPath', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'foreignObject', 'g', 'hatch', 'hatchpath', 'image', 'line', 'linearGradient', 'marker', 'mask', 'mesh', 'meshpatch', 'meshrow', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'set', 'solidcolor', 'stop', 'svg', 'switch', 'symbol', 'text', 'textPath', 'tspan', 'use', 'view']; exports.pageBoxDirectives = [ '@bottom-center', '@bottom-left', '@bottom-left-corner', '@bottom-right', '@bottom-right-corner', '@left-bottom', '@left-middle', '@left-top', '@right-bottom', '@right-middle', '@right-top', '@top-center', '@top-left', '@top-left-corner', '@top-right', '@top-right-corner' ]; }); var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; (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('vscode-css-languageservice/languageFacts/facts',["require", "exports", "./entry", "./colors", "./builtinData"], 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 }); __exportStar(require("./entry"), exports); __exportStar(require("./colors"), exports); __exportStar(require("./builtinData"), exports); }); (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('vscode-css-languageservice/utils/objects',["require", "exports"], 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 }); exports.isDefined = exports.values = void 0; function values(obj) { return Object.keys(obj).map(function (key) { return obj[key]; }); } exports.values = values; function isDefined(obj) { return typeof obj !== 'undefined'; } exports.isDefined = isDefined; }); (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('vscode-css-languageservice/parser/cssParser',["require", "exports", "./cssScanner", "./cssNodes", "./cssErrors", "../languageFacts/facts", "../utils/objects"], 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 }); exports.Parser = void 0; var cssScanner_1 = require("./cssScanner"); var nodes = require("./cssNodes"); var cssErrors_1 = require("./cssErrors"); var languageFacts = require("../languageFacts/facts"); var objects_1 = require("../utils/objects"); /// /// A parser for the css core specification. See for reference: /// https://www.w3.org/TR/CSS21/grammar.html /// http://www.w3.org/TR/CSS21/syndata.html#tokenization /// var Parser = /** @class */ (function () { function Parser(scnr) { if (scnr === void 0) { scnr = new cssScanner_1.Scanner(); } this.keyframeRegex = /^@(\-(webkit|ms|moz|o)\-)?keyframes$/i; this.scanner = scnr; this.token = { type: cssScanner_1.TokenType.EOF, offset: -1, len: 0, text: '' }; this.prevToken = undefined; } Parser.prototype.peekIdent = function (text) { return cssScanner_1.TokenType.Ident === this.token.type && text.length === this.token.text.length && text === this.token.text.toLowerCase(); }; Parser.prototype.peekKeyword = function (text) { return cssScanner_1.TokenType.AtKeyword === this.token.type && text.length === this.token.text.length && text === this.token.text.toLowerCase(); }; Parser.prototype.peekDelim = function (text) { return cssScanner_1.TokenType.Delim === this.token.type && text === this.token.text; }; Parser.prototype.peek = function (type) { return type === this.token.type; }; Parser.prototype.peekOne = function (types) { return types.indexOf(this.token.type) !== -1; }; Parser.prototype.peekRegExp = function (type, regEx) { if (type !== this.token.type) { return false; } return regEx.test(this.token.text); }; Parser.prototype.hasWhitespace = function () { return !!this.prevToken && (this.prevToken.offset + this.prevToken.len !== this.token.offset); }; Parser.prototype.consumeToken = function () { this.prevToken = this.token; this.token = this.scanner.scan(); }; Parser.prototype.mark = function () { return { prev: this.prevToken, curr: this.token, pos: this.scanner.pos() }; }; Parser.prototype.restoreAtMark = function (mark) { this.prevToken = mark.prev; this.token = mark.curr; this.scanner.goBackTo(mark.pos); }; Parser.prototype.try = function (func) { var pos = this.mark(); var node = func(); if (!node) { this.restoreAtMark(pos); return null; } return node; }; Parser.prototype.acceptOneKeyword = function (keywords) { if (cssScanner_1.TokenType.AtKeyword === this.token.type) { for (var _i = 0, keywords_1 = keywords; _i < keywords_1.length; _i++) { var keyword = keywords_1[_i]; if (keyword.length === this.token.text.length && keyword === this.token.text.toLowerCase()) { this.consumeToken(); return true; } } } return false; }; Parser.prototype.accept = function (type) { if (type === this.token.type) { this.consumeToken(); return true; } return false; }; Parser.prototype.acceptIdent = function (text) { if (this.peekIdent(text)) { this.consumeToken(); return true; } return false; }; Parser.prototype.acceptKeyword = function (text) { if (this.peekKeyword(text)) { this.consumeToken(); return true; } return false; }; Parser.prototype.acceptDelim = function (text) { if (this.peekDelim(text)) { this.consumeToken(); return true; } return false; }; Parser.prototype.acceptRegexp = function (regEx) { if (regEx.test(this.token.text)) { this.consumeToken(); return true; } return false; }; Parser.prototype._parseRegexp = function (regEx) { var node = this.createNode(nodes.NodeType.Identifier); do { } while (this.acceptRegexp(regEx)); return this.finish(node); }; Parser.prototype.acceptUnquotedString = function () { var pos = this.scanner.pos(); this.scanner.goBackTo(this.token.offset); var unquoted = this.scanner.scanUnquotedString(); if (unquoted) { this.token = unquoted; this.consumeToken(); return true; } this.scanner.goBackTo(pos); return false; }; Parser.prototype.resync = function (resyncTokens, resyncStopTokens) { while (true) { if (resyncTokens && resyncTokens.indexOf(this.token.type) !== -1) { this.consumeToken(); return true; } else if (resyncStopTokens && resyncStopTokens.indexOf(this.token.type) !== -1) { return true; } else { if (this.token.type === cssScanner_1.TokenType.EOF) { return false; } this.token = this.scanner.scan(); } } }; Parser.prototype.createNode = function (nodeType) { return new nodes.Node(this.token.offset, this.token.len, nodeType); }; Parser.prototype.create = function (ctor) { return new ctor(this.token.offset, this.token.len); }; Parser.prototype.finish = function (node, error, resyncTokens, resyncStopTokens) { // parseNumeric misuses error for boolean flagging (however the real error mustn't be a false) // + nodelist offsets mustn't be modified, because there is a offset hack in rulesets for smartselection if (!(node instanceof nodes.Nodelist)) { if (error) { this.markError(node, error, resyncTokens, resyncStopTokens); } // set the node end position if (this.prevToken) { // length with more elements belonging together var prevEnd = this.prevToken.offset + this.prevToken.len; node.length = prevEnd > node.offset ? prevEnd - node.offset : 0; // offset is taken from current token, end from previous: Use 0 for empty nodes } } return node; }; Parser.prototype.markError = function (node, error, resyncTokens, resyncStopTokens) { if (this.token !== this.lastErrorToken) { // do not report twice on the same token node.addIssue(new nodes.Marker(node, error, nodes.Level.Error, undefined, this.token.offset, this.token.len)); this.lastErrorToken = this.token; } if (resyncTokens || resyncStopTokens) { this.resync(resyncTokens, resyncStopTokens); } }; Parser.prototype.parseStylesheet = function (textDocument) { var versionId = textDocument.version; var text = textDocument.getText(); var textProvider = function (offset, length) { if (textDocument.version !== versionId) { throw new Error('Underlying model has changed, AST is no longer valid'); } return text.substr(offset, length); }; return this.internalParse(text, this._parseStylesheet, textProvider); }; Parser.prototype.internalParse = function (input, parseFunc, textProvider) { this.scanner.setSource(input); this.token = this.scanner.scan(); var node = parseFunc.bind(this)(); if (node) { if (textProvider) { node.textProvider = textProvider; } else { node.textProvider = function (offset, length) { return input.substr(offset, length); }; } } return node; }; Parser.prototype._parseStylesheet = function () { var node = this.create(nodes.Stylesheet); while (node.addChild(this._parseStylesheetStart())) { // Parse statements only valid at the beginning of stylesheets. } var inRecovery = false; do { var hasMatch = false; do { hasMatch = false; var statement = this._parseStylesheetStatement(); if (statement) { node.addChild(statement); hasMatch = true; inRecovery = false; if (!this.peek(cssScanner_1.TokenType.EOF) && this._needsSemicolonAfter(statement) && !this.accept(cssScanner_1.TokenType.SemiColon)) { this.markError(node, cssErrors_1.ParseError.SemiColonExpected); } } while (this.accept(cssScanner_1.TokenType.SemiColon) || this.accept(cssScanner_1.TokenType.CDO) || this.accept(cssScanner_1.TokenType.CDC)) { // accept empty statements hasMatch = true; inRecovery = false; } } while (hasMatch); if (this.peek(cssScanner_1.TokenType.EOF)) { break; } if (!inRecovery) { if (this.peek(cssScanner_1.TokenType.AtKeyword)) { this.markError(node, cssErrors_1.ParseError.UnknownAtRule); } else { this.markError(node, cssErrors_1.ParseError.RuleOrSelectorExpected); } inRecovery = true; } this.consumeToken(); } while (!this.peek(cssScanner_1.TokenType.EOF)); return this.finish(node); }; Parser.prototype._parseStylesheetStart = function () { return this._parseCharset(); }; Parser.prototype._parseStylesheetStatement = function (isNested) { if (isNested === void 0) { isNested = false; } if (this.peek(cssScanner_1.TokenType.AtKeyword)) { return this._parseStylesheetAtStatement(isNested); } return this._parseRuleset(isNested); }; Parser.prototype._parseStylesheetAtStatement = function (isNested) { if (isNested === void 0) { isNested = false; } return this._parseImport() || this._parseMedia(isNested) || this._parsePage() || this._parseFontFace() || this._parseKeyframe() || this._parseSupports(isNested) || this._parseViewPort() || this._parseNamespace() || this._parseDocument() || this._parseUnknownAtRule(); }; Parser.prototype._tryParseRuleset = function (isNested) { var mark = this.mark(); if (this._parseSelector(isNested)) { while (this.accept(cssScanner_1.TokenType.Comma) && this._parseSelector(isNested)) { // loop } if (this.accept(cssScanner_1.TokenType.CurlyL)) { this.restoreAtMark(mark); return this._parseRuleset(isNested); } } this.restoreAtMark(mark); return null; }; Parser.prototype._parseRuleset = function (isNested) { if (isNested === void 0) { isNested = false; } var node = this.create(nodes.RuleSet); var selectors = node.getSelectors(); if (!selectors.addChild(this._parseSelector(isNested))) { return null; } while (this.accept(cssScanner_1.TokenType.Comma)) { if (!selectors.addChild(this._parseSelector(isNested))) { return this.finish(node, cssErrors_1.ParseError.SelectorExpected); } } return this._parseBody(node, this._parseRuleSetDeclaration.bind(this)); }; Parser.prototype._parseRuleSetDeclarationAtStatement = function () { return this._parseUnknownAtRule(); }; Parser.prototype._parseRuleSetDeclaration = function () { // https://www.w3.org/TR/css-syntax-3/#consume-a-list-of-declarations0 if (this.peek(cssScanner_1.TokenType.AtKeyword)) { return this._parseRuleSetDeclarationAtStatement(); } return this._parseDeclaration(); }; Parser.prototype._needsSemicolonAfter = function (node) { switch (node.type) { case nodes.NodeType.Keyframe: case nodes.NodeType.ViewPort: case nodes.NodeType.Media: case nodes.NodeType.Ruleset: case nodes.NodeType.Namespace: case nodes.NodeType.If: case nodes.NodeType.For: case nodes.NodeType.Each: case nodes.NodeType.While: case nodes.NodeType.MixinDeclaration: case nodes.NodeType.FunctionDeclaration: case nodes.NodeType.MixinContentDeclaration: return false; case nodes.NodeType.ExtendsReference: case nodes.NodeType.MixinContentReference: case nodes.NodeType.ReturnStatement: case nodes.NodeType.MediaQuery: case nodes.NodeType.Debug: case nodes.NodeType.Import: case nodes.NodeType.AtApplyRule: case nodes.NodeType.CustomPropertyDeclaration: return true; case nodes.NodeType.VariableDeclaration: return node.needsSemicolon; case nodes.NodeType.MixinReference: return !node.getContent(); case nodes.NodeType.Declaration: return !node.getNestedProperties(); } return false; }; Parser.prototype._parseDeclarations = function (parseDeclaration) { var node = this.create(nodes.Declarations); if (!this.accept(cssScanner_1.TokenType.CurlyL)) { return null; } var decl = parseDeclaration(); while (node.addChild(decl)) { if (this.peek(cssScanner_1.TokenType.CurlyR)) { break; } if (this._needsSemicolonAfter(decl) && !this.accept(cssScanner_1.TokenType.SemiColon)) { return this.finish(node, cssErrors_1.ParseError.SemiColonExpected, [cssScanner_1.TokenType.SemiColon, cssScanner_1.TokenType.CurlyR]); } // We accepted semicolon token. Link it to declaration. if (decl && this.prevToken && this.prevToken.type === cssScanner_1.TokenType.SemiColon) { decl.semicolonPosition = this.prevToken.offset; } while (this.accept(cssScanner_1.TokenType.SemiColon)) { // accept empty statements } decl = parseDeclaration(); } if (!this.accept(cssScanner_1.TokenType.CurlyR)) { return this.finish(node, cssErrors_1.ParseError.RightCurlyExpected, [cssScanner_1.TokenType.CurlyR, cssScanner_1.TokenType.SemiColon]); } return this.finish(node); }; Parser.prototype._parseBody = function (node, parseDeclaration) { if (!node.setDeclarations(this._parseDeclarations(parseDeclaration))) { return this.finish(node, cssErrors_1.ParseError.LeftCurlyExpected, [cssScanner_1.TokenType.CurlyR, cssScanner_1.TokenType.SemiColon]); } return this.finish(node); }; Parser.prototype._parseSelector = function (isNested) { var node = this.create(nodes.Selector); var hasContent = false; if (isNested) { // nested selectors can start with a combinator hasContent = node.addChild(this._parseCombinator()); } while (node.addChild(this._parseSimpleSelector())) { hasContent = true; node.addChild(this._parseCombinator()); // optional } return hasContent ? this.finish(node) : null; }; Parser.prototype._parseDeclaration = function (stopTokens) { var custonProperty = this._tryParseCustomPropertyDeclaration(stopTokens); if (custonProperty) { return custonProperty; } var node = this.create(nodes.Declaration); if (!node.setProperty(this._parseProperty())) { return null; } if (!this.accept(cssScanner_1.TokenType.Colon)) { return this.finish(node, cssErrors_1.ParseError.ColonExpected, [cssScanner_1.TokenType.Colon], stopTokens || [cssScanner_1.TokenType.SemiColon]); } if (this.prevToken) { node.colonPosition = this.prevToken.offset; } if (!node.setValue(this._parseExpr())) { return this.finish(node, cssErrors_1.ParseError.PropertyValueExpected); } node.addChild(this._parsePrio()); if (this.peek(cssScanner_1.TokenType.SemiColon)) { node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist } return this.finish(node); }; Parser.prototype._tryParseCustomPropertyDeclaration = function (stopTokens) { if (!this.peekRegExp(cssScanner_1.TokenType.Ident, /^--/)) { return null; } var node = this.create(nodes.CustomPropertyDeclaration); if (!node.setProperty(this._parseProperty())) { return null; } if (!this.accept(cssScanner_1.TokenType.Colon)) { return this.finish(node, cssErrors_1.ParseError.ColonExpected, [cssScanner_1.TokenType.Colon]); } if (this.prevToken) { node.colonPosition = this.prevToken.offset; } var mark = this.mark(); if (this.peek(cssScanner_1.TokenType.CurlyL)) { // try to parse it as nested declaration var propertySet = this.create(nodes.CustomPropertySet); var declarations = this._parseDeclarations(this._parseRuleSetDeclaration.bind(this)); if (propertySet.setDeclarations(declarations) && !declarations.isErroneous(true)) { propertySet.addChild(this._parsePrio()); if (this.peek(cssScanner_1.TokenType.SemiColon)) { this.finish(propertySet); node.setPropertySet(propertySet); node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist return this.finish(node); } } this.restoreAtMark(mark); } // try tp parse as expression var expression = this._parseExpr(); if (expression && !expression.isErroneous(true)) { this._parsePrio(); if (this.peekOne(stopTokens || [cssScanner_1.TokenType.SemiColon])) { node.setValue(expression); node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist return this.finish(node); } } this.restoreAtMark(mark); node.addChild(this._parseCustomPropertyValue(stopTokens)); node.addChild(this._parsePrio()); if ((0, objects_1.isDefined)(node.colonPosition) && this.token.offset === node.colonPosition + 1) { return this.finish(node, cssErrors_1.ParseError.PropertyValueExpected); } return this.finish(node); }; /** * Parse custom property values. * * Based on https://www.w3.org/TR/css-variables/#syntax * * This code is somewhat unusual, as the allowed syntax is incredibly broad, * parsing almost any sequence of tokens, save for a small set of exceptions. * Unbalanced delimitors, invalid tokens, and declaration * terminators like semicolons and !important directives (when not inside * of delimitors). */ Parser.prototype._parseCustomPropertyValue = function (stopTokens) { var _this = this; if (stopTokens === void 0) { stopTokens = [cssScanner_1.TokenType.CurlyR]; } var node = this.create(nodes.Node); var isTopLevel = function () { return curlyDepth === 0 && parensDepth === 0 && bracketsDepth === 0; }; var onStopToken = function () { return stopTokens.indexOf(_this.token.type) !== -1; }; var curlyDepth = 0; var parensDepth = 0; var bracketsDepth = 0; done: while (true) { switch (this.token.type) { case cssScanner_1.TokenType.SemiColon: // A semicolon only ends things if we're not inside a delimitor. if (isTopLevel()) { break done; } break; case cssScanner_1.TokenType.Exclamation: // An exclamation ends the value if we're not inside delims. if (isTopLevel()) { break done; } break; case cssScanner_1.TokenType.CurlyL: curlyDepth++; break; case cssScanner_1.TokenType.CurlyR: curlyDepth--; if (curlyDepth < 0) { // The property value has been terminated without a semicolon, and // this is the last declaration in the ruleset. if (onStopToken() && parensDepth === 0 && bracketsDepth === 0) { break done; } return this.finish(node, cssErrors_1.ParseError.LeftCurlyExpected); } break; case cssScanner_1.TokenType.ParenthesisL: parensDepth++; break; case cssScanner_1.TokenType.ParenthesisR: parensDepth--; if (parensDepth < 0) { if (onStopToken() && bracketsDepth === 0 && curlyDepth === 0) { break done; } return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected); } break; case cssScanner_1.TokenType.BracketL: bracketsDepth++; break; case cssScanner_1.TokenType.BracketR: bracketsDepth--; if (bracketsDepth < 0) { return this.finish(node, cssErrors_1.ParseError.LeftSquareBracketExpected); } break; case cssScanner_1.TokenType.BadString: // fall through break done; case cssScanner_1.TokenType.EOF: // We shouldn't have reached the end of input, something is // unterminated. var error = cssErrors_1.ParseError.RightCurlyExpected; if (bracketsDepth > 0) { error = cssErrors_1.ParseError.RightSquareBracketExpected; } else if (parensDepth > 0) { error = cssErrors_1.ParseError.RightParenthesisExpected; } return this.finish(node, error); } this.consumeToken(); } return this.finish(node); }; Parser.prototype._tryToParseDeclaration = function (stopTokens) { var mark = this.mark(); if (this._parseProperty() && this.accept(cssScanner_1.TokenType.Colon)) { // looks like a declaration, go ahead this.restoreAtMark(mark); return this._parseDeclaration(stopTokens); } this.restoreAtMark(mark); return null; }; Parser.prototype._parseProperty = function () { var node = this.create(nodes.Property); var mark = this.mark(); if (this.acceptDelim('*') || this.acceptDelim('_')) { // support for IE 5.x, 6 and 7 star hack: see http://en.wikipedia.org/wiki/CSS_filter#Star_hack if (this.hasWhitespace()) { this.restoreAtMark(mark); return null; } } if (node.setIdentifier(this._parsePropertyIdentifier())) { return this.finish(node); } return null; }; Parser.prototype._parsePropertyIdentifier = function () { return this._parseIdent(); }; Parser.prototype._parseCharset = function () { if (!this.peek(cssScanner_1.TokenType.Charset)) { return null; } var node = this.create(nodes.Node); this.consumeToken(); // charset if (!this.accept(cssScanner_1.TokenType.String)) { return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); } if (!this.accept(cssScanner_1.TokenType.SemiColon)) { return this.finish(node, cssErrors_1.ParseError.SemiColonExpected); } return this.finish(node); }; Parser.prototype._parseImport = function () { if (!this.peekKeyword('@import')) { return null; } var node = this.create(nodes.Import); this.consumeToken(); // @import if (!node.addChild(this._parseURILiteral()) && !node.addChild(this._parseStringLiteral())) { return this.finish(node, cssErrors_1.ParseError.URIOrStringExpected); } if (!this.peek(cssScanner_1.TokenType.SemiColon) && !this.peek(cssScanner_1.TokenType.EOF)) { node.setMedialist(this._parseMediaQueryList()); } return this.finish(node); }; Parser.prototype._parseNamespace = function () { // http://www.w3.org/TR/css3-namespace/ // namespace : NAMESPACE_SYM S* [IDENT S*]? [STRING|URI] S* ';' S* if (!this.peekKeyword('@namespace')) { return null; } var node = this.create(nodes.Namespace); this.consumeToken(); // @namespace if (!node.addChild(this._parseURILiteral())) { // url literal also starts with ident node.addChild(this._parseIdent()); // optional prefix if (!node.addChild(this._parseURILiteral()) && !node.addChild(this._parseStringLiteral())) { return this.finish(node, cssErrors_1.ParseError.URIExpected, [cssScanner_1.TokenType.SemiColon]); } } if (!this.accept(cssScanner_1.TokenType.SemiColon)) { return this.finish(node, cssErrors_1.ParseError.SemiColonExpected); } return this.finish(node); }; Parser.prototype._parseFontFace = function () { if (!this.peekKeyword('@font-face')) { return null; } var node = this.create(nodes.FontFace); this.consumeToken(); // @font-face return this._parseBody(node, this._parseRuleSetDeclaration.bind(this)); }; Parser.prototype._parseViewPort = function () { if (!this.peekKeyword('@-ms-viewport') && !this.peekKeyword('@-o-viewport') && !this.peekKeyword('@viewport')) { return null; } var node = this.create(nodes.ViewPort); this.consumeToken(); // @-ms-viewport return this._parseBody(node, this._parseRuleSetDeclaration.bind(this)); }; Parser.prototype._parseKeyframe = function () { if (!this.peekRegExp(cssScanner_1.TokenType.AtKeyword, this.keyframeRegex)) { return null; } var node = this.create(nodes.Keyframe); var atNode = this.create(nodes.Node); this.consumeToken(); // atkeyword node.setKeyword(this.finish(atNode)); if (atNode.matches('@-ms-keyframes')) { // -ms-keyframes never existed this.markError(atNode, cssErrors_1.ParseError.UnknownKeyword); } if (!node.setIdentifier(this._parseKeyframeIdent())) { return this.finish(node, cssErrors_1.ParseError.IdentifierExpected, [cssScanner_1.TokenType.CurlyR]); } return this._parseBody(node, this._parseKeyframeSelector.bind(this)); }; Parser.prototype._parseKeyframeIdent = function () { return this._parseIdent([nodes.ReferenceType.Keyframe]); }; Parser.prototype._parseKeyframeSelector = function () { var node = this.create(nodes.KeyframeSelector); if (!node.addChild(this._parseIdent()) && !this.accept(cssScanner_1.TokenType.Percentage)) { return null; } while (this.accept(cssScanner_1.TokenType.Comma)) { if (!node.addChild(this._parseIdent()) && !this.accept(cssScanner_1.TokenType.Percentage)) { return this.finish(node, cssErrors_1.ParseError.PercentageExpected); } } return this._parseBody(node, this._parseRuleSetDeclaration.bind(this)); }; Parser.prototype._tryParseKeyframeSelector = function () { var node = this.create(nodes.KeyframeSelector); var pos = this.mark(); if (!node.addChild(this._parseIdent()) && !this.accept(cssScanner_1.TokenType.Percentage)) { return null; } while (this.accept(cssScanner_1.TokenType.Comma)) { if (!node.addChild(this._parseIdent()) && !this.accept(cssScanner_1.TokenType.Percentage)) { this.restoreAtMark(pos); return null; } } if (!this.peek(cssScanner_1.TokenType.CurlyL)) { this.restoreAtMark(pos); return null; } return this._parseBody(node, this._parseRuleSetDeclaration.bind(this)); }; Parser.prototype._parseSupports = function (isNested) { if (isNested === void 0) { isNested = false; } // SUPPORTS_SYM S* supports_condition '{' S* ruleset* '}' S* if (!this.peekKeyword('@supports')) { return null; } var node = this.create(nodes.Supports); this.consumeToken(); // @supports node.addChild(this._parseSupportsCondition()); return this._parseBody(node, this._parseSupportsDeclaration.bind(this, isNested)); }; Parser.prototype._parseSupportsDeclaration = function (isNested) { if (isNested === void 0) { isNested = false; } if (isNested) { // if nested, the body can contain rulesets, but also declarations return this._tryParseRuleset(true) || this._tryToParseDeclaration() || this._parseStylesheetStatement(true); } return this._parseStylesheetStatement(false); }; Parser.prototype._parseSupportsCondition = function () { // supports_condition : supports_negation | supports_conjunction | supports_disjunction | supports_condition_in_parens ; // supports_condition_in_parens: ( '(' S* supports_condition S* ')' ) | supports_declaration_condition | general_enclosed ; // supports_negation: NOT S+ supports_condition_in_parens ; // supports_conjunction: supports_condition_in_parens ( S+ AND S+ supports_condition_in_parens )+; // supports_disjunction: supports_condition_in_parens ( S+ OR S+ supports_condition_in_parens )+; // supports_declaration_condition: '(' S* declaration ')'; // general_enclosed: ( FUNCTION | '(' ) ( any | unused )* ')' ; var node = this.create(nodes.SupportsCondition); if (this.acceptIdent('not')) { node.addChild(this._parseSupportsConditionInParens()); } else { node.addChild(this._parseSupportsConditionInParens()); if (this.peekRegExp(cssScanner_1.TokenType.Ident, /^(and|or)$/i)) { var text = this.token.text.toLowerCase(); while (this.acceptIdent(text)) { node.addChild(this._parseSupportsConditionInParens()); } } } return this.finish(node); }; Parser.prototype._parseSupportsConditionInParens = function () { var node = this.create(nodes.SupportsCondition); if (this.accept(cssScanner_1.TokenType.ParenthesisL)) { if (this.prevToken) { node.lParent = this.prevToken.offset; } if (!node.addChild(this._tryToParseDeclaration([cssScanner_1.TokenType.ParenthesisR]))) { if (!this._parseSupportsCondition()) { return this.finish(node, cssErrors_1.ParseError.ConditionExpected); } } if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) { return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected, [cssScanner_1.TokenType.ParenthesisR], []); } if (this.prevToken) { node.rParent = this.prevToken.offset; } return this.finish(node); } else if (this.peek(cssScanner_1.TokenType.Ident)) { var pos = this.mark(); this.consumeToken(); if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.ParenthesisL)) { var openParentCount = 1; while (this.token.type !== cssScanner_1.TokenType.EOF && openParentCount !== 0) { if (this.token.type === cssScanner_1.TokenType.ParenthesisL) { openParentCount++; } else if (this.token.type === cssScanner_1.TokenType.ParenthesisR) { openParentCount--; } this.consumeToken(); } return this.finish(node); } else { this.restoreAtMark(pos); } } return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected, [], [cssScanner_1.TokenType.ParenthesisL]); }; Parser.prototype._parseMediaDeclaration = function (isNested) { if (isNested === void 0) { isNested = false; } if (isNested) { // if nested, the body can contain rulesets, but also declarations return this._tryParseRuleset(true) || this._tryToParseDeclaration() || this._parseStylesheetStatement(true); } return this._parseStylesheetStatement(false); }; Parser.prototype._parseMedia = function (isNested) { if (isNested === void 0) { isNested = false; } // MEDIA_SYM S* media_query_list '{' S* ruleset* '}' S* // media_query_list : S* [media_query [ ',' S* media_query ]* ]? if (!this.peekKeyword('@media')) { return null; } var node = this.create(nodes.Media); this.consumeToken(); // @media if (!node.addChild(this._parseMediaQueryList())) { return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected); } return this._parseBody(node, this._parseMediaDeclaration.bind(this, isNested)); }; Parser.prototype._parseMediaQueryList = function () { var node = this.create(nodes.Medialist); if (!node.addChild(this._parseMediaQuery([cssScanner_1.TokenType.CurlyL]))) { return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected); } while (this.accept(cssScanner_1.TokenType.Comma)) { if (!node.addChild(this._parseMediaQuery([cssScanner_1.TokenType.CurlyL]))) { return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected); } } return this.finish(node); }; Parser.prototype._parseMediaQuery = function (resyncStopToken) { // http://www.w3.org/TR/css3-mediaqueries/ // media_query : [ONLY | NOT]? S* IDENT S* [ AND S* expression ]* | expression [ AND S* expression ]* // expression : '(' S* IDENT S* [ ':' S* expr ]? ')' S* var node = this.create(nodes.MediaQuery); var parseExpression = true; var hasContent = false; if (!this.peek(cssScanner_1.TokenType.ParenthesisL)) { if (this.acceptIdent('only') || this.acceptIdent('not')) { // optional } if (!node.addChild(this._parseIdent())) { return null; } hasContent = true; parseExpression = this.acceptIdent('and'); } while (parseExpression) { // Allow short-circuting for other language constructs. if (node.addChild(this._parseMediaContentStart())) { parseExpression = this.acceptIdent('and'); continue; } if (!this.accept(cssScanner_1.TokenType.ParenthesisL)) { if (hasContent) { return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected, [], resyncStopToken); } return null; } if (!node.addChild(this._parseMediaFeatureName())) { return this.finish(node, cssErrors_1.ParseError.IdentifierExpected, [], resyncStopToken); } if (this.accept(cssScanner_1.TokenType.Colon)) { if (!node.addChild(this._parseExpr())) { return this.finish(node, cssErrors_1.ParseError.TermExpected, [], resyncStopToken); } } if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) { return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected, [], resyncStopToken); } parseExpression = this.acceptIdent('and'); } return this.finish(node); }; Parser.prototype._parseMediaContentStart = function () { return null; }; Parser.prototype._parseMediaFeatureName = function () { return this._parseIdent(); }; Parser.prototype._parseMedium = function () { var node = this.create(nodes.Node); if (node.addChild(this._parseIdent())) { return this.finish(node); } else { return null; } }; Parser.prototype._parsePageDeclaration = function () { return this._parsePageMarginBox() || this._parseRuleSetDeclaration(); }; Parser.prototype._parsePage = function () { // http://www.w3.org/TR/css3-page/ // page_rule : PAGE_SYM S* page_selector_list '{' S* page_body '}' S* // page_body : /* Can be empty */ declaration? [ ';' S* page_body ]? | page_margin_box page_body if (!this.peekKeyword('@page')) { return null; } var node = this.create(nodes.Page); this.consumeToken(); if (node.addChild(this._parsePageSelector())) { while (this.accept(cssScanner_1.TokenType.Comma)) { if (!node.addChild(this._parsePageSelector())) { return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); } } } return this._parseBody(node, this._parsePageDeclaration.bind(this)); }; Parser.prototype._parsePageMarginBox = function () { // page_margin_box : margin_sym S* '{' S* declaration? [ ';' S* declaration? ]* '}' S* if (!this.peek(cssScanner_1.TokenType.AtKeyword)) { return null; } var node = this.create(nodes.PageBoxMarginBox); if (!this.acceptOneKeyword(languageFacts.pageBoxDirectives)) { this.markError(node, cssErrors_1.ParseError.UnknownAtRule, [], [cssScanner_1.TokenType.CurlyL]); } return this._parseBody(node, this._parseRuleSetDeclaration.bind(this)); }; Parser.prototype._parsePageSelector = function () { // page_selector : pseudo_page+ | IDENT pseudo_page* // pseudo_page : ':' [ "left" | "right" | "first" | "blank" ]; if (!this.peek(cssScanner_1.TokenType.Ident) && !this.peek(cssScanner_1.TokenType.Colon)) { return null; } var node = this.create(nodes.Node); node.addChild(this._parseIdent()); // optional ident if (this.accept(cssScanner_1.TokenType.Colon)) { if (!node.addChild(this._parseIdent())) { // optional ident return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); } } return this.finish(node); }; Parser.prototype._parseDocument = function () { // -moz-document is experimental but has been pushed to css4 if (!this.peekKeyword('@-moz-document')) { return null; } var node = this.create(nodes.Document); this.consumeToken(); // @-moz-document this.resync([], [cssScanner_1.TokenType.CurlyL]); // ignore all the rules return this._parseBody(node, this._parseStylesheetStatement.bind(this)); }; // https://www.w3.org/TR/css-syntax-3/#consume-an-at-rule Parser.prototype._parseUnknownAtRule = function () { if (!this.peek(cssScanner_1.TokenType.AtKeyword)) { return null; } var node = this.create(nodes.UnknownAtRule); node.addChild(this._parseUnknownAtRuleName()); var isTopLevel = function () { return curlyDepth === 0 && parensDepth === 0 && bracketsDepth === 0; }; var curlyLCount = 0; var curlyDepth = 0; var parensDepth = 0; var bracketsDepth = 0; done: while (true) { switch (this.token.type) { case cssScanner_1.TokenType.SemiColon: if (isTopLevel()) { break done; } break; case cssScanner_1.TokenType.EOF: if (curlyDepth > 0) { return this.finish(node, cssErrors_1.ParseError.RightCurlyExpected); } else if (bracketsDepth > 0) { return this.finish(node, cssErrors_1.ParseError.RightSquareBracketExpected); } else if (parensDepth > 0) { return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected); } else { return this.finish(node); } case cssScanner_1.TokenType.CurlyL: curlyLCount++; curlyDepth++; break; case cssScanner_1.TokenType.CurlyR: curlyDepth--; // End of at-rule, consume CurlyR and return node if (curlyLCount > 0 && curlyDepth === 0) { this.consumeToken(); if (bracketsDepth > 0) { return this.finish(node, cssErrors_1.ParseError.RightSquareBracketExpected); } else if (parensDepth > 0) { return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected); } break done; } if (curlyDepth < 0) { // The property value has been terminated without a semicolon, and // this is the last declaration in the ruleset. if (parensDepth === 0 && bracketsDepth === 0) { break done; } return this.finish(node, cssErrors_1.ParseError.LeftCurlyExpected); } break; case cssScanner_1.TokenType.ParenthesisL: parensDepth++; break; case cssScanner_1.TokenType.ParenthesisR: parensDepth--; if (parensDepth < 0) { return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected); } break; case cssScanner_1.TokenType.BracketL: bracketsDepth++; break; case cssScanner_1.TokenType.BracketR: bracketsDepth--; if (bracketsDepth < 0) { return this.finish(node, cssErrors_1.ParseError.LeftSquareBracketExpected); } break; } this.consumeToken(); } return node; }; Parser.prototype._parseUnknownAtRuleName = function () { var node = this.create(nodes.Node); if (this.accept(cssScanner_1.TokenType.AtKeyword)) { return this.finish(node); } return node; }; Parser.prototype._parseOperator = function () { // these are operators for binary expressions if (this.peekDelim('/') || this.peekDelim('*') || this.peekDelim('+') || this.peekDelim('-') || this.peek(cssScanner_1.TokenType.Dashmatch) || this.peek(cssScanner_1.TokenType.Includes) || this.peek(cssScanner_1.TokenType.SubstringOperator) || this.peek(cssScanner_1.TokenType.PrefixOperator) || this.peek(cssScanner_1.TokenType.SuffixOperator) || this.peekDelim('=')) { // doesn't stick to the standard here var node = this.createNode(nodes.NodeType.Operator); this.consumeToken(); return this.finish(node); } else { return null; } }; Parser.prototype._parseUnaryOperator = function () { if (!this.peekDelim('+') && !this.peekDelim('-')) { return null; } var node = this.create(nodes.Node); this.consumeToken(); return this.finish(node); }; Parser.prototype._parseCombinator = function () { if (this.peekDelim('>')) { var node = this.create(nodes.Node); this.consumeToken(); var mark = this.mark(); if (!this.hasWhitespace() && this.acceptDelim('>')) { if (!this.hasWhitespace() && this.acceptDelim('>')) { node.type = nodes.NodeType.SelectorCombinatorShadowPiercingDescendant; return this.finish(node); } this.restoreAtMark(mark); } node.type = nodes.NodeType.SelectorCombinatorParent; return this.finish(node); } else if (this.peekDelim('+')) { var node = this.create(nodes.Node); this.consumeToken(); node.type = nodes.NodeType.SelectorCombinatorSibling; return this.finish(node); } else if (this.peekDelim('~')) { var node = this.create(nodes.Node); this.consumeToken(); node.type = nodes.NodeType.SelectorCombinatorAllSiblings; return this.finish(node); } else if (this.peekDelim('/')) { var node = this.create(nodes.Node); this.consumeToken(); var mark = this.mark(); if (!this.hasWhitespace() && this.acceptIdent('deep') && !this.hasWhitespace() && this.acceptDelim('/')) { node.type = nodes.NodeType.SelectorCombinatorShadowPiercingDescendant; return this.finish(node); } this.restoreAtMark(mark); } return null; }; Parser.prototype._parseSimpleSelector = function () { // simple_selector // : element_name [ HASH | class | attrib | pseudo ]* | [ HASH | class | attrib | pseudo ]+ ; var node = this.create(nodes.SimpleSelector); var c = 0; if (node.addChild(this._parseElementName())) { c++; } while ((c === 0 || !this.hasWhitespace()) && node.addChild(this._parseSimpleSelectorBody())) { c++; } return c > 0 ? this.finish(node) : null; }; Parser.prototype._parseSimpleSelectorBody = function () { return this._parsePseudo() || this._parseHash() || this._parseClass() || this._parseAttrib(); }; Parser.prototype._parseSelectorIdent = function () { return this._parseIdent(); }; Parser.prototype._parseHash = function () { if (!this.peek(cssScanner_1.TokenType.Hash) && !this.peekDelim('#')) { return null; } var node = this.createNode(nodes.NodeType.IdentifierSelector); if (this.acceptDelim('#')) { if (this.hasWhitespace() || !node.addChild(this._parseSelectorIdent())) { return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); } } else { this.consumeToken(); // TokenType.Hash } return this.finish(node); }; Parser.prototype._parseClass = function () { // class: '.' IDENT ; if (!this.peekDelim('.')) { return null; } var node = this.createNode(nodes.NodeType.ClassSelector); this.consumeToken(); // '.' if (this.hasWhitespace() || !node.addChild(this._parseSelectorIdent())) { return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); } return this.finish(node); }; Parser.prototype._parseElementName = function () { // element_name: (ns? '|')? IDENT | '*'; var pos = this.mark(); var node = this.createNode(nodes.NodeType.ElementNameSelector); node.addChild(this._parseNamespacePrefix()); if (!node.addChild(this._parseSelectorIdent()) && !this.acceptDelim('*')) { this.restoreAtMark(pos); return null; } return this.finish(node); }; Parser.prototype._parseNamespacePrefix = function () { var pos = this.mark(); var node = this.createNode(nodes.NodeType.NamespacePrefix); if (!node.addChild(this._parseIdent()) && !this.acceptDelim('*')) { // ns is optional } if (!this.acceptDelim('|')) { this.restoreAtMark(pos); return null; } return this.finish(node); }; Parser.prototype._parseAttrib = function () { // attrib : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S* [ IDENT | STRING ] S* ]? ']' if (!this.peek(cssScanner_1.TokenType.BracketL)) { return null; } var node = this.create(nodes.AttributeSelector); this.consumeToken(); // BracketL // Optional attrib namespace node.setNamespacePrefix(this._parseNamespacePrefix()); if (!node.setIdentifier(this._parseIdent())) { return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); } if (node.setOperator(this._parseOperator())) { node.setValue(this._parseBinaryExpr()); this.acceptIdent('i'); // case insensitive matching } if (!this.accept(cssScanner_1.TokenType.BracketR)) { return this.finish(node, cssErrors_1.ParseError.RightSquareBracketExpected); } return this.finish(node); }; Parser.prototype._parsePseudo = function () { var _this = this; // pseudo: ':' [ IDENT | FUNCTION S* [IDENT S*]? ')' ] var node = this._tryParsePseudoIdentifier(); if (node) { if (!this.hasWhitespace() && this.accept(cssScanner_1.TokenType.ParenthesisL)) { var tryAsSelector = function () { var selectors = _this.create(nodes.Node); if (!selectors.addChild(_this._parseSelector(false))) { return null; } while (_this.accept(cssScanner_1.TokenType.Comma) && selectors.addChild(_this._parseSelector(false))) { // loop } if (_this.peek(cssScanner_1.TokenType.ParenthesisR)) { return _this.finish(selectors); } return null; }; node.addChild(this.try(tryAsSelector) || this._parseBinaryExpr()); if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) { return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected); } } return this.finish(node); } return null; }; Parser.prototype._tryParsePseudoIdentifier = function () { if (!this.peek(cssScanner_1.TokenType.Colon)) { return null; } var pos = this.mark(); var node = this.createNode(nodes.NodeType.PseudoSelector); this.consumeToken(); // Colon if (this.hasWhitespace()) { this.restoreAtMark(pos); return null; } // optional, support :: this.accept(cssScanner_1.TokenType.Colon); if (this.hasWhitespace() || !node.addChild(this._parseIdent())) { return this.finish(node, cssErrors_1.ParseError.IdentifierExpected); } return this.finish(node); }; Parser.prototype._tryParsePrio = function () { var mark = this.mark(); var prio = this._parsePrio(); if (prio) { return prio; } this.restoreAtMark(mark); return null; }; Parser.prototype._parsePrio = function () { if (!this.peek(cssScanner_1.TokenType.Exclamation)) { return null; } var node = this.createNode(nodes.NodeType.Prio); if (this.accept(cssScanner_1.TokenType.Exclamation) && this.acceptIdent('important')) { return this.finish(node); } return null; }; Parser.prototype._parseExpr = function (stopOnComma) { if (stopOnComma === void 0) { stopOnComma = false; } var node = this.create(nodes.Expression); if (!node.addChild(this._parseBinaryExpr())) { return null; } while (true) { if (this.peek(cssScanner_1.TokenType.Comma)) { // optional if (stopOnComma) { return this.finish(node); } this.consumeToken(); } if (!node.addChild(this._parseBinaryExpr())) { break; } } return this.finish(node); }; Parser.prototype._parseNamedLine = function () { // https://www.w3.org/TR/css-grid-1/#named-lines if (!this.peek(cssScanner_1.TokenType.BracketL)) { return null; } var node = this.createNode(nodes.NodeType.GridLine); this.consumeToken(); while (node.addChild(this._parseIdent())) { // repeat } if (!this.accept(cssScanner_1.TokenType.BracketR)) { return this.finish(node, cssErrors_1.ParseError.RightSquareBracketExpected); } return this.finish(node); }; Parser.prototype._parseBinaryExpr = function (preparsedLeft, preparsedOper) { var node = this.create(nodes.BinaryExpression); if (!node.setLeft((preparsedLeft || this._parseTerm()))) { return null; } if (!node.setOperator(preparsedOper || this._parseOperator())) { return this.finish(node); } if (!node.setRight(this._parseTerm())) { return this.finish(node, cssErrors_1.ParseError.TermExpected); } // things needed for multiple binary expressions node = this.finish(node); var operator = this._parseOperator(); if (operator) { node = this._parseBinaryExpr(node, operator); } return this.finish(node); }; Parser.prototype._parseTerm = function () { var node = this.create(nodes.Term); node.setOperator(this._parseUnaryOperator()); // optional if (node.setExpression(this._parseTermExpression())) { return this.finish(node); } return null; }; Parser.prototype._parseTermExpression = function () { return this._parseURILiteral() || // url before function this._parseFunction() || // function before ident this._parseIdent() || this._parseStringLiteral() || this._parseNumeric() || this._parseHexColor() || this._parseOperation() || this._parseNamedLine(); }; Parser.prototype._parseOperation = function () { if (!this.peek(cssScanner_1.TokenType.ParenthesisL)) { return null; } var node = this.create(nodes.Node); this.consumeToken(); // ParenthesisL node.addChild(this._parseExpr()); if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) { return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected); } return this.finish(node); }; Parser.prototype._parseNumeric = function () { if (this.peek(cssScanner_1.TokenType.Num) || this.peek(cssScanner_1.TokenType.Percentage) || this.peek(cssScanner_1.TokenType.Resolution) || this.peek(cssScanner_1.TokenType.Length) || this.peek(cssScanner_1.TokenType.EMS) || this.peek(cssScanner_1.TokenType.EXS) || this.peek(cssScanner_1.TokenType.Angle) || this.peek(cssScanner_1.TokenType.Time) || this.peek(cssScanner_1.TokenType.Dimension) || this.peek(cssScanner_1.TokenType.Freq)) { var node = this.create(nodes.NumericValue); this.consumeToken(); return this.finish(node); } return null; }; Parser.prototype._parseStringLiteral = function () { if (!this.peek(cssScanner_1.TokenType.String) && !this.peek(cssScanner_1.TokenType.BadString)) { return null; } var node = this.createNode(nodes.NodeType.StringLiteral); this.consumeToken(); return this.finish(node); }; Parser.prototype._parseURILiteral = function () { if (!this.peekRegExp(cssScanner_1.TokenType.Ident, /^url(-prefix)?$/i)) { return null; } var pos = this.mark(); var node = this.createNode(nodes.NodeType.URILiteral); this.accept(cssScanner_1.TokenType.Ident); if (this.hasWhitespace() || !this.peek(cssScanner_1.TokenType.ParenthesisL)) { this.restoreAtMark(pos); return null; } this.scanner.inURL = true; this.consumeToken(); // consume () node.addChild(this._parseURLArgument()); // argument is optional this.scanner.inURL = false; if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) { return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected); } return this.finish(node); }; Parser.prototype._parseURLArgument = function () { var node = this.create(nodes.Node); if (!this.accept(cssScanner_1.TokenType.String) && !this.accept(cssScanner_1.TokenType.BadString) && !this.acceptUnquotedString()) { return null; } return this.finish(node); }; Parser.prototype._parseIdent = function (referenceTypes) { if (!this.peek(cssScanner_1.TokenType.Ident)) { return null; } var node = this.create(nodes.Identifier); if (referenceTypes) { node.referenceTypes = referenceTypes; } node.isCustomProperty = this.peekRegExp(cssScanner_1.TokenType.Ident, /^--/); this.consumeToken(); return this.finish(node); }; Parser.prototype._parseFunction = function () { var pos = this.mark(); var node = this.create(nodes.Function); if (!node.setIdentifier(this._parseFunctionIdentifier())) { return null; } if (this.hasWhitespace() || !this.accept(cssScanner_1.TokenType.ParenthesisL)) { this.restoreAtMark(pos); return null; } if (node.getArguments().addChild(this._parseFunctionArgument())) { while (this.accept(cssScanner_1.TokenType.Comma)) { if (this.peek(cssScanner_1.TokenType.ParenthesisR)) { break; } if (!node.getArguments().addChild(this._parseFunctionArgument())) { this.markError(node, cssErrors_1.ParseError.ExpressionExpected); } } } if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) { return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected); } return this.finish(node); }; Parser.prototype._parseFunctionIdentifier = function () { if (!this.peek(cssScanner_1.TokenType.Ident)) { return null; } var node = this.create(nodes.Identifier); node.referenceTypes = [nodes.ReferenceType.Function]; if (this.acceptIdent('progid')) { // support for IE7 specific filters: 'progid:DXImageTransform.Microsoft.MotionBlur(strength=13, direction=310)' if (this.accept(cssScanner_1.TokenType.Colon)) { while (this.accept(cssScanner_1.TokenType.Ident) && this.acceptDelim('.')) { // loop } } return this.finish(node); } this.consumeToken(); return this.finish(node); }; Parser.prototype._parseFunctionArgument = function () { var node = this.create(nodes.FunctionArgument); if (node.setValue(this._parseExpr(true))) { return this.finish(node); } return null; }; Parser.prototype._parseHexColor = function () { if (this.peekRegExp(cssScanner_1.TokenType.Hash, /^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/g)) { var node = this.create(nodes.HexColorValue); this.consumeToken(); return this.finish(node); } else { return null; } }; return Parser; }()); exports.Parser = Parser; }); (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('vscode-css-languageservice/utils/arrays',["require", "exports"], 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 }); exports.union = exports.includes = exports.findFirst = void 0; /** * Takes a sorted array and a function p. The array is sorted in such a way that all elements where p(x) is false * are located before all elements where p(x) is true. * @returns the least x for which p(x) is true or array.length if no element fullfills the given function. */ function findFirst(array, p) { var low = 0, high = array.length; if (high === 0) { return 0; // no children } while (low < high) { var mid = Math.floor((low + high) / 2); if (p(array[mid])) { high = mid; } else { low = mid + 1; } } return low; } exports.findFirst = findFirst; function includes(array, item) { return array.indexOf(item) !== -1; } exports.includes = includes; function union() { var arrays = []; for (var _i = 0; _i < arguments.length; _i++) { arrays[_i] = arguments[_i]; } var result = []; for (var _a = 0, arrays_1 = arrays; _a < arrays_1.length; _a++) { var array = arrays_1[_a]; for (var _b = 0, array_1 = array; _b < array_1.length; _b++) { var item = array_1[_b]; if (!includes(result, item)) { result.push(item); } } } return result; } exports.union = union; }); var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); (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('vscode-css-languageservice/parser/cssSymbolScope',["require", "exports", "./cssNodes", "../utils/arrays"], 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 }); exports.Symbols = exports.ScopeBuilder = exports.Symbol = exports.GlobalScope = exports.Scope = void 0; var nodes = require("./cssNodes"); var arrays_1 = require("../utils/arrays"); var Scope = /** @class */ (function () { function Scope(offset, length) { this.offset = offset; this.length = length; this.symbols = []; this.parent = null; this.children = []; } Scope.prototype.addChild = function (scope) { this.children.push(scope); scope.setParent(this); }; Scope.prototype.setParent = function (scope) { this.parent = scope; }; Scope.prototype.findScope = function (offset, length) { if (length === void 0) { length = 0; } if (this.offset <= offset && this.offset + this.length > offset + length || this.offset === offset && this.length === length) { return this.findInScope(offset, length); } return null; }; Scope.prototype.findInScope = function (offset, length) { if (length === void 0) { length = 0; } // find the first scope child that has an offset larger than offset + length var end = offset + length; var idx = (0, arrays_1.findFirst)(this.children, function (s) { return s.offset > end; }); if (idx === 0) { // all scopes have offsets larger than our end return this; } var res = this.children[idx - 1]; if (res.offset <= offset && res.offset + res.length >= offset + length) { return res.findInScope(offset, length); } return this; }; Scope.prototype.addSymbol = function (symbol) { this.symbols.push(symbol); }; Scope.prototype.getSymbol = function (name, type) { for (var index = 0; index < this.symbols.length; index++) { var symbol = this.symbols[index]; if (symbol.name === name && symbol.type === type) { return symbol; } } return null; }; Scope.prototype.getSymbols = function () { return this.symbols; }; return Scope; }()); exports.Scope = Scope; var GlobalScope = /** @class */ (function (_super) { __extends(GlobalScope, _super); function GlobalScope() { return _super.call(this, 0, Number.MAX_VALUE) || this; } return GlobalScope; }(Scope)); exports.GlobalScope = GlobalScope; var Symbol = /** @class */ (function () { function Symbol(name, value, node, type) { this.name = name; this.value = value; this.node = node; this.type = type; } return Symbol; }()); exports.Symbol = Symbol; var ScopeBuilder = /** @class */ (function () { function ScopeBuilder(scope) { this.scope = scope; } ScopeBuilder.prototype.addSymbol = function (node, name, value, type) { if (node.offset !== -1) { var current = this.scope.findScope(node.offset, node.length); if (current) { current.addSymbol(new Symbol(name, value, node, type)); } } }; ScopeBuilder.prototype.addScope = function (node) { if (node.offset !== -1) { var current = this.scope.findScope(node.offset, node.length); if (current && (current.offset !== node.offset || current.length !== node.length)) { // scope already known? var newScope = new Scope(node.offset, node.length); current.addChild(newScope); return newScope; } return current; } return null; }; ScopeBuilder.prototype.addSymbolToChildScope = function (scopeNode, node, name, value, type) { if (scopeNode && scopeNode.offset !== -1) { var current = this.addScope(scopeNode); // create the scope or gets the existing one if (current) { current.addSymbol(new Symbol(name, value, node, type)); } } }; ScopeBuilder.prototype.visitNode = function (node) { switch (node.type) { case nodes.NodeType.Keyframe: this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Keyframe); return true; case nodes.NodeType.CustomPropertyDeclaration: return this.visitCustomPropertyDeclarationNode(node); case nodes.NodeType.VariableDeclaration: return this.visitVariableDeclarationNode(node); case nodes.NodeType.Ruleset: return this.visitRuleSet(node); case nodes.NodeType.MixinDeclaration: this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Mixin); return true; case nodes.NodeType.FunctionDeclaration: this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Function); return true; case nodes.NodeType.FunctionParameter: { return this.visitFunctionParameterNode(node); } case nodes.NodeType.Declarations: this.addScope(node); return true; case nodes.NodeType.For: var forNode = node; var scopeNode = forNode.getDeclarations(); if (scopeNode && forNode.variable) { this.addSymbolToChildScope(scopeNode, forNode.variable, forNode.variable.getName(), void 0, nodes.ReferenceType.Variable); } return true; case nodes.NodeType.Each: { var eachNode = node; var scopeNode_1 = eachNode.getDeclarations(); if (scopeNode_1) { var variables = eachNode.getVariables().getChildren(); for (var _i = 0, variables_1 = variables; _i < variables_1.length; _i++) { var variable = variables_1[_i]; this.addSymbolToChildScope(scopeNode_1, variable, variable.getName(), void 0, nodes.ReferenceType.Variable); } } return true; } } return true; }; ScopeBuilder.prototype.visitRuleSet = function (node) { var current = this.scope.findScope(node.offset, node.length); if (current) { for (var _i = 0, _a = node.getSelectors().getChildren(); _i < _a.length; _i++) { var child = _a[_i]; if (child instanceof nodes.Selector) { if (child.getChildren().length === 1) { // only selectors with a single element can be extended current.addSymbol(new Symbol(child.getChild(0).getText(), void 0, child, nodes.ReferenceType.Rule)); } } } } return true; }; ScopeBuilder.prototype.visitVariableDeclarationNode = function (node) { var value = node.getValue() ? node.getValue().getText() : void 0; this.addSymbol(node, node.getName(), value, nodes.ReferenceType.Variable); return true; }; ScopeBuilder.prototype.visitFunctionParameterNode = function (node) { // parameters are part of the body scope var scopeNode = node.getParent().getDeclarations(); if (scopeNode) { var valueNode = node.getDefaultValue(); var value = valueNode ? valueNode.getText() : void 0; this.addSymbolToChildScope(scopeNode, node, node.getName(), value, nodes.ReferenceType.Variable); } return true; }; ScopeBuilder.prototype.visitCustomPropertyDeclarationNode = function (node) { var value = node.getValue() ? node.getValue().getText() : ''; this.addCSSVariable(node.getProperty(), node.getProperty().getName(), value, nodes.ReferenceType.Variable); return true; }; ScopeBuilder.prototype.addCSSVariable = function (node, name, value, type) { if (node.offset !== -1) { this.scope.addSymbol(new Symbol(name, value, node, type)); } }; return ScopeBuilder; }()); exports.ScopeBuilder = ScopeBuilder; var Symbols = /** @class */ (function () { function Symbols(node) { this.global = new GlobalScope(); node.acceptVisitor(new ScopeBuilder(this.global)); } Symbols.prototype.findSymbolsAtOffset = function (offset, referenceType) { var scope = this.global.findScope(offset, 0); var result = []; var names = {}; while (scope) { var symbols = scope.getSymbols(); for (var i = 0; i < symbols.length; i++) { var symbol = symbols[i]; if (symbol.type === referenceType && !names[symbol.name]) { result.push(symbol); names[symbol.name] = true; } } scope = scope.parent; } return result; }; Symbols.prototype.internalFindSymbol = function (node, referenceTypes) { var scopeNode = node; if (node.parent instanceof nodes.FunctionParameter && node.parent.getParent() instanceof nodes.BodyDeclaration) { scopeNode = node.parent.getParent().getDeclarations(); } if (node.parent instanceof nodes.FunctionArgument && node.parent.getParent() instanceof nodes.Function) { var funcId = node.parent.getParent().getIdentifier(); if (funcId) { var functionSymbol = this.internalFindSymbol(funcId, [nodes.ReferenceType.Function]); if (functionSymbol) { scopeNode = functionSymbol.node.getDeclarations(); } } } if (!scopeNode) { return null; } var name = node.getText(); var scope = this.global.findScope(scopeNode.offset, scopeNode.length); while (scope) { for (var index = 0; index < referenceTypes.length; index++) { var type = referenceTypes[index]; var symbol = scope.getSymbol(name, type); if (symbol) { return symbol; } } scope = scope.parent; } return null; }; Symbols.prototype.evaluateReferenceTypes = function (node) { if (node instanceof nodes.Identifier) { var referenceTypes = node.referenceTypes; if (referenceTypes) { return referenceTypes; } else { if (node.isCustomProperty) { return [nodes.ReferenceType.Variable]; } // are a reference to a keyframe? var decl = nodes.getParentDeclaration(node); if (decl) { var propertyName = decl.getNonPrefixedPropertyName(); if ((propertyName === 'animation' || propertyName === 'animation-name') && decl.getValue() && decl.getValue().offset === node.offset) { return [nodes.ReferenceType.Keyframe]; } } } } else if (node instanceof nodes.Variable) { return [nodes.ReferenceType.Variable]; } var selector = node.findAParent(nodes.NodeType.Selector, nodes.NodeType.ExtendsReference); if (selector) { return [nodes.ReferenceType.Rule]; } return null; }; Symbols.prototype.findSymbolFromNode = function (node) { if (!node) { return null; } while (node.type === nodes.NodeType.Interpolation) { node = node.getParent(); } var referenceTypes = this.evaluateReferenceTypes(node); if (referenceTypes) { return this.internalFindSymbol(node, referenceTypes); } return null; }; Symbols.prototype.matchesSymbol = function (node, symbol) { if (!node) { return false; } while (node.type === nodes.NodeType.Interpolation) { node = node.getParent(); } if (!node.matches(symbol.name)) { return false; } var referenceTypes = this.evaluateReferenceTypes(node); if (!referenceTypes || referenceTypes.indexOf(symbol.type) === -1) { return false; } var nodeSymbol = this.internalFindSymbol(node, referenceTypes); return nodeSymbol === symbol; }; Symbols.prototype.findSymbol = function (name, type, offset) { var scope = this.global.findScope(offset); while (scope) { var symbol = scope.getSymbol(name, type); if (symbol) { return symbol; } scope = scope.parent; } return null; }; return Symbols; }()); exports.Symbols = Symbols; }); (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('vscode-languageserver-types/main',["require", "exports"], 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 }); exports.TextDocument = exports.EOL = exports.SelectionRange = exports.DocumentLink = exports.FormattingOptions = exports.CodeLens = exports.CodeAction = exports.CodeActionContext = exports.CodeActionKind = exports.DocumentSymbol = exports.SymbolInformation = exports.SymbolTag = exports.SymbolKind = exports.DocumentHighlight = exports.DocumentHighlightKind = exports.SignatureInformation = exports.ParameterInformation = exports.Hover = exports.MarkedString = exports.CompletionList = exports.CompletionItem = exports.InsertTextMode = exports.InsertReplaceEdit = exports.CompletionItemTag = exports.InsertTextFormat = exports.CompletionItemKind = exports.MarkupContent = exports.MarkupKind = exports.TextDocumentItem = exports.OptionalVersionedTextDocumentIdentifier = exports.VersionedTextDocumentIdentifier = exports.TextDocumentIdentifier = exports.WorkspaceChange = exports.WorkspaceEdit = exports.DeleteFile = exports.RenameFile = exports.CreateFile = exports.TextDocumentEdit = exports.AnnotatedTextEdit = exports.ChangeAnnotationIdentifier = exports.ChangeAnnotation = exports.TextEdit = exports.Command = exports.Diagnostic = exports.CodeDescription = exports.DiagnosticTag = exports.DiagnosticSeverity = exports.DiagnosticRelatedInformation = exports.FoldingRange = exports.FoldingRangeKind = exports.ColorPresentation = exports.ColorInformation = exports.Color = exports.LocationLink = exports.Location = exports.Range = exports.Position = exports.uinteger = exports.integer = void 0; var integer; (function (integer) { integer.MIN_VALUE = -2147483648; integer.MAX_VALUE = 2147483647; })(integer = exports.integer || (exports.integer = {})); var uinteger; (function (uinteger) { uinteger.MIN_VALUE = 0; uinteger.MAX_VALUE = 2147483647; })(uinteger = exports.uinteger || (exports.uinteger = {})); /** * The Position namespace provides helper functions to work with * [Position](#Position) literals. */ var Position; (function (Position) { /** * Creates a new Position literal from the given line and character. * @param line The position's line. * @param character The position's character. */ function create(line, character) { if (line === Number.MAX_VALUE) { line = uinteger.MAX_VALUE; } if (character === Number.MAX_VALUE) { character = uinteger.MAX_VALUE; } return { line: line, character: character }; } Position.create = create; /** * Checks whether the given literal conforms to the [Position](#Position) interface. */ function is(value) { var candidate = value; return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character); } Position.is = is; })(Position = exports.Position || (exports.Position = {})); /** * The Range namespace provides helper functions to work with * [Range](#Range) literals. */ var Range; (function (Range) { function create(one, two, three, four) { if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) { return { start: Position.create(one, two), end: Position.create(three, four) }; } else if (Position.is(one) && Position.is(two)) { return { start: one, end: two }; } else { throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]"); } } Range.create = create; /** * Checks whether the given literal conforms to the [Range](#Range) interface. */ function is(value) { var candidate = value; return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end); } Range.is = is; })(Range = exports.Range || (exports.Range = {})); /** * The Location namespace provides helper functions to work with * [Location](#Location) literals. */ var Location; (function (Location) { /** * Creates a Location literal. * @param uri The location's uri. * @param range The location's range. */ function create(uri, range) { return { uri: uri, range: range }; } Location.create = create; /** * Checks whether the given literal conforms to the [Location](#Location) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri)); } Location.is = is; })(Location = exports.Location || (exports.Location = {})); /** * The LocationLink namespace provides helper functions to work with * [LocationLink](#LocationLink) literals. */ var LocationLink; (function (LocationLink) { /** * Creates a LocationLink literal. * @param targetUri The definition's uri. * @param targetRange The full range of the definition. * @param targetSelectionRange The span of the symbol definition at the target. * @param originSelectionRange The span of the symbol being defined in the originating source file. */ function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) { return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange }; } LocationLink.create = create; /** * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange)) && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange)); } LocationLink.is = is; })(LocationLink = exports.LocationLink || (exports.LocationLink = {})); /** * The Color namespace provides helper functions to work with * [Color](#Color) literals. */ var Color; (function (Color) { /** * Creates a new Color literal. */ function create(red, green, blue, alpha) { return { red: red, green: green, blue: blue, alpha: alpha, }; } Color.create = create; /** * Checks whether the given literal conforms to the [Color](#Color) interface. */ function is(value) { var candidate = value; return Is.numberRange(candidate.red, 0, 1) && Is.numberRange(candidate.green, 0, 1) && Is.numberRange(candidate.blue, 0, 1) && Is.numberRange(candidate.alpha, 0, 1); } Color.is = is; })(Color = exports.Color || (exports.Color = {})); /** * The ColorInformation namespace provides helper functions to work with * [ColorInformation](#ColorInformation) literals. */ var ColorInformation; (function (ColorInformation) { /** * Creates a new ColorInformation literal. */ function create(range, color) { return { range: range, color: color, }; } ColorInformation.create = create; /** * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface. */ function is(value) { var candidate = value; return Range.is(candidate.range) && Color.is(candidate.color); } ColorInformation.is = is; })(ColorInformation = exports.ColorInformation || (exports.ColorInformation = {})); /** * The Color namespace provides helper functions to work with * [ColorPresentation](#ColorPresentation) literals. */ var ColorPresentation; (function (ColorPresentation) { /** * Creates a new ColorInformation literal. */ function create(label, textEdit, additionalTextEdits) { return { label: label, textEdit: textEdit, additionalTextEdits: additionalTextEdits, }; } ColorPresentation.create = create; /** * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface. */ function is(value) { var candidate = value; return Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is)); } ColorPresentation.is = is; })(ColorPresentation = exports.ColorPresentation || (exports.ColorPresentation = {})); /** * Enum of known range kinds */ var FoldingRangeKind; (function (FoldingRangeKind) { /** * Folding range for a comment */ FoldingRangeKind["Comment"] = "comment"; /** * Folding range for a imports or includes */ FoldingRangeKind["Imports"] = "imports"; /** * Folding range for a region (e.g. `#region`) */ FoldingRangeKind["Region"] = "region"; })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {})); /** * The folding range namespace provides helper functions to work with * [FoldingRange](#FoldingRange) literals. */ var FoldingRange; (function (FoldingRange) { /** * Creates a new FoldingRange literal. */ function create(startLine, endLine, startCharacter, endCharacter, kind) { var result = { startLine: startLine, endLine: endLine }; if (Is.defined(startCharacter)) { result.startCharacter = startCharacter; } if (Is.defined(endCharacter)) { result.endCharacter = endCharacter; } if (Is.defined(kind)) { result.kind = kind; } return result; } FoldingRange.create = create; /** * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface. */ function is(value) { var candidate = value; return Is.uinteger(candidate.startLine) && Is.uinteger(candidate.startLine) && (Is.undefined(candidate.startCharacter) || Is.uinteger(candidate.startCharacter)) && (Is.undefined(candidate.endCharacter) || Is.uinteger(candidate.endCharacter)) && (Is.undefined(candidate.kind) || Is.string(candidate.kind)); } FoldingRange.is = is; })(FoldingRange = exports.FoldingRange || (exports.FoldingRange = {})); /** * The DiagnosticRelatedInformation namespace provides helper functions to work with * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals. */ var DiagnosticRelatedInformation; (function (DiagnosticRelatedInformation) { /** * Creates a new DiagnosticRelatedInformation literal. */ function create(location, message) { return { location: location, message: message }; } DiagnosticRelatedInformation.create = create; /** * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message); } DiagnosticRelatedInformation.is = is; })(DiagnosticRelatedInformation = exports.DiagnosticRelatedInformation || (exports.DiagnosticRelatedInformation = {})); /** * The diagnostic's severity. */ var DiagnosticSeverity; (function (DiagnosticSeverity) { /** * Reports an error. */ DiagnosticSeverity.Error = 1; /** * Reports a warning. */ DiagnosticSeverity.Warning = 2; /** * Reports an information. */ DiagnosticSeverity.Information = 3; /** * Reports a hint. */ DiagnosticSeverity.Hint = 4; })(DiagnosticSeverity = exports.DiagnosticSeverity || (exports.DiagnosticSeverity = {})); /** * The diagnostic tags. * * @since 3.15.0 */ var DiagnosticTag; (function (DiagnosticTag) { /** * Unused or unnecessary code. * * Clients are allowed to render diagnostics with this tag faded out instead of having * an error squiggle. */ DiagnosticTag.Unnecessary = 1; /** * Deprecated or obsolete code. * * Clients are allowed to rendered diagnostics with this tag strike through. */ DiagnosticTag.Deprecated = 2; })(DiagnosticTag = exports.DiagnosticTag || (exports.DiagnosticTag = {})); /** * The CodeDescription namespace provides functions to deal with descriptions for diagnostic codes. * * @since 3.16.0 */ var CodeDescription; (function (CodeDescription) { function is(value) { var candidate = value; return candidate !== undefined && candidate !== null && Is.string(candidate.href); } CodeDescription.is = is; })(CodeDescription = exports.CodeDescription || (exports.CodeDescription = {})); /** * The Diagnostic namespace provides helper functions to work with * [Diagnostic](#Diagnostic) literals. */ var Diagnostic; (function (Diagnostic) { /** * Creates a new Diagnostic literal. */ function create(range, message, severity, code, source, relatedInformation) { var result = { range: range, message: message }; if (Is.defined(severity)) { result.severity = severity; } if (Is.defined(code)) { result.code = code; } if (Is.defined(source)) { result.source = source; } if (Is.defined(relatedInformation)) { result.relatedInformation = relatedInformation; } return result; } Diagnostic.create = create; /** * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface. */ function is(value) { var _a; var candidate = value; return Is.defined(candidate) && Range.is(candidate.range) && Is.string(candidate.message) && (Is.number(candidate.severity) || Is.undefined(candidate.severity)) && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code)) && (Is.undefined(candidate.codeDescription) || (Is.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href))) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is)); } Diagnostic.is = is; })(Diagnostic = exports.Diagnostic || (exports.Diagnostic = {})); /** * The Command namespace provides helper functions to work with * [Command](#Command) literals. */ var Command; (function (Command) { /** * Creates a new Command literal. */ function create(title, command) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } var result = { title: title, command: command }; if (Is.defined(args) && args.length > 0) { result.arguments = args; } return result; } Command.create = create; /** * Checks whether the given literal conforms to the [Command](#Command) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command); } Command.is = is; })(Command = exports.Command || (exports.Command = {})); /** * The TextEdit namespace provides helper function to create replace, * insert and delete edits more easily. */ var TextEdit; (function (TextEdit) { /** * Creates a replace text edit. * @param range The range of text to be replaced. * @param newText The new text. */ function replace(range, newText) { return { range: range, newText: newText }; } TextEdit.replace = replace; /** * Creates a insert text edit. * @param position The position to insert the text at. * @param newText The text to be inserted. */ function insert(position, newText) { return { range: { start: position, end: position }, newText: newText }; } TextEdit.insert = insert; /** * Creates a delete text edit. * @param range The range of text to be deleted. */ function del(range) { return { range: range, newText: '' }; } TextEdit.del = del; function is(value) { var candidate = value; return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range); } TextEdit.is = is; })(TextEdit = exports.TextEdit || (exports.TextEdit = {})); var ChangeAnnotation; (function (ChangeAnnotation) { function create(label, needsConfirmation, description) { var result = { label: label }; if (needsConfirmation !== undefined) { result.needsConfirmation = needsConfirmation; } if (description !== undefined) { result.description = description; } return result; } ChangeAnnotation.create = create; function is(value) { var candidate = value; return candidate !== undefined && Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === undefined) && (Is.string(candidate.description) || candidate.description === undefined); } ChangeAnnotation.is = is; })(ChangeAnnotation = exports.ChangeAnnotation || (exports.ChangeAnnotation = {})); var ChangeAnnotationIdentifier; (function (ChangeAnnotationIdentifier) { function is(value) { var candidate = value; return typeof candidate === 'string'; } ChangeAnnotationIdentifier.is = is; })(ChangeAnnotationIdentifier = exports.ChangeAnnotationIdentifier || (exports.ChangeAnnotationIdentifier = {})); var AnnotatedTextEdit; (function (AnnotatedTextEdit) { /** * Creates an annotated replace text edit. * * @param range The range of text to be replaced. * @param newText The new text. * @param annotation The annotation. */ function replace(range, newText, annotation) { return { range: range, newText: newText, annotationId: annotation }; } AnnotatedTextEdit.replace = replace; /** * Creates an annotated insert text edit. * * @param position The position to insert the text at. * @param newText The text to be inserted. * @param annotation The annotation. */ function insert(position, newText, annotation) { return { range: { start: position, end: position }, newText: newText, annotationId: annotation }; } AnnotatedTextEdit.insert = insert; /** * Creates an annotated delete text edit. * * @param range The range of text to be deleted. * @param annotation The annotation. */ function del(range, annotation) { return { range: range, newText: '', annotationId: annotation }; } AnnotatedTextEdit.del = del; function is(value) { var candidate = value; return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId)); } AnnotatedTextEdit.is = is; })(AnnotatedTextEdit = exports.AnnotatedTextEdit || (exports.AnnotatedTextEdit = {})); /** * The TextDocumentEdit namespace provides helper function to create * an edit that manipulates a text document. */ var TextDocumentEdit; (function (TextDocumentEdit) { /** * Creates a new `TextDocumentEdit` */ function create(textDocument, edits) { return { textDocument: textDocument, edits: edits }; } TextDocumentEdit.create = create; function is(value) { var candidate = value; return Is.defined(candidate) && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument) && Array.isArray(candidate.edits); } TextDocumentEdit.is = is; })(TextDocumentEdit = exports.TextDocumentEdit || (exports.TextDocumentEdit = {})); var CreateFile; (function (CreateFile) { function create(uri, options, annotation) { var result = { kind: 'create', uri: uri }; if (options !== undefined && (options.overwrite !== undefined || options.ignoreIfExists !== undefined)) { result.options = options; } if (annotation !== undefined) { result.annotationId = annotation; } return result; } CreateFile.create = create; function is(value) { var candidate = value; return candidate && candidate.kind === 'create' && Is.string(candidate.uri) && (candidate.options === undefined || ((candidate.options.overwrite === undefined || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === undefined || Is.boolean(candidate.options.ignoreIfExists)))) && (candidate.annotationId === undefined || ChangeAnnotationIdentifier.is(candidate.annotationId)); } CreateFile.is = is; })(CreateFile = exports.CreateFile || (exports.CreateFile = {})); var RenameFile; (function (RenameFile) { function create(oldUri, newUri, options, annotation) { var result = { kind: 'rename', oldUri: oldUri, newUri: newUri }; if (options !== undefined && (options.overwrite !== undefined || options.ignoreIfExists !== undefined)) { result.options = options; } if (annotation !== undefined) { result.annotationId = annotation; } return result; } RenameFile.create = create; function is(value) { var candidate = value; return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && (candidate.options === undefined || ((candidate.options.overwrite === undefined || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === undefined || Is.boolean(candidate.options.ignoreIfExists)))) && (candidate.annotationId === undefined || ChangeAnnotationIdentifier.is(candidate.annotationId)); } RenameFile.is = is; })(RenameFile = exports.RenameFile || (exports.RenameFile = {})); var DeleteFile; (function (DeleteFile) { function create(uri, options, annotation) { var result = { kind: 'delete', uri: uri }; if (options !== undefined && (options.recursive !== undefined || options.ignoreIfNotExists !== undefined)) { result.options = options; } if (annotation !== undefined) { result.annotationId = annotation; } return result; } DeleteFile.create = create; function is(value) { var candidate = value; return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) && (candidate.options === undefined || ((candidate.options.recursive === undefined || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === undefined || Is.boolean(candidate.options.ignoreIfNotExists)))) && (candidate.annotationId === undefined || ChangeAnnotationIdentifier.is(candidate.annotationId)); } DeleteFile.is = is; })(DeleteFile = exports.DeleteFile || (exports.DeleteFile = {})); var WorkspaceEdit; (function (WorkspaceEdit) { function is(value) { var candidate = value; return candidate && (candidate.changes !== undefined || candidate.documentChanges !== undefined) && (candidate.documentChanges === undefined || candidate.documentChanges.every(function (change) { if (Is.string(change.kind)) { return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change); } else { return TextDocumentEdit.is(change); } })); } WorkspaceEdit.is = is; })(WorkspaceEdit = exports.WorkspaceEdit || (exports.WorkspaceEdit = {})); var TextEditChangeImpl = /** @class */ (function () { function TextEditChangeImpl(edits, changeAnnotations) { this.edits = edits; this.changeAnnotations = changeAnnotations; } TextEditChangeImpl.prototype.insert = function (position, newText, annotation) { var edit; var id; if (annotation === undefined) { edit = TextEdit.insert(position, newText); } else if (ChangeAnnotationIdentifier.is(annotation)) { id = annotation; edit = AnnotatedTextEdit.insert(position, newText, annotation); } else { this.assertChangeAnnotations(this.changeAnnotations); id = this.changeAnnotations.manage(annotation); edit = AnnotatedTextEdit.insert(position, newText, id); } this.edits.push(edit); if (id !== undefined) { return id; } }; TextEditChangeImpl.prototype.replace = function (range, newText, annotation) { var edit; var id; if (annotation === undefined) { edit = TextEdit.replace(range, newText); } else if (ChangeAnnotationIdentifier.is(annotation)) { id = annotation; edit = AnnotatedTextEdit.replace(range, newText, annotation); } else { this.assertChangeAnnotations(this.changeAnnotations); id = this.changeAnnotations.manage(annotation); edit = AnnotatedTextEdit.replace(range, newText, id); } this.edits.push(edit); if (id !== undefined) { return id; } }; TextEditChangeImpl.prototype.delete = function (range, annotation) { var edit; var id; if (annotation === undefined) { edit = TextEdit.del(range); } else if (ChangeAnnotationIdentifier.is(annotation)) { id = annotation; edit = AnnotatedTextEdit.del(range, annotation); } else { this.assertChangeAnnotations(this.changeAnnotations); id = this.changeAnnotations.manage(annotation); edit = AnnotatedTextEdit.del(range, id); } this.edits.push(edit); if (id !== undefined) { return id; } }; TextEditChangeImpl.prototype.add = function (edit) { this.edits.push(edit); }; TextEditChangeImpl.prototype.all = function () { return this.edits; }; TextEditChangeImpl.prototype.clear = function () { this.edits.splice(0, this.edits.length); }; TextEditChangeImpl.prototype.assertChangeAnnotations = function (value) { if (value === undefined) { throw new Error("Text edit change is not configured to manage change annotations."); } }; return TextEditChangeImpl; }()); /** * A helper class */ var ChangeAnnotations = /** @class */ (function () { function ChangeAnnotations(annotations) { this._annotations = annotations === undefined ? Object.create(null) : annotations; this._counter = 0; this._size = 0; } ChangeAnnotations.prototype.all = function () { return this._annotations; }; Object.defineProperty(ChangeAnnotations.prototype, "size", { get: function () { return this._size; }, enumerable: false, configurable: true }); ChangeAnnotations.prototype.manage = function (idOrAnnotation, annotation) { var id; if (ChangeAnnotationIdentifier.is(idOrAnnotation)) { id = idOrAnnotation; } else { id = this.nextId(); annotation = idOrAnnotation; } if (this._annotations[id] !== undefined) { throw new Error("Id " + id + " is already in use."); } if (annotation === undefined) { throw new Error("No annotation provided for id " + id); } this._annotations[id] = annotation; this._size++; return id; }; ChangeAnnotations.prototype.nextId = function () { this._counter++; return this._counter.toString(); }; return ChangeAnnotations; }()); /** * A workspace change helps constructing changes to a workspace. */ var WorkspaceChange = /** @class */ (function () { function WorkspaceChange(workspaceEdit) { var _this = this; this._textEditChanges = Object.create(null); if (workspaceEdit !== undefined) { this._workspaceEdit = workspaceEdit; if (workspaceEdit.documentChanges) { this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations); workspaceEdit.changeAnnotations = this._changeAnnotations.all(); workspaceEdit.documentChanges.forEach(function (change) { if (TextDocumentEdit.is(change)) { var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations); _this._textEditChanges[change.textDocument.uri] = textEditChange; } }); } else if (workspaceEdit.changes) { Object.keys(workspaceEdit.changes).forEach(function (key) { var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]); _this._textEditChanges[key] = textEditChange; }); } } else { this._workspaceEdit = {}; } } Object.defineProperty(WorkspaceChange.prototype, "edit", { /** * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal * use to be returned from a workspace edit operation like rename. */ get: function () { this.initDocumentChanges(); if (this._changeAnnotations !== undefined) { if (this._changeAnnotations.size === 0) { this._workspaceEdit.changeAnnotations = undefined; } else { this._workspaceEdit.changeAnnotations = this._changeAnnotations.all(); } } return this._workspaceEdit; }, enumerable: false, configurable: true }); WorkspaceChange.prototype.getTextEditChange = function (key) { if (OptionalVersionedTextDocumentIdentifier.is(key)) { this.initDocumentChanges(); if (this._workspaceEdit.documentChanges === undefined) { throw new Error('Workspace edit is not configured for document changes.'); } var textDocument = { uri: key.uri, version: key.version }; var result = this._textEditChanges[textDocument.uri]; if (!result) { var edits = []; var textDocumentEdit = { textDocument: textDocument, edits: edits }; this._workspaceEdit.documentChanges.push(textDocumentEdit); result = new TextEditChangeImpl(edits, this._changeAnnotations); this._textEditChanges[textDocument.uri] = result; } return result; } else { this.initChanges(); if (this._workspaceEdit.changes === undefined) { throw new Error('Workspace edit is not configured for normal text edit changes.'); } var result = this._textEditChanges[key]; if (!result) { var edits = []; this._workspaceEdit.changes[key] = edits; result = new TextEditChangeImpl(edits); this._textEditChanges[key] = result; } return result; } }; WorkspaceChange.prototype.initDocumentChanges = function () { if (this._workspaceEdit.documentChanges === undefined && this._workspaceEdit.changes === undefined) { this._changeAnnotations = new ChangeAnnotations(); this._workspaceEdit.documentChanges = []; this._workspaceEdit.changeAnnotations = this._changeAnnotations.all(); } }; WorkspaceChange.prototype.initChanges = function () { if (this._workspaceEdit.documentChanges === undefined && this._workspaceEdit.changes === undefined) { this._workspaceEdit.changes = Object.create(null); } }; WorkspaceChange.prototype.createFile = function (uri, optionsOrAnnotation, options) { this.initDocumentChanges(); if (this._workspaceEdit.documentChanges === undefined) { throw new Error('Workspace edit is not configured for document changes.'); } var annotation; if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) { annotation = optionsOrAnnotation; } else { options = optionsOrAnnotation; } var operation; var id; if (annotation === undefined) { operation = CreateFile.create(uri, options); } else { id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation); operation = CreateFile.create(uri, options, id); } this._workspaceEdit.documentChanges.push(operation); if (id !== undefined) { return id; } }; WorkspaceChange.prototype.renameFile = function (oldUri, newUri, optionsOrAnnotation, options) { this.initDocumentChanges(); if (this._workspaceEdit.documentChanges === undefined) { throw new Error('Workspace edit is not configured for document changes.'); } var annotation; if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) { annotation = optionsOrAnnotation; } else { options = optionsOrAnnotation; } var operation; var id; if (annotation === undefined) { operation = RenameFile.create(oldUri, newUri, options); } else { id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation); operation = RenameFile.create(oldUri, newUri, options, id); } this._workspaceEdit.documentChanges.push(operation); if (id !== undefined) { return id; } }; WorkspaceChange.prototype.deleteFile = function (uri, optionsOrAnnotation, options) { this.initDocumentChanges(); if (this._workspaceEdit.documentChanges === undefined) { throw new Error('Workspace edit is not configured for document changes.'); } var annotation; if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) { annotation = optionsOrAnnotation; } else { options = optionsOrAnnotation; } var operation; var id; if (annotation === undefined) { operation = DeleteFile.create(uri, options); } else { id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation); operation = DeleteFile.create(uri, options, id); } this._workspaceEdit.documentChanges.push(operation); if (id !== undefined) { return id; } }; return WorkspaceChange; }()); exports.WorkspaceChange = WorkspaceChange; /** * The TextDocumentIdentifier namespace provides helper functions to work with * [TextDocumentIdentifier](#TextDocumentIdentifier) literals. */ var TextDocumentIdentifier; (function (TextDocumentIdentifier) { /** * Creates a new TextDocumentIdentifier literal. * @param uri The document's uri. */ function create(uri) { return { uri: uri }; } TextDocumentIdentifier.create = create; /** * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Is.string(candidate.uri); } TextDocumentIdentifier.is = is; })(TextDocumentIdentifier = exports.TextDocumentIdentifier || (exports.TextDocumentIdentifier = {})); /** * The VersionedTextDocumentIdentifier namespace provides helper functions to work with * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals. */ var VersionedTextDocumentIdentifier; (function (VersionedTextDocumentIdentifier) { /** * Creates a new VersionedTextDocumentIdentifier literal. * @param uri The document's uri. * @param uri The document's text. */ function create(uri, version) { return { uri: uri, version: version }; } VersionedTextDocumentIdentifier.create = create; /** * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version); } VersionedTextDocumentIdentifier.is = is; })(VersionedTextDocumentIdentifier = exports.VersionedTextDocumentIdentifier || (exports.VersionedTextDocumentIdentifier = {})); /** * The OptionalVersionedTextDocumentIdentifier namespace provides helper functions to work with * [OptionalVersionedTextDocumentIdentifier](#OptionalVersionedTextDocumentIdentifier) literals. */ var OptionalVersionedTextDocumentIdentifier; (function (OptionalVersionedTextDocumentIdentifier) { /** * Creates a new OptionalVersionedTextDocumentIdentifier literal. * @param uri The document's uri. * @param uri The document's text. */ function create(uri, version) { return { uri: uri, version: version }; } OptionalVersionedTextDocumentIdentifier.create = create; /** * Checks whether the given literal conforms to the [OptionalVersionedTextDocumentIdentifier](#OptionalVersionedTextDocumentIdentifier) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version)); } OptionalVersionedTextDocumentIdentifier.is = is; })(OptionalVersionedTextDocumentIdentifier = exports.OptionalVersionedTextDocumentIdentifier || (exports.OptionalVersionedTextDocumentIdentifier = {})); /** * The TextDocumentItem namespace provides helper functions to work with * [TextDocumentItem](#TextDocumentItem) literals. */ var TextDocumentItem; (function (TextDocumentItem) { /** * Creates a new TextDocumentItem literal. * @param uri The document's uri. * @param languageId The document's language identifier. * @param version The document's version number. * @param text The document's text. */ function create(uri, languageId, version, text) { return { uri: uri, languageId: languageId, version: version, text: text }; } TextDocumentItem.create = create; /** * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text); } TextDocumentItem.is = is; })(TextDocumentItem = exports.TextDocumentItem || (exports.TextDocumentItem = {})); /** * Describes the content type that a client supports in various * result literals like `Hover`, `ParameterInfo` or `CompletionItem`. * * Please note that `MarkupKinds` must not start with a `$`. This kinds * are reserved for internal usage. */ var MarkupKind; (function (MarkupKind) { /** * Plain text is supported as a content format */ MarkupKind.PlainText = 'plaintext'; /** * Markdown is supported as a content format */ MarkupKind.Markdown = 'markdown'; })(MarkupKind = exports.MarkupKind || (exports.MarkupKind = {})); (function (MarkupKind) { /** * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type. */ function is(value) { var candidate = value; return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown; } MarkupKind.is = is; })(MarkupKind = exports.MarkupKind || (exports.MarkupKind = {})); var MarkupContent; (function (MarkupContent) { /** * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface. */ function is(value) { var candidate = value; return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value); } MarkupContent.is = is; })(MarkupContent = exports.MarkupContent || (exports.MarkupContent = {})); /** * The kind of a completion entry. */ var CompletionItemKind; (function (CompletionItemKind) { CompletionItemKind.Text = 1; CompletionItemKind.Method = 2; CompletionItemKind.Function = 3; CompletionItemKind.Constructor = 4; CompletionItemKind.Field = 5; CompletionItemKind.Variable = 6; CompletionItemKind.Class = 7; CompletionItemKind.Interface = 8; CompletionItemKind.Module = 9; CompletionItemKind.Property = 10; CompletionItemKind.Unit = 11; CompletionItemKind.Value = 12; CompletionItemKind.Enum = 13; CompletionItemKind.Keyword = 14; CompletionItemKind.Snippet = 15; CompletionItemKind.Color = 16; CompletionItemKind.File = 17; CompletionItemKind.Reference = 18; CompletionItemKind.Folder = 19; CompletionItemKind.EnumMember = 20; CompletionItemKind.Constant = 21; CompletionItemKind.Struct = 22; CompletionItemKind.Event = 23; CompletionItemKind.Operator = 24; CompletionItemKind.TypeParameter = 25; })(CompletionItemKind = exports.CompletionItemKind || (exports.CompletionItemKind = {})); /** * Defines whether the insert text in a completion item should be interpreted as * plain text or a snippet. */ var InsertTextFormat; (function (InsertTextFormat) { /** * The primary text to be inserted is treated as a plain string. */ InsertTextFormat.PlainText = 1; /** * The primary text to be inserted is treated as a snippet. * * A snippet can define tab stops and placeholders with `$1`, `$2` * and `${3:foo}`. `$0` defines the final tab stop, it defaults to * the end of the snippet. Placeholders with equal identifiers are linked, * that is typing in one will update others too. * * See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax */ InsertTextFormat.Snippet = 2; })(InsertTextFormat = exports.InsertTextFormat || (exports.InsertTextFormat = {})); /** * Completion item tags are extra annotations that tweak the rendering of a completion * item. * * @since 3.15.0 */ var CompletionItemTag; (function (CompletionItemTag) { /** * Render a completion as obsolete, usually using a strike-out. */ CompletionItemTag.Deprecated = 1; })(CompletionItemTag = exports.CompletionItemTag || (exports.CompletionItemTag = {})); /** * The InsertReplaceEdit namespace provides functions to deal with insert / replace edits. * * @since 3.16.0 */ var InsertReplaceEdit; (function (InsertReplaceEdit) { /** * Creates a new insert / replace edit */ function create(newText, insert, replace) { return { newText: newText, insert: insert, replace: replace }; } InsertReplaceEdit.create = create; /** * Checks whether the given literal conforms to the [InsertReplaceEdit](#InsertReplaceEdit) interface. */ function is(value) { var candidate = value; return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace); } InsertReplaceEdit.is = is; })(InsertReplaceEdit = exports.InsertReplaceEdit || (exports.InsertReplaceEdit = {})); /** * How whitespace and indentation is handled during completion * item insertion. * * @since 3.16.0 */ var InsertTextMode; (function (InsertTextMode) { /** * The insertion or replace strings is taken as it is. If the * value is multi line the lines below the cursor will be * inserted using the indentation defined in the string value. * The client will not apply any kind of adjustments to the * string. */ InsertTextMode.asIs = 1; /** * The editor adjusts leading whitespace of new lines so that * they match the indentation up to the cursor of the line for * which the item is accepted. * * Consider a line like this: <2tabs><3tabs>foo. Accepting a * multi line completion item is indented using 2 tabs and all * following lines inserted will be indented using 2 tabs as well. */ InsertTextMode.adjustIndentation = 2; })(InsertTextMode = exports.InsertTextMode || (exports.InsertTextMode = {})); /** * The CompletionItem namespace provides functions to deal with * completion items. */ var CompletionItem; (function (CompletionItem) { /** * Create a completion item and seed it with a label. * @param label The completion item's label */ function create(label) { return { label: label }; } CompletionItem.create = create; })(CompletionItem = exports.CompletionItem || (exports.CompletionItem = {})); /** * The CompletionList namespace provides functions to deal with * completion lists. */ var CompletionList; (function (CompletionList) { /** * Creates a new completion list. * * @param items The completion items. * @param isIncomplete The list is not complete. */ function create(items, isIncomplete) { return { items: items ? items : [], isIncomplete: !!isIncomplete }; } CompletionList.create = create; })(CompletionList = exports.CompletionList || (exports.CompletionList = {})); var MarkedString; (function (MarkedString) { /** * Creates a marked string from plain text. * * @param plainText The plain text. */ function fromPlainText(plainText) { return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash } MarkedString.fromPlainText = fromPlainText; /** * Checks whether the given value conforms to the [MarkedString](#MarkedString) type. */ function is(value) { var candidate = value; return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value)); } MarkedString.is = is; })(MarkedString = exports.MarkedString || (exports.MarkedString = {})); var Hover; (function (Hover) { /** * Checks whether the given value conforms to the [Hover](#Hover) interface. */ function is(value) { var candidate = value; return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === undefined || Range.is(value.range)); } Hover.is = is; })(Hover = exports.Hover || (exports.Hover = {})); /** * The ParameterInformation namespace provides helper functions to work with * [ParameterInformation](#ParameterInformation) literals. */ var ParameterInformation; (function (ParameterInformation) { /** * Creates a new parameter information literal. * * @param label A label string. * @param documentation A doc string. */ function create(label, documentation) { return documentation ? { label: label, documentation: documentation } : { label: label }; } ParameterInformation.create = create; })(ParameterInformation = exports.ParameterInformation || (exports.ParameterInformation = {})); /** * The SignatureInformation namespace provides helper functions to work with * [SignatureInformation](#SignatureInformation) literals. */ var SignatureInformation; (function (SignatureInformation) { function create(label, documentation) { var parameters = []; for (var _i = 2; _i < arguments.length; _i++) { parameters[_i - 2] = arguments[_i]; } var result = { label: label }; if (Is.defined(documentation)) { result.documentation = documentation; } if (Is.defined(parameters)) { result.parameters = parameters; } else { result.parameters = []; } return result; } SignatureInformation.create = create; })(SignatureInformation = exports.SignatureInformation || (exports.SignatureInformation = {})); /** * A document highlight kind. */ var DocumentHighlightKind; (function (DocumentHighlightKind) { /** * A textual occurrence. */ DocumentHighlightKind.Text = 1; /** * Read-access of a symbol, like reading a variable. */ DocumentHighlightKind.Read = 2; /** * Write-access of a symbol, like writing to a variable. */ DocumentHighlightKind.Write = 3; })(DocumentHighlightKind = exports.DocumentHighlightKind || (exports.DocumentHighlightKind = {})); /** * DocumentHighlight namespace to provide helper functions to work with * [DocumentHighlight](#DocumentHighlight) literals. */ var DocumentHighlight; (function (DocumentHighlight) { /** * Create a DocumentHighlight object. * @param range The range the highlight applies to. */ function create(range, kind) { var result = { range: range }; if (Is.number(kind)) { result.kind = kind; } return result; } DocumentHighlight.create = create; })(DocumentHighlight = exports.DocumentHighlight || (exports.DocumentHighlight = {})); /** * A symbol kind. */ var SymbolKind; (function (SymbolKind) { SymbolKind.File = 1; SymbolKind.Module = 2; SymbolKind.Namespace = 3; SymbolKind.Package = 4; SymbolKind.Class = 5; SymbolKind.Method = 6; SymbolKind.Property = 7; SymbolKind.Field = 8; SymbolKind.Constructor = 9; SymbolKind.Enum = 10; SymbolKind.Interface = 11; SymbolKind.Function = 12; SymbolKind.Variable = 13; SymbolKind.Constant = 14; SymbolKind.String = 15; SymbolKind.Number = 16; SymbolKind.Boolean = 17; SymbolKind.Array = 18; SymbolKind.Object = 19; SymbolKind.Key = 20; SymbolKind.Null = 21; SymbolKind.EnumMember = 22; SymbolKind.Struct = 23; SymbolKind.Event = 24; SymbolKind.Operator = 25; SymbolKind.TypeParameter = 26; })(SymbolKind = exports.SymbolKind || (exports.SymbolKind = {})); /** * Symbol tags are extra annotations that tweak the rendering of a symbol. * @since 3.16 */ var SymbolTag; (function (SymbolTag) { /** * Render a symbol as obsolete, usually using a strike-out. */ SymbolTag.Deprecated = 1; })(SymbolTag = exports.SymbolTag || (exports.SymbolTag = {})); var SymbolInformation; (function (SymbolInformation) { /** * Creates a new symbol information literal. * * @param name The name of the symbol. * @param kind The kind of the symbol. * @param range The range of the location of the symbol. * @param uri The resource of the location of symbol, defaults to the current document. * @param containerName The name of the symbol containing the symbol. */ function create(name, kind, range, uri, containerName) { var result = { name: name, kind: kind, location: { uri: uri, range: range } }; if (containerName) { result.containerName = containerName; } return result; } SymbolInformation.create = create; })(SymbolInformation = exports.SymbolInformation || (exports.SymbolInformation = {})); var DocumentSymbol; (function (DocumentSymbol) { /** * Creates a new symbol information literal. * * @param name The name of the symbol. * @param detail The detail of the symbol. * @param kind The kind of the symbol. * @param range The range of the symbol. * @param selectionRange The selectionRange of the symbol. * @param children Children of the symbol. */ function create(name, detail, kind, range, selectionRange, children) { var result = { name: name, detail: detail, kind: kind, range: range, selectionRange: selectionRange }; if (children !== undefined) { result.children = children; } return result; } DocumentSymbol.create = create; /** * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface. */ function is(value) { var candidate = value; return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range.is(candidate.range) && Range.is(candidate.selectionRange) && (candidate.detail === undefined || Is.string(candidate.detail)) && (candidate.deprecated === undefined || Is.boolean(candidate.deprecated)) && (candidate.children === undefined || Array.isArray(candidate.children)) && (candidate.tags === undefined || Array.isArray(candidate.tags)); } DocumentSymbol.is = is; })(DocumentSymbol = exports.DocumentSymbol || (exports.DocumentSymbol = {})); /** * A set of predefined code action kinds */ var CodeActionKind; (function (CodeActionKind) { /** * Empty kind. */ CodeActionKind.Empty = ''; /** * Base kind for quickfix actions: 'quickfix' */ CodeActionKind.QuickFix = 'quickfix'; /** * Base kind for refactoring actions: 'refactor' */ CodeActionKind.Refactor = 'refactor'; /** * Base kind for refactoring extraction actions: 'refactor.extract' * * Example extract actions: * * - Extract method * - Extract function * - Extract variable * - Extract interface from class * - ... */ CodeActionKind.RefactorExtract = 'refactor.extract'; /** * Base kind for refactoring inline actions: 'refactor.inline' * * Example inline actions: * * - Inline function * - Inline variable * - Inline constant * - ... */ CodeActionKind.RefactorInline = 'refactor.inline'; /** * Base kind for refactoring rewrite actions: 'refactor.rewrite' * * Example rewrite actions: * * - Convert JavaScript function to class * - Add or remove parameter * - Encapsulate field * - Make method static * - Move method to base class * - ... */ CodeActionKind.RefactorRewrite = 'refactor.rewrite'; /** * Base kind for source actions: `source` * * Source code actions apply to the entire file. */ CodeActionKind.Source = 'source'; /** * Base kind for an organize imports source action: `source.organizeImports` */ CodeActionKind.SourceOrganizeImports = 'source.organizeImports'; /** * Base kind for auto-fix source actions: `source.fixAll`. * * Fix all actions automatically fix errors that have a clear fix that do not require user input. * They should not suppress errors or perform unsafe fixes such as generating new types or classes. * * @since 3.15.0 */ CodeActionKind.SourceFixAll = 'source.fixAll'; })(CodeActionKind = exports.CodeActionKind || (exports.CodeActionKind = {})); /** * The CodeActionContext namespace provides helper functions to work with * [CodeActionContext](#CodeActionContext) literals. */ var CodeActionContext; (function (CodeActionContext) { /** * Creates a new CodeActionContext literal. */ function create(diagnostics, only) { var result = { diagnostics: diagnostics }; if (only !== undefined && only !== null) { result.only = only; } return result; } CodeActionContext.create = create; /** * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === undefined || Is.typedArray(candidate.only, Is.string)); } CodeActionContext.is = is; })(CodeActionContext = exports.CodeActionContext || (exports.CodeActionContext = {})); var CodeAction; (function (CodeAction) { function create(title, kindOrCommandOrEdit, kind) { var result = { title: title }; var checkKind = true; if (typeof kindOrCommandOrEdit === 'string') { checkKind = false; result.kind = kindOrCommandOrEdit; } else if (Command.is(kindOrCommandOrEdit)) { result.command = kindOrCommandOrEdit; } else { result.edit = kindOrCommandOrEdit; } if (checkKind && kind !== undefined) { result.kind = kind; } return result; } CodeAction.create = create; function is(value) { var candidate = value; return candidate && Is.string(candidate.title) && (candidate.diagnostics === undefined || Is.typedArray(candidate.diagnostics, Diagnostic.is)) && (candidate.kind === undefined || Is.string(candidate.kind)) && (candidate.edit !== undefined || candidate.command !== undefined) && (candidate.command === undefined || Command.is(candidate.command)) && (candidate.isPreferred === undefined || Is.boolean(candidate.isPreferred)) && (candidate.edit === undefined || WorkspaceEdit.is(candidate.edit)); } CodeAction.is = is; })(CodeAction = exports.CodeAction || (exports.CodeAction = {})); /** * The CodeLens namespace provides helper functions to work with * [CodeLens](#CodeLens) literals. */ var CodeLens; (function (CodeLens) { /** * Creates a new CodeLens literal. */ function create(range, data) { var result = { range: range }; if (Is.defined(data)) { result.data = data; } return result; } CodeLens.create = create; /** * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command)); } CodeLens.is = is; })(CodeLens = exports.CodeLens || (exports.CodeLens = {})); /** * The FormattingOptions namespace provides helper functions to work with * [FormattingOptions](#FormattingOptions) literals. */ var FormattingOptions; (function (FormattingOptions) { /** * Creates a new FormattingOptions literal. */ function create(tabSize, insertSpaces) { return { tabSize: tabSize, insertSpaces: insertSpaces }; } FormattingOptions.create = create; /** * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces); } FormattingOptions.is = is; })(FormattingOptions = exports.FormattingOptions || (exports.FormattingOptions = {})); /** * The DocumentLink namespace provides helper functions to work with * [DocumentLink](#DocumentLink) literals. */ var DocumentLink; (function (DocumentLink) { /** * Creates a new DocumentLink literal. */ function create(range, target, data) { return { range: range, target: target, data: data }; } DocumentLink.create = create; /** * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target)); } DocumentLink.is = is; })(DocumentLink = exports.DocumentLink || (exports.DocumentLink = {})); /** * The SelectionRange namespace provides helper function to work with * SelectionRange literals. */ var SelectionRange; (function (SelectionRange) { /** * Creates a new SelectionRange * @param range the range. * @param parent an optional parent. */ function create(range, parent) { return { range: range, parent: parent }; } SelectionRange.create = create; function is(value) { var candidate = value; return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent)); } SelectionRange.is = is; })(SelectionRange = exports.SelectionRange || (exports.SelectionRange = {})); exports.EOL = ['\n', '\r\n', '\r']; /** * @deprecated Use the text document from the new vscode-languageserver-textdocument package. */ var TextDocument; (function (TextDocument) { /** * Creates a new ITextDocument literal from the given uri and content. * @param uri The document's uri. * @param languageId The document's language Id. * @param content The document's content. */ function create(uri, languageId, version, content) { return new FullTextDocument(uri, languageId, version, content); } TextDocument.create = create; /** * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface. */ function is(value) { var candidate = value; return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.uinteger(candidate.lineCount) && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false; } TextDocument.is = is; function applyEdits(document, edits) { var text = document.getText(); var sortedEdits = mergeSort(edits, function (a, b) { var diff = a.range.start.line - b.range.start.line; if (diff === 0) { return a.range.start.character - b.range.start.character; } return diff; }); var lastModifiedOffset = text.length; for (var i = sortedEdits.length - 1; i >= 0; i--) { var e = sortedEdits[i]; var startOffset = document.offsetAt(e.range.start); var endOffset = document.offsetAt(e.range.end); if (endOffset <= lastModifiedOffset) { text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length); } else { throw new Error('Overlapping edit'); } lastModifiedOffset = startOffset; } return text; } TextDocument.applyEdits = applyEdits; function mergeSort(data, compare) { if (data.length <= 1) { // sorted return data; } var p = (data.length / 2) | 0; var left = data.slice(0, p); var right = data.slice(p); mergeSort(left, compare); mergeSort(right, compare); var leftIdx = 0; var rightIdx = 0; var i = 0; while (leftIdx < left.length && rightIdx < right.length) { var ret = compare(left[leftIdx], right[rightIdx]); if (ret <= 0) { // smaller_equal -> take left to preserve order data[i++] = left[leftIdx++]; } else { // greater -> take right data[i++] = right[rightIdx++]; } } while (leftIdx < left.length) { data[i++] = left[leftIdx++]; } while (rightIdx < right.length) { data[i++] = right[rightIdx++]; } return data; } })(TextDocument = exports.TextDocument || (exports.TextDocument = {})); /** * @deprecated Use the text document from the new vscode-languageserver-textdocument package. */ var FullTextDocument = /** @class */ (function () { function FullTextDocument(uri, languageId, version, content) { this._uri = uri; this._languageId = languageId; this._version = version; this._content = content; this._lineOffsets = undefined; } Object.defineProperty(FullTextDocument.prototype, "uri", { get: function () { return this._uri; }, enumerable: false, configurable: true }); Object.defineProperty(FullTextDocument.prototype, "languageId", { get: function () { return this._languageId; }, enumerable: false, configurable: true }); Object.defineProperty(FullTextDocument.prototype, "version", { get: function () { return this._version; }, enumerable: false, configurable: true }); FullTextDocument.prototype.getText = function (range) { if (range) { var start = this.offsetAt(range.start); var end = this.offsetAt(range.end); return this._content.substring(start, end); } return this._content; }; FullTextDocument.prototype.update = function (event, version) { this._content = event.text; this._version = version; this._lineOffsets = undefined; }; FullTextDocument.prototype.getLineOffsets = function () { if (this._lineOffsets === undefined) { var lineOffsets = []; var text = this._content; var isLineStart = true; for (var i = 0; i < text.length; i++) { if (isLineStart) { lineOffsets.push(i); isLineStart = false; } var ch = text.charAt(i); isLineStart = (ch === '\r' || ch === '\n'); if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') { i++; } } if (isLineStart && text.length > 0) { lineOffsets.push(text.length); } this._lineOffsets = lineOffsets; } return this._lineOffsets; }; FullTextDocument.prototype.positionAt = function (offset) { offset = Math.max(Math.min(offset, this._content.length), 0); var lineOffsets = this.getLineOffsets(); var low = 0, high = lineOffsets.length; if (high === 0) { return Position.create(0, offset); } while (low < high) { var mid = Math.floor((low + high) / 2); if (lineOffsets[mid] > offset) { high = mid; } else { low = mid + 1; } } // low is the least x for which the line offset is larger than the current offset // or array.length if no line offset is larger than the current offset var line = low - 1; return Position.create(line, offset - lineOffsets[line]); }; FullTextDocument.prototype.offsetAt = function (position) { var lineOffsets = this.getLineOffsets(); if (position.line >= lineOffsets.length) { return this._content.length; } else if (position.line < 0) { return 0; } var lineOffset = lineOffsets[position.line]; var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length; return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset); }; Object.defineProperty(FullTextDocument.prototype, "lineCount", { get: function () { return this.getLineOffsets().length; }, enumerable: false, configurable: true }); return FullTextDocument; }()); var Is; (function (Is) { var toString = Object.prototype.toString; function defined(value) { return typeof value !== 'undefined'; } Is.defined = defined; function undefined(value) { return typeof value === 'undefined'; } Is.undefined = undefined; function boolean(value) { return value === true || value === false; } Is.boolean = boolean; function string(value) { return toString.call(value) === '[object String]'; } Is.string = string; function number(value) { return toString.call(value) === '[object Number]'; } Is.number = number; function numberRange(value, min, max) { return toString.call(value) === '[object Number]' && min <= value && value <= max; } Is.numberRange = numberRange; function integer(value) { return toString.call(value) === '[object Number]' && -2147483648 <= value && value <= 2147483647; } Is.integer = integer; function uinteger(value) { return toString.call(value) === '[object Number]' && 0 <= value && value <= 2147483647; } Is.uinteger = uinteger; function func(value) { return toString.call(value) === '[object Function]'; } Is.func = func; function objectLiteral(value) { // Strictly speaking class instances pass this check as well. Since the LSP // doesn't use classes we ignore this for now. If we do we need to add something // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null` return value !== null && typeof value === 'object'; } Is.objectLiteral = objectLiteral; function typedArray(value, check) { return Array.isArray(value) && value.every(check); } Is.typedArray = typedArray; })(Is || (Is = {})); }); //# sourceMappingURL=main.js.map; define('vscode-languageserver-types', ['vscode-languageserver-types/main'], function (main) { return main; }); (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('vscode-languageserver-textdocument/main',["require", "exports"], 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 FullTextDocument = /** @class */ (function () { function FullTextDocument(uri, languageId, version, content) { this._uri = uri; this._languageId = languageId; this._version = version; this._content = content; this._lineOffsets = undefined; } Object.defineProperty(FullTextDocument.prototype, "uri", { get: function () { return this._uri; }, enumerable: true, configurable: true }); Object.defineProperty(FullTextDocument.prototype, "languageId", { get: function () { return this._languageId; }, enumerable: true, configurable: true }); Object.defineProperty(FullTextDocument.prototype, "version", { get: function () { return this._version; }, enumerable: true, configurable: true }); FullTextDocument.prototype.getText = function (range) { if (range) { var start = this.offsetAt(range.start); var end = this.offsetAt(range.end); return this._content.substring(start, end); } return this._content; }; FullTextDocument.prototype.update = function (changes, version) { for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) { var change = changes_1[_i]; if (FullTextDocument.isIncremental(change)) { // makes sure start is before end var range = getWellformedRange(change.range); // update content var startOffset = this.offsetAt(range.start); var endOffset = this.offsetAt(range.end); this._content = this._content.substring(0, startOffset) + change.text + this._content.substring(endOffset, this._content.length); // update the offsets var startLine = Math.max(range.start.line, 0); var endLine = Math.max(range.end.line, 0); var lineOffsets = this._lineOffsets; var addedLineOffsets = computeLineOffsets(change.text, false, startOffset); if (endLine - startLine === addedLineOffsets.length) { for (var i = 0, len = addedLineOffsets.length; i < len; i++) { lineOffsets[i + startLine + 1] = addedLineOffsets[i]; } } else { if (addedLineOffsets.length < 10000) { lineOffsets.splice.apply(lineOffsets, [startLine + 1, endLine - startLine].concat(addedLineOffsets)); } else { // avoid too many arguments for splice this._lineOffsets = lineOffsets = lineOffsets.slice(0, startLine + 1).concat(addedLineOffsets, lineOffsets.slice(endLine + 1)); } } var diff = change.text.length - (endOffset - startOffset); if (diff !== 0) { for (var i = startLine + 1 + addedLineOffsets.length, len = lineOffsets.length; i < len; i++) { lineOffsets[i] = lineOffsets[i] + diff; } } } else if (FullTextDocument.isFull(change)) { this._content = change.text; this._lineOffsets = undefined; } else { throw new Error('Unknown change event received'); } } this._version = version; }; FullTextDocument.prototype.getLineOffsets = function () { if (this._lineOffsets === undefined) { this._lineOffsets = computeLineOffsets(this._content, true); } return this._lineOffsets; }; FullTextDocument.prototype.positionAt = function (offset) { offset = Math.max(Math.min(offset, this._content.length), 0); var lineOffsets = this.getLineOffsets(); var low = 0, high = lineOffsets.length; if (high === 0) { return { line: 0, character: offset }; } while (low < high) { var mid = Math.floor((low + high) / 2); if (lineOffsets[mid] > offset) { high = mid; } else { low = mid + 1; } } // low is the least x for which the line offset is larger than the current offset // or array.length if no line offset is larger than the current offset var line = low - 1; return { line: line, character: offset - lineOffsets[line] }; }; FullTextDocument.prototype.offsetAt = function (position) { var lineOffsets = this.getLineOffsets(); if (position.line >= lineOffsets.length) { return this._content.length; } else if (position.line < 0) { return 0; } var lineOffset = lineOffsets[position.line]; var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length; return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset); }; Object.defineProperty(FullTextDocument.prototype, "lineCount", { get: function () { return this.getLineOffsets().length; }, enumerable: true, configurable: true }); FullTextDocument.isIncremental = function (event) { var candidate = event; return candidate !== undefined && candidate !== null && typeof candidate.text === 'string' && candidate.range !== undefined && (candidate.rangeLength === undefined || typeof candidate.rangeLength === 'number'); }; FullTextDocument.isFull = function (event) { var candidate = event; return candidate !== undefined && candidate !== null && typeof candidate.text === 'string' && candidate.range === undefined && candidate.rangeLength === undefined; }; return FullTextDocument; }()); var TextDocument; (function (TextDocument) { /** * Creates a new text document. * * @param uri The document's uri. * @param languageId The document's language Id. * @param version The document's initial version number. * @param content The document's content. */ function create(uri, languageId, version, content) { return new FullTextDocument(uri, languageId, version, content); } TextDocument.create = create; /** * Updates a TextDocument by modifing its content. * * @param document the document to update. Only documents created by TextDocument.create are valid inputs. * @param changes the changes to apply to the document. * @returns The updated TextDocument. Note: That's the same document instance passed in as first parameter. * */ function update(document, changes, version) { if (document instanceof FullTextDocument) { document.update(changes, version); return document; } else { throw new Error('TextDocument.update: document must be created by TextDocument.create'); } } TextDocument.update = update; function applyEdits(document, edits) { var text = document.getText(); var sortedEdits = mergeSort(edits.map(getWellformedEdit), function (a, b) { var diff = a.range.start.line - b.range.start.line; if (diff === 0) { return a.range.start.character - b.range.start.character; } return diff; }); var lastModifiedOffset = 0; var spans = []; for (var _i = 0, sortedEdits_1 = sortedEdits; _i < sortedEdits_1.length; _i++) { var e = sortedEdits_1[_i]; var startOffset = document.offsetAt(e.range.start); if (startOffset < lastModifiedOffset) { throw new Error('Overlapping edit'); } else if (startOffset > lastModifiedOffset) { spans.push(text.substring(lastModifiedOffset, startOffset)); } if (e.newText.length) { spans.push(e.newText); } lastModifiedOffset = document.offsetAt(e.range.end); } spans.push(text.substr(lastModifiedOffset)); return spans.join(''); } TextDocument.applyEdits = applyEdits; })(TextDocument = exports.TextDocument || (exports.TextDocument = {})); function mergeSort(data, compare) { if (data.length <= 1) { // sorted return data; } var p = (data.length / 2) | 0; var left = data.slice(0, p); var right = data.slice(p); mergeSort(left, compare); mergeSort(right, compare); var leftIdx = 0; var rightIdx = 0; var i = 0; while (leftIdx < left.length && rightIdx < right.length) { var ret = compare(left[leftIdx], right[rightIdx]); if (ret <= 0) { // smaller_equal -> take left to preserve order data[i++] = left[leftIdx++]; } else { // greater -> take right data[i++] = right[rightIdx++]; } } while (leftIdx < left.length) { data[i++] = left[leftIdx++]; } while (rightIdx < right.length) { data[i++] = right[rightIdx++]; } return data; } function computeLineOffsets(text, isAtLineStart, textOffset) { if (textOffset === void 0) { textOffset = 0; } var result = isAtLineStart ? [textOffset] : []; for (var i = 0; i < text.length; i++) { var ch = text.charCodeAt(i); if (ch === 13 /* CarriageReturn */ || ch === 10 /* LineFeed */) { if (ch === 13 /* CarriageReturn */ && i + 1 < text.length && text.charCodeAt(i + 1) === 10 /* LineFeed */) { i++; } result.push(textOffset + i + 1); } } return result; } function getWellformedRange(range) { var start = range.start; var end = range.end; if (start.line > end.line || (start.line === end.line && start.character > end.character)) { return { start: end, end: start }; } return range; } function getWellformedEdit(textEdit) { var range = getWellformedRange(textEdit.range); if (range !== textEdit.range) { return { newText: textEdit.newText, range: range }; } return textEdit; } }); define('vscode-languageserver-textdocument', ['vscode-languageserver-textdocument/main'], function (main) { return main; }); (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('vscode-css-languageservice/cssLanguageTypes',["require", "exports", "vscode-languageserver-types", "vscode-languageserver-textdocument"], 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 }); exports.FileType = exports.ClientCapabilities = exports.DocumentHighlightKind = exports.VersionedTextDocumentIdentifier = exports.TextDocumentEdit = exports.CodeActionKind = exports.TextEdit = exports.WorkspaceEdit = exports.DocumentLink = exports.DocumentHighlight = exports.CodeAction = exports.Command = exports.CodeActionContext = exports.MarkedString = exports.Hover = exports.Location = exports.DocumentSymbol = exports.SymbolKind = exports.SymbolInformation = exports.InsertTextFormat = exports.CompletionItemTag = exports.CompletionList = exports.CompletionItemKind = exports.CompletionItem = exports.DiagnosticSeverity = exports.Diagnostic = exports.SelectionRange = exports.FoldingRangeKind = exports.FoldingRange = exports.ColorPresentation = exports.ColorInformation = exports.Color = exports.MarkupKind = exports.MarkupContent = exports.Position = exports.Range = exports.TextDocument = void 0; var vscode_languageserver_types_1 = require("vscode-languageserver-types"); Object.defineProperty(exports, "Range", { enumerable: true, get: function () { return vscode_languageserver_types_1.Range; } }); Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return vscode_languageserver_types_1.Position; } }); Object.defineProperty(exports, "MarkupContent", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkupContent; } }); Object.defineProperty(exports, "MarkupKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkupKind; } }); Object.defineProperty(exports, "Color", { enumerable: true, get: function () { return vscode_languageserver_types_1.Color; } }); Object.defineProperty(exports, "ColorInformation", { enumerable: true, get: function () { return vscode_languageserver_types_1.ColorInformation; } }); Object.defineProperty(exports, "ColorPresentation", { enumerable: true, get: function () { return vscode_languageserver_types_1.ColorPresentation; } }); Object.defineProperty(exports, "FoldingRange", { enumerable: true, get: function () { return vscode_languageserver_types_1.FoldingRange; } }); Object.defineProperty(exports, "FoldingRangeKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.FoldingRangeKind; } }); Object.defineProperty(exports, "SelectionRange", { enumerable: true, get: function () { return vscode_languageserver_types_1.SelectionRange; } }); Object.defineProperty(exports, "Diagnostic", { enumerable: true, get: function () { return vscode_languageserver_types_1.Diagnostic; } }); Object.defineProperty(exports, "DiagnosticSeverity", { enumerable: true, get: function () { return vscode_languageserver_types_1.DiagnosticSeverity; } }); Object.defineProperty(exports, "CompletionItem", { enumerable: true, get: function () { return vscode_languageserver_types_1.CompletionItem; } }); Object.defineProperty(exports, "CompletionItemKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.CompletionItemKind; } }); Object.defineProperty(exports, "CompletionList", { enumerable: true, get: function () { return vscode_languageserver_types_1.CompletionList; } }); Object.defineProperty(exports, "CompletionItemTag", { enumerable: true, get: function () { return vscode_languageserver_types_1.CompletionItemTag; } }); Object.defineProperty(exports, "InsertTextFormat", { enumerable: true, get: function () { return vscode_languageserver_types_1.InsertTextFormat; } }); Object.defineProperty(exports, "SymbolInformation", { enumerable: true, get: function () { return vscode_languageserver_types_1.SymbolInformation; } }); Object.defineProperty(exports, "SymbolKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.SymbolKind; } }); Object.defineProperty(exports, "DocumentSymbol", { enumerable: true, get: function () { return vscode_languageserver_types_1.DocumentSymbol; } }); Object.defineProperty(exports, "Location", { enumerable: true, get: function () { return vscode_languageserver_types_1.Location; } }); Object.defineProperty(exports, "Hover", { enumerable: true, get: function () { return vscode_languageserver_types_1.Hover; } }); Object.defineProperty(exports, "MarkedString", { enumerable: true, get: function () { return vscode_languageserver_types_1.MarkedString; } }); Object.defineProperty(exports, "CodeActionContext", { enumerable: true, get: function () { return vscode_languageserver_types_1.CodeActionContext; } }); Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return vscode_languageserver_types_1.Command; } }); Object.defineProperty(exports, "CodeAction", { enumerable: true, get: function () { return vscode_languageserver_types_1.CodeAction; } }); Object.defineProperty(exports, "DocumentHighlight", { enumerable: true, get: function () { return vscode_languageserver_types_1.DocumentHighlight; } }); Object.defineProperty(exports, "DocumentLink", { enumerable: true, get: function () { return vscode_languageserver_types_1.DocumentLink; } }); Object.defineProperty(exports, "WorkspaceEdit", { enumerable: true, get: function () { return vscode_languageserver_types_1.WorkspaceEdit; } }); Object.defineProperty(exports, "TextEdit", { enumerable: true, get: function () { return vscode_languageserver_types_1.TextEdit; } }); Object.defineProperty(exports, "CodeActionKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.CodeActionKind; } }); Object.defineProperty(exports, "TextDocumentEdit", { enumerable: true, get: function () { return vscode_languageserver_types_1.TextDocumentEdit; } }); Object.defineProperty(exports, "VersionedTextDocumentIdentifier", { enumerable: true, get: function () { return vscode_languageserver_types_1.VersionedTextDocumentIdentifier; } }); Object.defineProperty(exports, "DocumentHighlightKind", { enumerable: true, get: function () { return vscode_languageserver_types_1.DocumentHighlightKind; } }); var vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument"); Object.defineProperty(exports, "TextDocument", { enumerable: true, get: function () { return vscode_languageserver_textdocument_1.TextDocument; } }); var ClientCapabilities; (function (ClientCapabilities) { ClientCapabilities.LATEST = { textDocument: { completion: { completionItem: { documentationFormat: [vscode_languageserver_types_1.MarkupKind.Markdown, vscode_languageserver_types_1.MarkupKind.PlainText] } }, hover: { contentFormat: [vscode_languageserver_types_1.MarkupKind.Markdown, vscode_languageserver_types_1.MarkupKind.PlainText] } } }; })(ClientCapabilities = exports.ClientCapabilities || (exports.ClientCapabilities = {})); var FileType; (function (FileType) { /** * The file type is unknown. */ FileType[FileType["Unknown"] = 0] = "Unknown"; /** * A regular file. */ FileType[FileType["File"] = 1] = "File"; /** * A directory. */ FileType[FileType["Directory"] = 2] = "Directory"; /** * A symbolic link to a file. */ FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink"; })(FileType = exports.FileType || (exports.FileType = {})); }); !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define('vscode-uri/index',[],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(this,(function(){return(()=>{"use strict";var t={470:t=>{function e(t){if("string"!=typeof t)throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}function r(t,e){for(var r,n="",i=0,o=-1,a=0,h=0;h<=t.length;++h){if(h2){var s=n.lastIndexOf("/");if(s!==n.length-1){-1===s?(n="",i=0):i=(n=n.slice(0,s)).length-1-n.lastIndexOf("/"),o=h,a=0;continue}}else if(2===n.length||1===n.length){n="",i=0,o=h,a=0;continue}e&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+t.slice(o+1,h):n=t.slice(o+1,h),i=h-o-1;o=h,a=0}else 46===r&&-1!==a?++a:a=-1}return n}var n={resolve:function(){for(var t,n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var a;o>=0?a=arguments[o]:(void 0===t&&(t=process.cwd()),a=t),e(a),0!==a.length&&(n=a+"/"+n,i=47===a.charCodeAt(0))}return n=r(n,!i),i?n.length>0?"/"+n:"/":n.length>0?n:"."},normalize:function(t){if(e(t),0===t.length)return".";var n=47===t.charCodeAt(0),i=47===t.charCodeAt(t.length-1);return 0!==(t=r(t,!n)).length||n||(t="."),t.length>0&&i&&(t+="/"),n?"/"+t:t},isAbsolute:function(t){return e(t),t.length>0&&47===t.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var t,r=0;r0&&(void 0===t?t=i:t+="/"+i)}return void 0===t?".":n.normalize(t)},relative:function(t,r){if(e(t),e(r),t===r)return"";if((t=n.resolve(t))===(r=n.resolve(r)))return"";for(var i=1;if){if(47===r.charCodeAt(h+c))return r.slice(h+c+1);if(0===c)return r.slice(h+c)}else a>f&&(47===t.charCodeAt(i+c)?u=c:0===c&&(u=0));break}var l=t.charCodeAt(i+c);if(l!==r.charCodeAt(h+c))break;47===l&&(u=c)}var p="";for(c=i+u+1;c<=o;++c)c!==o&&47!==t.charCodeAt(c)||(0===p.length?p+="..":p+="/..");return p.length>0?p+r.slice(h+u):(h+=u,47===r.charCodeAt(h)&&++h,r.slice(h))},_makeLong:function(t){return t},dirname:function(t){if(e(t),0===t.length)return".";for(var r=t.charCodeAt(0),n=47===r,i=-1,o=!0,a=t.length-1;a>=1;--a)if(47===(r=t.charCodeAt(a))){if(!o){i=a;break}}else o=!1;return-1===i?n?"/":".":n&&1===i?"//":t.slice(0,i)},basename:function(t,r){if(void 0!==r&&"string"!=typeof r)throw new TypeError('"ext" argument must be a string');e(t);var n,i=0,o=-1,a=!0;if(void 0!==r&&r.length>0&&r.length<=t.length){if(r.length===t.length&&r===t)return"";var h=r.length-1,s=-1;for(n=t.length-1;n>=0;--n){var f=t.charCodeAt(n);if(47===f){if(!a){i=n+1;break}}else-1===s&&(a=!1,s=n+1),h>=0&&(f===r.charCodeAt(h)?-1==--h&&(o=n):(h=-1,o=s))}return i===o?o=s:-1===o&&(o=t.length),t.slice(i,o)}for(n=t.length-1;n>=0;--n)if(47===t.charCodeAt(n)){if(!a){i=n+1;break}}else-1===o&&(a=!1,o=n+1);return-1===o?"":t.slice(i,o)},extname:function(t){e(t);for(var r=-1,n=0,i=-1,o=!0,a=0,h=t.length-1;h>=0;--h){var s=t.charCodeAt(h);if(47!==s)-1===i&&(o=!1,i=h+1),46===s?-1===r?r=h:1!==a&&(a=1):-1!==r&&(a=-1);else if(!o){n=h+1;break}}return-1===r||-1===i||0===a||1===a&&r===i-1&&r===n+1?"":t.slice(r,i)},format:function(t){if(null===t||"object"!=typeof t)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return function(t,e){var r=e.dir||e.root,n=e.base||(e.name||"")+(e.ext||"");return r?r===e.root?r+n:r+"/"+n:n}(0,t)},parse:function(t){e(t);var r={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return r;var n,i=t.charCodeAt(0),o=47===i;o?(r.root="/",n=1):n=0;for(var a=-1,h=0,s=-1,f=!0,u=t.length-1,c=0;u>=n;--u)if(47!==(i=t.charCodeAt(u)))-1===s&&(f=!1,s=u+1),46===i?-1===a?a=u:1!==c&&(c=1):-1!==a&&(c=-1);else if(!f){h=u+1;break}return-1===a||-1===s||0===c||1===c&&a===s-1&&a===h+1?-1!==s&&(r.base=r.name=0===h&&o?t.slice(1,s):t.slice(h,s)):(0===h&&o?(r.name=t.slice(1,a),r.base=t.slice(1,s)):(r.name=t.slice(h,a),r.base=t.slice(h,s)),r.ext=t.slice(a,s)),h>0?r.dir=t.slice(0,h-1):o&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};n.posix=n,t.exports=n},465:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Utils=e.URI=void 0;var n=r(796);Object.defineProperty(e,"URI",{enumerable:!0,get:function(){return n.URI}});var i=r(679);Object.defineProperty(e,"Utils",{enumerable:!0,get:function(){return i.Utils}})},674:(t,e)=>{if(Object.defineProperty(e,"__esModule",{value:!0}),e.isWindows=void 0,"object"==typeof process)e.isWindows="win32"===process.platform;else if("object"==typeof navigator){var r=navigator.userAgent;e.isWindows=r.indexOf("Windows")>=0}},796:function(t,e,r){var n,i,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.uriToFsPath=e.URI=void 0;var a=r(674),h=/^\w[\w\d+.-]*$/,s=/^\//,f=/^\/\//,u="",c="/",l=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,p=function(){function t(t,e,r,n,i,o){void 0===o&&(o=!1),"object"==typeof t?(this.scheme=t.scheme||u,this.authority=t.authority||u,this.path=t.path||u,this.query=t.query||u,this.fragment=t.fragment||u):(this.scheme=function(t,e){return t||e?t:"file"}(t,o),this.authority=e||u,this.path=function(t,e){switch(t){case"https":case"http":case"file":e?e[0]!==c&&(e=c+e):e=c}return e}(this.scheme,r||u),this.query=n||u,this.fragment=i||u,function(t,e){if(!t.scheme&&e)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'+t.authority+'", path: "'+t.path+'", query: "'+t.query+'", fragment: "'+t.fragment+'"}');if(t.scheme&&!h.test(t.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(t.path)if(t.authority){if(!s.test(t.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(f.test(t.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,o))}return t.isUri=function(e){return e instanceof t||!!e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString},Object.defineProperty(t.prototype,"fsPath",{get:function(){return b(this,!1)},enumerable:!1,configurable:!0}),t.prototype.with=function(t){if(!t)return this;var e=t.scheme,r=t.authority,n=t.path,i=t.query,o=t.fragment;return void 0===e?e=this.scheme:null===e&&(e=u),void 0===r?r=this.authority:null===r&&(r=u),void 0===n?n=this.path:null===n&&(n=u),void 0===i?i=this.query:null===i&&(i=u),void 0===o?o=this.fragment:null===o&&(o=u),e===this.scheme&&r===this.authority&&n===this.path&&i===this.query&&o===this.fragment?this:new g(e,r,n,i,o)},t.parse=function(t,e){void 0===e&&(e=!1);var r=l.exec(t);return r?new g(r[2]||u,_(r[4]||u),_(r[5]||u),_(r[7]||u),_(r[9]||u),e):new g(u,u,u,u,u)},t.file=function(t){var e=u;if(a.isWindows&&(t=t.replace(/\\/g,c)),t[0]===c&&t[1]===c){var r=t.indexOf(c,2);-1===r?(e=t.substring(2),t=c):(e=t.substring(2,r),t=t.substring(r)||c)}return new g("file",e,t,u,u)},t.from=function(t){return new g(t.scheme,t.authority,t.path,t.query,t.fragment)},t.prototype.toString=function(t){return void 0===t&&(t=!1),C(this,t)},t.prototype.toJSON=function(){return this},t.revive=function(e){if(e){if(e instanceof t)return e;var r=new g(e);return r._formatted=e.external,r._fsPath=e._sep===d?e.fsPath:null,r}return e},t}();e.URI=p;var d=a.isWindows?1:void 0,g=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._formatted=null,e._fsPath=null,e}return o(e,t),Object.defineProperty(e.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=b(this,!1)),this._fsPath},enumerable:!1,configurable:!0}),e.prototype.toString=function(t){return void 0===t&&(t=!1),t?C(this,!0):(this._formatted||(this._formatted=C(this,!1)),this._formatted)},e.prototype.toJSON=function(){var t={$mid:1};return this._fsPath&&(t.fsPath=this._fsPath,t._sep=d),this._formatted&&(t.external=this._formatted),this.path&&(t.path=this.path),this.scheme&&(t.scheme=this.scheme),this.authority&&(t.authority=this.authority),this.query&&(t.query=this.query),this.fragment&&(t.fragment=this.fragment),t},e}(p),v=((i={})[58]="%3A",i[47]="%2F",i[63]="%3F",i[35]="%23",i[91]="%5B",i[93]="%5D",i[64]="%40",i[33]="%21",i[36]="%24",i[38]="%26",i[39]="%27",i[40]="%28",i[41]="%29",i[42]="%2A",i[43]="%2B",i[44]="%2C",i[59]="%3B",i[61]="%3D",i[32]="%20",i);function m(t,e){for(var r=void 0,n=-1,i=0;i=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||45===o||46===o||95===o||126===o||e&&47===o)-1!==n&&(r+=encodeURIComponent(t.substring(n,i)),n=-1),void 0!==r&&(r+=t.charAt(i));else{void 0===r&&(r=t.substr(0,i));var a=v[o];void 0!==a?(-1!==n&&(r+=encodeURIComponent(t.substring(n,i)),n=-1),r+=a):-1===n&&(n=i)}}return-1!==n&&(r+=encodeURIComponent(t.substring(n))),void 0!==r?r:t}function y(t){for(var e=void 0,r=0;r1&&"file"===t.scheme?"//"+t.authority+t.path:47===t.path.charCodeAt(0)&&(t.path.charCodeAt(1)>=65&&t.path.charCodeAt(1)<=90||t.path.charCodeAt(1)>=97&&t.path.charCodeAt(1)<=122)&&58===t.path.charCodeAt(2)?e?t.path.substr(1):t.path[1].toLowerCase()+t.path.substr(2):t.path,a.isWindows&&(r=r.replace(/\//g,"\\")),r}function C(t,e){var r=e?y:m,n="",i=t.scheme,o=t.authority,a=t.path,h=t.query,s=t.fragment;if(i&&(n+=i,n+=":"),(o||"file"===i)&&(n+=c,n+=c),o){var f=o.indexOf("@");if(-1!==f){var u=o.substr(0,f);o=o.substr(f+1),-1===(f=u.indexOf(":"))?n+=r(u,!1):(n+=r(u.substr(0,f),!1),n+=":",n+=r(u.substr(f+1),!1)),n+="@"}-1===(f=(o=o.toLowerCase()).indexOf(":"))?n+=r(o,!1):(n+=r(o.substr(0,f),!1),n+=o.substr(f))}if(a){if(a.length>=3&&47===a.charCodeAt(0)&&58===a.charCodeAt(2))(l=a.charCodeAt(1))>=65&&l<=90&&(a="/"+String.fromCharCode(l+32)+":"+a.substr(3));else if(a.length>=2&&58===a.charCodeAt(1)){var l;(l=a.charCodeAt(0))>=65&&l<=90&&(a=String.fromCharCode(l+32)+":"+a.substr(2))}n+=r(a,!0)}return h&&(n+="?",n+=r(h,!1)),s&&(n+="#",n+=e?s:m(s,!1)),n}function A(t){try{return decodeURIComponent(t)}catch(e){return t.length>3?t.substr(0,3)+A(t.substr(3)):t}}e.uriToFsPath=b;var w=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function _(t){return t.match(w)?t.replace(w,(function(t){return A(t)})):t}},679:function(t,e,r){var n=this&&this.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; (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('vscode-css-languageservice/services/pathCompletion',["require", "exports", "../cssLanguageTypes", "../utils/strings", "../utils/resources"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PathCompletionParticipant = void 0; var cssLanguageTypes_1 = require("../cssLanguageTypes"); var strings_1 = require("../utils/strings"); var resources_1 = require("../utils/resources"); var PathCompletionParticipant = /** @class */ (function () { function PathCompletionParticipant(readDirectory) { this.readDirectory = readDirectory; this.literalCompletions = []; this.importCompletions = []; } PathCompletionParticipant.prototype.onCssURILiteralValue = function (context) { this.literalCompletions.push(context); }; PathCompletionParticipant.prototype.onCssImportPath = function (context) { this.importCompletions.push(context); }; PathCompletionParticipant.prototype.computeCompletions = function (document, documentContext) { return __awaiter(this, void 0, void 0, function () { var result, _i, _a, literalCompletion, uriValue, fullValue, items, _b, items_1, item, _c, _d, importCompletion, pathValue, fullValue, suggestions, _e, suggestions_1, item; return __generator(this, function (_f) { switch (_f.label) { case 0: result = { items: [], isIncomplete: false }; _i = 0, _a = this.literalCompletions; _f.label = 1; case 1: if (!(_i < _a.length)) return [3 /*break*/, 5]; literalCompletion = _a[_i]; uriValue = literalCompletion.uriValue; fullValue = stripQuotes(uriValue); if (!(fullValue === '.' || fullValue === '..')) return [3 /*break*/, 2]; result.isIncomplete = true; return [3 /*break*/, 4]; case 2: return [4 /*yield*/, this.providePathSuggestions(uriValue, literalCompletion.position, literalCompletion.range, document, documentContext)]; case 3: items = _f.sent(); for (_b = 0, items_1 = items; _b < items_1.length; _b++) { item = items_1[_b]; result.items.push(item); } _f.label = 4; case 4: _i++; return [3 /*break*/, 1]; case 5: _c = 0, _d = this.importCompletions; _f.label = 6; case 6: if (!(_c < _d.length)) return [3 /*break*/, 10]; importCompletion = _d[_c]; pathValue = importCompletion.pathValue; fullValue = stripQuotes(pathValue); if (!(fullValue === '.' || fullValue === '..')) return [3 /*break*/, 7]; result.isIncomplete = true; return [3 /*break*/, 9]; case 7: return [4 /*yield*/, this.providePathSuggestions(pathValue, importCompletion.position, importCompletion.range, document, documentContext)]; case 8: suggestions = _f.sent(); if (document.languageId === 'scss') { suggestions.forEach(function (s) { if ((0, strings_1.startsWith)(s.label, '_') && (0, strings_1.endsWith)(s.label, '.scss')) { if (s.textEdit) { s.textEdit.newText = s.label.slice(1, -5); } else { s.label = s.label.slice(1, -5); } } }); } for (_e = 0, suggestions_1 = suggestions; _e < suggestions_1.length; _e++) { item = suggestions_1[_e]; result.items.push(item); } _f.label = 9; case 9: _c++; return [3 /*break*/, 6]; case 10: return [2 /*return*/, result]; } }); }); }; PathCompletionParticipant.prototype.providePathSuggestions = function (pathValue, position, range, document, documentContext) { return __awaiter(this, void 0, void 0, function () { var fullValue, isValueQuoted, valueBeforeCursor, currentDocUri, fullValueRange, replaceRange, valueBeforeLastSlash, parentDir, result, infos, _i, infos_1, _a, name, type, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: fullValue = stripQuotes(pathValue); isValueQuoted = (0, strings_1.startsWith)(pathValue, "'") || (0, strings_1.startsWith)(pathValue, "\""); valueBeforeCursor = isValueQuoted ? fullValue.slice(0, position.character - (range.start.character + 1)) : fullValue.slice(0, position.character - range.start.character); currentDocUri = document.uri; fullValueRange = isValueQuoted ? shiftRange(range, 1, -1) : range; replaceRange = pathToReplaceRange(valueBeforeCursor, fullValue, fullValueRange); valueBeforeLastSlash = valueBeforeCursor.substring(0, valueBeforeCursor.lastIndexOf('/') + 1); parentDir = documentContext.resolveReference(valueBeforeLastSlash || '.', currentDocUri); if (!parentDir) return [3 /*break*/, 4]; _b.label = 1; case 1: _b.trys.push([1, 3, , 4]); result = []; return [4 /*yield*/, this.readDirectory(parentDir)]; case 2: infos = _b.sent(); for (_i = 0, infos_1 = infos; _i < infos_1.length; _i++) { _a = infos_1[_i], name = _a[0], type = _a[1]; // Exclude paths that start with `.` if (name.charCodeAt(0) !== CharCode_dot && (type === cssLanguageTypes_1.FileType.Directory || (0, resources_1.joinPath)(parentDir, name) !== currentDocUri)) { result.push(createCompletionItem(name, type === cssLanguageTypes_1.FileType.Directory, replaceRange)); } } return [2 /*return*/, result]; case 3: e_1 = _b.sent(); return [3 /*break*/, 4]; case 4: return [2 /*return*/, []]; } }); }); }; return PathCompletionParticipant; }()); exports.PathCompletionParticipant = PathCompletionParticipant; var CharCode_dot = '.'.charCodeAt(0); function stripQuotes(fullValue) { if ((0, strings_1.startsWith)(fullValue, "'") || (0, strings_1.startsWith)(fullValue, "\"")) { return fullValue.slice(1, -1); } else { return fullValue; } } function pathToReplaceRange(valueBeforeCursor, fullValue, fullValueRange) { var replaceRange; var lastIndexOfSlash = valueBeforeCursor.lastIndexOf('/'); if (lastIndexOfSlash === -1) { replaceRange = fullValueRange; } else { // For cases where cursor is in the middle of attribute value, like