UNPKG

monaco-sqlpad-test

Version:

![preview.gif](https://upload-images.jianshu.io/upload_images/11287122-31aabe9832be213f.gif?imageMogr2/auto-orient/strip)

1,330 lines (1,304 loc) 1.4 MB
((typeof self !== 'undefined' ? self : this)["webpackJsonpmonaco_sqlpad"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpmonaco_sqlpad"] || []).push([[3],{ /***/ "db4f": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, "setupMode", function() { return /* binding */ setupMode; }); // CONCATENATED MODULE: ./node_modules/monaco-editor/esm/vs/language/css/workerManager.js /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 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.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: { languageSettings: this._defaults.diagnosticsOptions, 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; }()); // CONCATENATED MODULE: ./node_modules/monaco-editor/esm/vs/language/css/_deps/vscode-css-languageservice/parser/cssScanner.js /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 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 || (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; }()); var cssScanner_a = 'a'.charCodeAt(0); var cssScanner_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([_LAN, _BNG, _MIN, _MIN])) { return this.finishToken(offset, TokenType.CDO); } // CDC --> 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._matchWordAnyCase = function (characters) { var index = 0; this.stream.advanceWhileChar(function (ch) { var result = characters[index] === ch || characters[index + 1] === ch; if (result) { index += 2; } return result; }); if (index === characters.length) { return true; } else { this.stream.goBack(index / 2); return false; } }; 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 >= cssScanner_a && ch <= cssScanner_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 >= cssScanner_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 >= cssScanner_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; }()); // CONCATENATED MODULE: ./node_modules/monaco-editor/esm/vs/language/css/_deps/vscode-css-languageservice/parser/cssNodes.js /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ var __extends = (undefined && undefined.__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 (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); /// <summary> /// Nodes for the css 2.1 specification. See for reference: /// http://www.w3.org/TR/CSS21/grammar.html#grammar /// </summary> 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["MixinContent"] = 48] = "MixinContent"; NodeType[NodeType["Media"] = 49] = "Media"; NodeType[NodeType["Keyframe"] = 50] = "Keyframe"; NodeType[NodeType["FontFace"] = 51] = "FontFace"; NodeType[NodeType["Import"] = 52] = "Import"; NodeType[NodeType["Namespace"] = 53] = "Namespace"; NodeType[NodeType["Invocation"] = 54] = "Invocation"; NodeType[NodeType["FunctionDeclaration"] = 55] = "FunctionDeclaration"; NodeType[NodeType["ReturnStatement"] = 56] = "ReturnStatement"; NodeType[NodeType["MediaQuery"] = 57] = "MediaQuery"; NodeType[NodeType["FunctionParameter"] = 58] = "FunctionParameter"; NodeType[NodeType["FunctionArgument"] = 59] = "FunctionArgument"; NodeType[NodeType["KeyframeSelector"] = 60] = "KeyframeSelector"; NodeType[NodeType["ViewPort"] = 61] = "ViewPort"; NodeType[NodeType["Document"] = 62] = "Document"; NodeType[NodeType["AtApplyRule"] = 63] = "AtApplyRule"; NodeType[NodeType["CustomPropertyDeclaration"] = 64] = "CustomPropertyDeclaration"; NodeType[NodeType["CustomPropertySet"] = 65] = "CustomPropertySet"; NodeType[NodeType["ListEntry"] = 66] = "ListEntry"; NodeType[NodeType["Supports"] = 67] = "Supports"; NodeType[NodeType["SupportsCondition"] = 68] = "SupportsCondition"; NodeType[NodeType["NamespacePrefix"] = 69] = "NamespacePrefix"; NodeType[NodeType["GridLine"] = 70] = "GridLine"; NodeType[NodeType["Plugin"] = 71] = "Plugin"; NodeType[NodeType["UnknownAtRule"] = 72] = "UnknownAtRule"; NodeType[NodeType["Use"] = 73] = "Use"; NodeType[NodeType["ModuleConfiguration"] = 74] = "ModuleConfiguration"; NodeType[NodeType["Forward"] = 75] = "Forward"; NodeType[NodeType["ForwardVisibility"] = 76] = "ForwardVisibility"; NodeType[NodeType["Module"] = 77] = "Module"; })(NodeType || (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 || (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; } function getNodePath(node, offset) { var candidate = getNodeAtOffset(node, offset); var path = []; while (candidate) { path.unshift(candidate); candidate = candidate.parent; } return path; } function getParentDeclaration(node) { var decl = node.findParent(NodeType.Declaration); var value = decl && decl.getValue(); if (value && value.encloses(node)) { return decl; } return null; } 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: true, configurable: true }); Object.defineProperty(Node.prototype, "type", { get: function () { return this.nodeType || NodeType.Undefined; }, set: function (type) { this.nodeType = type; }, enumerable: true, 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; }()); 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)); 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: true, configurable: true }); Identifier.prototype.containsInterpolation = function () { return this.hasChildren(); }; return Identifier; }(Node)); 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: true, configurable: true }); return Stylesheet; }(Node)); 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: true, configurable: true }); return Declarations; }(Node)); 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)); 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: true, 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)); 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: true, configurable: true }); return Selector; }(Node)); 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: true, configurable: true }); return SimpleSelector; }(Node)); 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: true, 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)); var AbstractDeclaration = /** @class */ (function (_super) { __extends(AbstractDeclaration, _super); function AbstractDeclaration(offset, length) { return _super.call(this, offset, length) || this; } return AbstractDeclaration; }(Node)); 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: true, configurable: true }); CustomPropertyDeclaration.prototype.setProperty = function (node) { return this.setNode('property', node); }; CustomPropertyDeclaration.prototype.getProperty = function () { return this.property; }; CustomPropertyDeclaration.prototype.setValue = function (value) { return this.setNode('value', value); }; CustomPropertyDeclaration.prototype.getValue = function () { return this.value; }; CustomPropertyDeclaration.prototype.setPropertySet = function (value) { return this.setNode('propertySet', value); }; CustomPropertyDeclaration.prototype.getPropertySet = function () { return this.propertySet; }; return CustomPropertyDeclaration; }(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: true, configurable: true }); return CustomPropertySet; }(BodyDeclaration)); 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: true, 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)); 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: true, configurable: true }); Property.prototype.setIdentifier = function (value) { return this.setNode('identifier', value); }; Property.prototype.getIdentifier = function () { return this.identifier; }; Property.prototype.getName = function () { return this.getText(); }; Property.prototype.isCustomPropert