monaco-editor
Version:
A browser based code editor
1,667 lines • 1.26 MB
JavaScript
define("vs/language/css/css.worker", ["../../initialize-BJOLaCxY", "../../index-CXwHBsfm", "../../main-CLp3wP3p"], (function(initialize, index, main) {
"use strict";
var TokenType;
(function(TokenType2) {
TokenType2[TokenType2["Ident"] = 0] = "Ident";
TokenType2[TokenType2["AtKeyword"] = 1] = "AtKeyword";
TokenType2[TokenType2["String"] = 2] = "String";
TokenType2[TokenType2["BadString"] = 3] = "BadString";
TokenType2[TokenType2["UnquotedString"] = 4] = "UnquotedString";
TokenType2[TokenType2["Hash"] = 5] = "Hash";
TokenType2[TokenType2["Num"] = 6] = "Num";
TokenType2[TokenType2["Percentage"] = 7] = "Percentage";
TokenType2[TokenType2["Dimension"] = 8] = "Dimension";
TokenType2[TokenType2["UnicodeRange"] = 9] = "UnicodeRange";
TokenType2[TokenType2["CDO"] = 10] = "CDO";
TokenType2[TokenType2["CDC"] = 11] = "CDC";
TokenType2[TokenType2["Colon"] = 12] = "Colon";
TokenType2[TokenType2["SemiColon"] = 13] = "SemiColon";
TokenType2[TokenType2["CurlyL"] = 14] = "CurlyL";
TokenType2[TokenType2["CurlyR"] = 15] = "CurlyR";
TokenType2[TokenType2["ParenthesisL"] = 16] = "ParenthesisL";
TokenType2[TokenType2["ParenthesisR"] = 17] = "ParenthesisR";
TokenType2[TokenType2["BracketL"] = 18] = "BracketL";
TokenType2[TokenType2["BracketR"] = 19] = "BracketR";
TokenType2[TokenType2["Whitespace"] = 20] = "Whitespace";
TokenType2[TokenType2["Includes"] = 21] = "Includes";
TokenType2[TokenType2["Dashmatch"] = 22] = "Dashmatch";
TokenType2[TokenType2["SubstringOperator"] = 23] = "SubstringOperator";
TokenType2[TokenType2["PrefixOperator"] = 24] = "PrefixOperator";
TokenType2[TokenType2["SuffixOperator"] = 25] = "SuffixOperator";
TokenType2[TokenType2["Delim"] = 26] = "Delim";
TokenType2[TokenType2["EMS"] = 27] = "EMS";
TokenType2[TokenType2["EXS"] = 28] = "EXS";
TokenType2[TokenType2["Length"] = 29] = "Length";
TokenType2[TokenType2["Angle"] = 30] = "Angle";
TokenType2[TokenType2["Time"] = 31] = "Time";
TokenType2[TokenType2["Freq"] = 32] = "Freq";
TokenType2[TokenType2["Exclamation"] = 33] = "Exclamation";
TokenType2[TokenType2["Resolution"] = 34] = "Resolution";
TokenType2[TokenType2["Comma"] = 35] = "Comma";
TokenType2[TokenType2["Charset"] = 36] = "Charset";
TokenType2[TokenType2["EscapedJavaScript"] = 37] = "EscapedJavaScript";
TokenType2[TokenType2["BadEscapedJavaScript"] = 38] = "BadEscapedJavaScript";
TokenType2[TokenType2["Comment"] = 39] = "Comment";
TokenType2[TokenType2["SingleLineComment"] = 40] = "SingleLineComment";
TokenType2[TokenType2["EOF"] = 41] = "EOF";
TokenType2[TokenType2["ContainerQueryLength"] = 42] = "ContainerQueryLength";
TokenType2[TokenType2["CustomToken"] = 43] = "CustomToken";
})(TokenType || (TokenType = {}));
class MultiLineStream {
constructor(source) {
this.source = source;
this.len = source.length;
this.position = 0;
}
substring(from, to = this.position) {
return this.source.substring(from, to);
}
eos() {
return this.len <= this.position;
}
pos() {
return this.position;
}
goBackTo(pos) {
this.position = pos;
}
goBack(n) {
this.position -= n;
}
advance(n) {
this.position += n;
}
nextChar() {
return this.source.charCodeAt(this.position++) || 0;
}
peekChar(n = 0) {
return this.source.charCodeAt(this.position + n) || 0;
}
lookbackChar(n = 0) {
return this.source.charCodeAt(this.position - n) || 0;
}
advanceIfChar(ch) {
if (ch === this.source.charCodeAt(this.position)) {
this.position++;
return true;
}
return false;
}
advanceIfChars(ch) {
if (this.position + ch.length > this.source.length) {
return false;
}
let i = 0;
for (; i < ch.length; i++) {
if (this.source.charCodeAt(this.position + i) !== ch[i]) {
return false;
}
}
this.advance(i);
return true;
}
advanceWhileChar(condition) {
const posNow = this.position;
while (this.position < this.len && condition(this.source.charCodeAt(this.position))) {
this.position++;
}
return this.position - posNow;
}
}
const _a = "a".charCodeAt(0);
const _f = "f".charCodeAt(0);
const _z = "z".charCodeAt(0);
const _A = "A".charCodeAt(0);
const _F = "F".charCodeAt(0);
const _Z = "Z".charCodeAt(0);
const _0$1 = "0".charCodeAt(0);
const _9$1 = "9".charCodeAt(0);
const _TLD = "~".charCodeAt(0);
const _HAT = "^".charCodeAt(0);
const _EQS$1 = "=".charCodeAt(0);
const _PIP = "|".charCodeAt(0);
const _MIN = "-".charCodeAt(0);
const _USC = "_".charCodeAt(0);
const _PRC = "%".charCodeAt(0);
const _MUL = "*".charCodeAt(0);
const _LPA = "(".charCodeAt(0);
const _RPA = ")".charCodeAt(0);
const _LAN$1 = "<".charCodeAt(0);
const _RAN$1 = ">".charCodeAt(0);
const _ATS = "@".charCodeAt(0);
const _HSH$1 = "#".charCodeAt(0);
const _DLR$1 = "$".charCodeAt(0);
const _BSL = "\\".charCodeAt(0);
const _FSL$2 = "/".charCodeAt(0);
const _NWL$2 = "\n".charCodeAt(0);
const _CAR$2 = "\r".charCodeAt(0);
const _LFD$2 = "\f".charCodeAt(0);
const _DQO = '"'.charCodeAt(0);
const _SQO = "'".charCodeAt(0);
const _WSP = " ".charCodeAt(0);
const _TAB = " ".charCodeAt(0);
const _SEM = ";".charCodeAt(0);
const _COL = ":".charCodeAt(0);
const _CUL$2 = "{".charCodeAt(0);
const _CUR$1 = "}".charCodeAt(0);
const _BRL = "[".charCodeAt(0);
const _BRR = "]".charCodeAt(0);
const _CMA = ",".charCodeAt(0);
const _DOT$2 = ".".charCodeAt(0);
const _BNG$1 = "!".charCodeAt(0);
const _QSM = "?".charCodeAt(0);
const _PLS = "+".charCodeAt(0);
const staticTokenTable = {};
staticTokenTable[_SEM] = TokenType.SemiColon;
staticTokenTable[_COL] = TokenType.Colon;
staticTokenTable[_CUL$2] = TokenType.CurlyL;
staticTokenTable[_CUR$1] = TokenType.CurlyR;
staticTokenTable[_BRR] = TokenType.BracketR;
staticTokenTable[_BRL] = TokenType.BracketL;
staticTokenTable[_LPA] = TokenType.ParenthesisL;
staticTokenTable[_RPA] = TokenType.ParenthesisR;
staticTokenTable[_CMA] = TokenType.Comma;
const 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;
staticUnitTable["cqw"] = TokenType.ContainerQueryLength;
staticUnitTable["cqh"] = TokenType.ContainerQueryLength;
staticUnitTable["cqi"] = TokenType.ContainerQueryLength;
staticUnitTable["cqb"] = TokenType.ContainerQueryLength;
staticUnitTable["cqmin"] = TokenType.ContainerQueryLength;
staticUnitTable["cqmax"] = TokenType.ContainerQueryLength;
class Scanner {
constructor() {
this.stream = new MultiLineStream("");
this.ignoreComment = true;
this.ignoreWhitespace = true;
this.inURL = false;
}
setSource(input) {
this.stream = new MultiLineStream(input);
}
finishToken(offset, type, text) {
return {
offset,
len: this.stream.pos() - offset,
type,
text: text || this.stream.substring(offset)
};
}
substring(offset, len) {
return this.stream.substring(offset, offset + len);
}
pos() {
return this.stream.pos();
}
goBackTo(pos) {
this.stream.goBackTo(pos);
}
scanUnquotedString() {
const offset = this.stream.pos();
const content = [];
if (this._unquotedString(content)) {
return this.finishToken(offset, TokenType.UnquotedString, content.join(""));
}
return null;
}
scan() {
const triviaToken = this.trivia();
if (triviaToken !== null) {
return triviaToken;
}
const offset = this.stream.pos();
if (this.stream.eos()) {
return this.finishToken(offset, TokenType.EOF);
}
return this.scanNext(offset);
}
/**
* Read the range as described in https://www.w3.org/TR/CSS21/syndata.html#tokenization
* Assume the `u` has aleady been consumed
* @returns if reading the unicode was successful
*/
tryScanUnicode() {
const offset = this.stream.pos();
if (!this.stream.eos() && this._unicodeRange()) {
return this.finishToken(offset, TokenType.UnicodeRange);
}
this.stream.goBackTo(offset);
return void 0;
}
scanNext(offset) {
if (this.stream.advanceIfChars([_LAN$1, _BNG$1, _MIN, _MIN])) {
return this.finishToken(offset, TokenType.CDO);
}
if (this.stream.advanceIfChars([_MIN, _MIN, _RAN$1])) {
return this.finishToken(offset, TokenType.CDC);
}
let content = [];
if (this.ident(content)) {
return this.finishToken(offset, TokenType.Ident, content.join(""));
}
if (this.stream.advanceIfChar(_ATS)) {
content = ["@"];
if (this._name(content)) {
const 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);
}
}
if (this.stream.advanceIfChar(_HSH$1)) {
content = ["#"];
if (this._name(content)) {
return this.finishToken(offset, TokenType.Hash, content.join(""));
} else {
return this.finishToken(offset, TokenType.Delim);
}
}
if (this.stream.advanceIfChar(_BNG$1)) {
return this.finishToken(offset, TokenType.Exclamation);
}
if (this._number()) {
const pos = this.stream.pos();
content = [this.stream.substring(offset, pos)];
if (this.stream.advanceIfChar(_PRC)) {
return this.finishToken(offset, TokenType.Percentage);
} else if (this.ident(content)) {
const dim = this.stream.substring(pos).toLowerCase();
const tokenType2 = staticUnitTable[dim];
if (typeof tokenType2 !== "undefined") {
return this.finishToken(offset, tokenType2, content.join(""));
} else {
return this.finishToken(offset, TokenType.Dimension, content.join(""));
}
}
return this.finishToken(offset, TokenType.Num);
}
content = [];
let tokenType = this._string(content);
if (tokenType !== null) {
return this.finishToken(offset, tokenType, content.join(""));
}
tokenType = staticTokenTable[this.stream.peekChar()];
if (typeof tokenType !== "undefined") {
this.stream.advance(1);
return this.finishToken(offset, tokenType);
}
if (this.stream.peekChar(0) === _TLD && this.stream.peekChar(1) === _EQS$1) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.Includes);
}
if (this.stream.peekChar(0) === _PIP && this.stream.peekChar(1) === _EQS$1) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.Dashmatch);
}
if (this.stream.peekChar(0) === _MUL && this.stream.peekChar(1) === _EQS$1) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.SubstringOperator);
}
if (this.stream.peekChar(0) === _HAT && this.stream.peekChar(1) === _EQS$1) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.PrefixOperator);
}
if (this.stream.peekChar(0) === _DLR$1 && this.stream.peekChar(1) === _EQS$1) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.SuffixOperator);
}
this.stream.nextChar();
return this.finishToken(offset, TokenType.Delim);
}
trivia() {
while (true) {
const 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;
}
}
}
comment() {
if (this.stream.advanceIfChars([_FSL$2, _MUL])) {
let success = false, hot = false;
this.stream.advanceWhileChar((ch) => {
if (hot && ch === _FSL$2) {
success = true;
return false;
}
hot = ch === _MUL;
return true;
});
if (success) {
this.stream.advance(1);
}
return true;
}
return false;
}
_number() {
let npeek = 0, ch;
if (this.stream.peekChar() === _DOT$2) {
npeek = 1;
}
ch = this.stream.peekChar(npeek);
if (ch >= _0$1 && ch <= _9$1) {
this.stream.advance(npeek + 1);
this.stream.advanceWhileChar((ch2) => {
return ch2 >= _0$1 && ch2 <= _9$1 || npeek === 0 && ch2 === _DOT$2;
});
return true;
}
return false;
}
_newline(result) {
const ch = this.stream.peekChar();
switch (ch) {
case _CAR$2:
case _LFD$2:
case _NWL$2:
this.stream.advance(1);
result.push(String.fromCharCode(ch));
if (ch === _CAR$2 && this.stream.advanceIfChar(_NWL$2)) {
result.push("\n");
}
return true;
}
return false;
}
_escape(result, includeNewLines) {
let ch = this.stream.peekChar();
if (ch === _BSL) {
this.stream.advance(1);
ch = this.stream.peekChar();
let hexNumCount = 0;
while (hexNumCount < 6 && (ch >= _0$1 && ch <= _9$1 || ch >= _a && ch <= _f || ch >= _A && ch <= _F)) {
this.stream.advance(1);
ch = this.stream.peekChar();
hexNumCount++;
}
if (hexNumCount > 0) {
try {
const hexVal = parseInt(this.stream.substring(this.stream.pos() - hexNumCount), 16);
if (hexVal) {
result.push(String.fromCharCode(hexVal));
}
} catch (e) {
}
if (ch === _WSP || ch === _TAB) {
this.stream.advance(1);
} else {
this._newline([]);
}
return true;
}
if (ch !== _CAR$2 && ch !== _LFD$2 && ch !== _NWL$2) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
} else if (includeNewLines) {
return this._newline(result);
}
}
return false;
}
_stringChar(closeQuote, result) {
const ch = this.stream.peekChar();
if (ch !== 0 && ch !== closeQuote && ch !== _BSL && ch !== _CAR$2 && ch !== _LFD$2 && ch !== _NWL$2) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_string(result) {
if (this.stream.peekChar() === _SQO || this.stream.peekChar() === _DQO) {
const closeQuote = this.stream.nextChar();
result.push(String.fromCharCode(closeQuote));
while (this._stringChar(closeQuote, result) || this._escape(result, true)) {
}
if (this.stream.peekChar() === closeQuote) {
this.stream.nextChar();
result.push(String.fromCharCode(closeQuote));
return TokenType.String;
} else {
return TokenType.BadString;
}
}
return null;
}
_unquotedChar(result) {
const ch = this.stream.peekChar();
if (ch !== 0 && ch !== _BSL && ch !== _SQO && ch !== _DQO && ch !== _LPA && ch !== _RPA && ch !== _WSP && ch !== _TAB && ch !== _NWL$2 && ch !== _LFD$2 && ch !== _CAR$2) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_unquotedString(result) {
let hasContent = false;
while (this._unquotedChar(result) || this._escape(result)) {
hasContent = true;
}
return hasContent;
}
_whitespace() {
const n = this.stream.advanceWhileChar((ch) => {
return ch === _WSP || ch === _TAB || ch === _NWL$2 || ch === _LFD$2 || ch === _CAR$2;
});
return n > 0;
}
_name(result) {
let matched = false;
while (this._identChar(result) || this._escape(result)) {
matched = true;
}
return matched;
}
ident(result) {
const pos = this.stream.pos();
const hasMinus = this._minus(result);
if (hasMinus) {
if (this._minus(result) || this._identFirstChar(result) || this._escape(result)) {
while (this._identChar(result) || this._escape(result)) {
}
return true;
}
} else if (this._identFirstChar(result) || this._escape(result)) {
while (this._identChar(result) || this._escape(result)) {
}
return true;
}
this.stream.goBackTo(pos);
return false;
}
_identFirstChar(result) {
const ch = this.stream.peekChar();
if (ch === _USC || // _
ch >= _a && ch <= _z || // a-z
ch >= _A && ch <= _Z || // A-Z
ch >= 128 && ch <= 65535) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_minus(result) {
const ch = this.stream.peekChar();
if (ch === _MIN) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_identChar(result) {
const ch = this.stream.peekChar();
if (ch === _USC || // _
ch === _MIN || // -
ch >= _a && ch <= _z || // a-z
ch >= _A && ch <= _Z || // A-Z
ch >= _0$1 && ch <= _9$1 || // 0/9
ch >= 128 && ch <= 65535) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_unicodeRange() {
if (this.stream.advanceIfChar(_PLS)) {
const isHexDigit = (ch) => ch >= _0$1 && ch <= _9$1 || ch >= _a && ch <= _f || ch >= _A && ch <= _F;
const codePoints = this.stream.advanceWhileChar(isHexDigit) + this.stream.advanceWhileChar((ch) => ch === _QSM);
if (codePoints >= 1 && codePoints <= 6) {
if (this.stream.advanceIfChar(_MIN)) {
const digits = this.stream.advanceWhileChar(isHexDigit);
if (digits >= 1 && digits <= 6) {
return true;
}
} else {
return true;
}
}
}
return false;
}
}
function startsWith(haystack, needle) {
if (haystack.length < needle.length) {
return false;
}
for (let i = 0; i < needle.length; i++) {
if (haystack[i] !== needle[i]) {
return false;
}
}
return true;
}
function endsWith(haystack, needle) {
let diff = haystack.length - needle.length;
if (diff > 0) {
return haystack.lastIndexOf(needle) === diff;
} else if (diff === 0) {
return haystack === needle;
} else {
return false;
}
}
function difference(first, second, maxLenDelta = 4) {
let lengthDifference = Math.abs(first.length - second.length);
if (lengthDifference > maxLenDelta) {
return 0;
}
let LCS = [];
let zeroArray = [];
let 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);
}
function getLimitedString(str, ellipsis = true) {
if (!str) {
return "";
}
if (str.length < 140) {
return str;
}
return str.slice(0, 140) + (ellipsis ? "…" : "");
}
function trim(str, regexp) {
const m = regexp.exec(str);
if (m && m[0].length) {
return str.substr(0, str.length - m[0].length);
}
return str;
}
function repeat(value, count) {
let s = "";
while (count > 0) {
if ((count & 1) === 1) {
s += value;
}
value += value;
count = count >>> 1;
}
return s;
}
var NodeType;
(function(NodeType2) {
NodeType2[NodeType2["Undefined"] = 0] = "Undefined";
NodeType2[NodeType2["Identifier"] = 1] = "Identifier";
NodeType2[NodeType2["Stylesheet"] = 2] = "Stylesheet";
NodeType2[NodeType2["Ruleset"] = 3] = "Ruleset";
NodeType2[NodeType2["Selector"] = 4] = "Selector";
NodeType2[NodeType2["SimpleSelector"] = 5] = "SimpleSelector";
NodeType2[NodeType2["SelectorInterpolation"] = 6] = "SelectorInterpolation";
NodeType2[NodeType2["SelectorCombinator"] = 7] = "SelectorCombinator";
NodeType2[NodeType2["SelectorCombinatorParent"] = 8] = "SelectorCombinatorParent";
NodeType2[NodeType2["SelectorCombinatorSibling"] = 9] = "SelectorCombinatorSibling";
NodeType2[NodeType2["SelectorCombinatorAllSiblings"] = 10] = "SelectorCombinatorAllSiblings";
NodeType2[NodeType2["SelectorCombinatorShadowPiercingDescendant"] = 11] = "SelectorCombinatorShadowPiercingDescendant";
NodeType2[NodeType2["Page"] = 12] = "Page";
NodeType2[NodeType2["PageBoxMarginBox"] = 13] = "PageBoxMarginBox";
NodeType2[NodeType2["ClassSelector"] = 14] = "ClassSelector";
NodeType2[NodeType2["IdentifierSelector"] = 15] = "IdentifierSelector";
NodeType2[NodeType2["ElementNameSelector"] = 16] = "ElementNameSelector";
NodeType2[NodeType2["PseudoSelector"] = 17] = "PseudoSelector";
NodeType2[NodeType2["AttributeSelector"] = 18] = "AttributeSelector";
NodeType2[NodeType2["Declaration"] = 19] = "Declaration";
NodeType2[NodeType2["Declarations"] = 20] = "Declarations";
NodeType2[NodeType2["Property"] = 21] = "Property";
NodeType2[NodeType2["Expression"] = 22] = "Expression";
NodeType2[NodeType2["BinaryExpression"] = 23] = "BinaryExpression";
NodeType2[NodeType2["Term"] = 24] = "Term";
NodeType2[NodeType2["Operator"] = 25] = "Operator";
NodeType2[NodeType2["Value"] = 26] = "Value";
NodeType2[NodeType2["StringLiteral"] = 27] = "StringLiteral";
NodeType2[NodeType2["URILiteral"] = 28] = "URILiteral";
NodeType2[NodeType2["EscapedValue"] = 29] = "EscapedValue";
NodeType2[NodeType2["Function"] = 30] = "Function";
NodeType2[NodeType2["NumericValue"] = 31] = "NumericValue";
NodeType2[NodeType2["HexColorValue"] = 32] = "HexColorValue";
NodeType2[NodeType2["RatioValue"] = 33] = "RatioValue";
NodeType2[NodeType2["MixinDeclaration"] = 34] = "MixinDeclaration";
NodeType2[NodeType2["MixinReference"] = 35] = "MixinReference";
NodeType2[NodeType2["VariableName"] = 36] = "VariableName";
NodeType2[NodeType2["VariableDeclaration"] = 37] = "VariableDeclaration";
NodeType2[NodeType2["Prio"] = 38] = "Prio";
NodeType2[NodeType2["Interpolation"] = 39] = "Interpolation";
NodeType2[NodeType2["NestedProperties"] = 40] = "NestedProperties";
NodeType2[NodeType2["ExtendsReference"] = 41] = "ExtendsReference";
NodeType2[NodeType2["SelectorPlaceholder"] = 42] = "SelectorPlaceholder";
NodeType2[NodeType2["Debug"] = 43] = "Debug";
NodeType2[NodeType2["If"] = 44] = "If";
NodeType2[NodeType2["Else"] = 45] = "Else";
NodeType2[NodeType2["For"] = 46] = "For";
NodeType2[NodeType2["Each"] = 47] = "Each";
NodeType2[NodeType2["While"] = 48] = "While";
NodeType2[NodeType2["MixinContentReference"] = 49] = "MixinContentReference";
NodeType2[NodeType2["MixinContentDeclaration"] = 50] = "MixinContentDeclaration";
NodeType2[NodeType2["Media"] = 51] = "Media";
NodeType2[NodeType2["Keyframe"] = 52] = "Keyframe";
NodeType2[NodeType2["FontFace"] = 53] = "FontFace";
NodeType2[NodeType2["Import"] = 54] = "Import";
NodeType2[NodeType2["Namespace"] = 55] = "Namespace";
NodeType2[NodeType2["Invocation"] = 56] = "Invocation";
NodeType2[NodeType2["FunctionDeclaration"] = 57] = "FunctionDeclaration";
NodeType2[NodeType2["ReturnStatement"] = 58] = "ReturnStatement";
NodeType2[NodeType2["MediaQuery"] = 59] = "MediaQuery";
NodeType2[NodeType2["MediaCondition"] = 60] = "MediaCondition";
NodeType2[NodeType2["MediaFeature"] = 61] = "MediaFeature";
NodeType2[NodeType2["FunctionParameter"] = 62] = "FunctionParameter";
NodeType2[NodeType2["FunctionArgument"] = 63] = "FunctionArgument";
NodeType2[NodeType2["KeyframeSelector"] = 64] = "KeyframeSelector";
NodeType2[NodeType2["ViewPort"] = 65] = "ViewPort";
NodeType2[NodeType2["Document"] = 66] = "Document";
NodeType2[NodeType2["AtApplyRule"] = 67] = "AtApplyRule";
NodeType2[NodeType2["CustomPropertyDeclaration"] = 68] = "CustomPropertyDeclaration";
NodeType2[NodeType2["CustomPropertySet"] = 69] = "CustomPropertySet";
NodeType2[NodeType2["ListEntry"] = 70] = "ListEntry";
NodeType2[NodeType2["Supports"] = 71] = "Supports";
NodeType2[NodeType2["SupportsCondition"] = 72] = "SupportsCondition";
NodeType2[NodeType2["NamespacePrefix"] = 73] = "NamespacePrefix";
NodeType2[NodeType2["GridLine"] = 74] = "GridLine";
NodeType2[NodeType2["Plugin"] = 75] = "Plugin";
NodeType2[NodeType2["UnknownAtRule"] = 76] = "UnknownAtRule";
NodeType2[NodeType2["Use"] = 77] = "Use";
NodeType2[NodeType2["ModuleConfiguration"] = 78] = "ModuleConfiguration";
NodeType2[NodeType2["Forward"] = 79] = "Forward";
NodeType2[NodeType2["ForwardVisibility"] = 80] = "ForwardVisibility";
NodeType2[NodeType2["Module"] = 81] = "Module";
NodeType2[NodeType2["UnicodeRange"] = 82] = "UnicodeRange";
NodeType2[NodeType2["Layer"] = 83] = "Layer";
NodeType2[NodeType2["LayerNameList"] = 84] = "LayerNameList";
NodeType2[NodeType2["LayerName"] = 85] = "LayerName";
NodeType2[NodeType2["PropertyAtRule"] = 86] = "PropertyAtRule";
NodeType2[NodeType2["Container"] = 87] = "Container";
})(NodeType || (NodeType = {}));
var ReferenceType;
(function(ReferenceType2) {
ReferenceType2[ReferenceType2["Mixin"] = 0] = "Mixin";
ReferenceType2[ReferenceType2["Rule"] = 1] = "Rule";
ReferenceType2[ReferenceType2["Variable"] = 2] = "Variable";
ReferenceType2[ReferenceType2["Function"] = 3] = "Function";
ReferenceType2[ReferenceType2["Keyframe"] = 4] = "Keyframe";
ReferenceType2[ReferenceType2["Unknown"] = 5] = "Unknown";
ReferenceType2[ReferenceType2["Module"] = 6] = "Module";
ReferenceType2[ReferenceType2["Forward"] = 7] = "Forward";
ReferenceType2[ReferenceType2["ForwardVisibility"] = 8] = "ForwardVisibility";
ReferenceType2[ReferenceType2["Property"] = 9] = "Property";
})(ReferenceType || (ReferenceType = {}));
function getNodeAtOffset(node, offset) {
let candidate = null;
if (!node || offset < node.offset || offset > node.end) {
return null;
}
node.accept((node2) => {
if (node2.offset === -1 && node2.length === -1) {
return true;
}
if (node2.offset <= offset && node2.end >= offset) {
if (!candidate) {
candidate = node2;
} else if (node2.length <= candidate.length) {
candidate = node2;
}
return true;
}
return false;
});
return candidate;
}
function getNodePath(node, offset) {
let candidate = getNodeAtOffset(node, offset);
const path = [];
while (candidate) {
path.unshift(candidate);
candidate = candidate.parent;
}
return path;
}
function getParentDeclaration(node) {
const decl = node.findParent(NodeType.Declaration);
const value = decl && decl.getValue();
if (value && value.encloses(node)) {
return decl;
}
return null;
}
class Node {
get end() {
return this.offset + this.length;
}
constructor(offset = -1, len = -1, nodeType) {
this.parent = null;
this.offset = offset;
this.length = len;
if (nodeType) {
this.nodeType = nodeType;
}
}
set type(type) {
this.nodeType = type;
}
get type() {
return this.nodeType || NodeType.Undefined;
}
getTextProvider() {
let node = this;
while (node && !node.textProvider) {
node = node.parent;
}
if (node) {
return node.textProvider;
}
return () => {
return "unknown";
};
}
getText() {
return this.getTextProvider()(this.offset, this.length);
}
matches(str) {
return this.length === str.length && this.getTextProvider()(this.offset, this.length) === str;
}
startsWith(str) {
return this.length >= str.length && this.getTextProvider()(this.offset, str.length) === str;
}
endsWith(str) {
return this.length >= str.length && this.getTextProvider()(this.end - str.length, str.length) === str;
}
accept(visitor) {
if (visitor(this) && this.children) {
for (const child of this.children) {
child.accept(visitor);
}
}
}
acceptVisitor(visitor) {
this.accept(visitor.visitNode.bind(visitor));
}
adoptChild(node, index2 = -1) {
if (node.parent && node.parent.children) {
const idx = node.parent.children.indexOf(node);
if (idx >= 0) {
node.parent.children.splice(idx, 1);
}
}
node.parent = this;
let children = this.children;
if (!children) {
children = this.children = [];
}
if (index2 !== -1) {
children.splice(index2, 0, node);
} else {
children.push(node);
}
return node;
}
attachTo(parent, index2 = -1) {
if (parent) {
parent.adoptChild(this, index2);
}
return this;
}
collectIssues(results) {
if (this.issues) {
results.push.apply(results, this.issues);
}
}
addIssue(issue) {
if (!this.issues) {
this.issues = [];
}
this.issues.push(issue);
}
hasIssue(rule) {
return Array.isArray(this.issues) && this.issues.some((i) => i.getRule() === rule);
}
isErroneous(recursive = false) {
if (this.issues && this.issues.length > 0) {
return true;
}
return recursive && Array.isArray(this.children) && this.children.some((c) => c.isErroneous(true));
}
setNode(field, node, index2 = -1) {
if (node) {
node.attachTo(this, index2);
this[field] = node;
return true;
}
return false;
}
addChild(node) {
if (node) {
if (!this.children) {
this.children = [];
}
node.attachTo(this);
this.updateOffsetAndLength(node);
return true;
}
return false;
}
updateOffsetAndLength(node) {
if (node.offset < this.offset || this.offset === -1) {
this.offset = node.offset;
}
const nodeEnd = node.end;
if (nodeEnd > this.end || this.length === -1) {
this.length = nodeEnd - this.offset;
}
}
hasChildren() {
return !!this.children && this.children.length > 0;
}
getChildren() {
return this.children ? this.children.slice(0) : [];
}
getChild(index2) {
if (this.children && index2 < this.children.length) {
return this.children[index2];
}
return null;
}
addChildren(nodes) {
for (const node of nodes) {
this.addChild(node);
}
}
findFirstChildBeforeOffset(offset) {
if (this.children) {
let current = null;
for (let i = this.children.length - 1; i >= 0; i--) {
current = this.children[i];
if (current.offset <= offset) {
return current;
}
}
}
return null;
}
findChildAtOffset(offset, goDeep) {
const current = this.findFirstChildBeforeOffset(offset);
if (current && current.end >= offset) {
if (goDeep) {
return current.findChildAtOffset(offset, true) || current;
}
return current;
}
return null;
}
encloses(candidate) {
return this.offset <= candidate.offset && this.offset + this.length >= candidate.offset + candidate.length;
}
getParent() {
let result = this.parent;
while (result instanceof Nodelist) {
result = result.parent;
}
return result;
}
findParent(type) {
let result = this;
while (result && result.type !== type) {
result = result.parent;
}
return result;
}
findAParent(...types) {
let result = this;
while (result && !types.some((t) => result.type === t)) {
result = result.parent;
}
return result;
}
setData(key, value) {
if (!this.options) {
this.options = {};
}
this.options[key] = value;
}
getData(key) {
if (!this.options || !this.options.hasOwnProperty(key)) {
return null;
}
return this.options[key];
}
}
class Nodelist extends Node {
constructor(parent, index2 = -1) {
super(-1, -1);
this.attachTo(parent, index2);
this.offset = -1;
this.length = -1;
}
}
class UnicodeRange extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.UnicodeRange;
}
setRangeStart(rangeStart) {
return this.setNode("rangeStart", rangeStart);
}
getRangeStart() {
return this.rangeStart;
}
setRangeEnd(rangeEnd) {
return this.setNode("rangeEnd", rangeEnd);
}
getRangeEnd() {
return this.rangeEnd;
}
}
class Identifier extends Node {
constructor(offset, length) {
super(offset, length);
this.isCustomProperty = false;
}
get type() {
return NodeType.Identifier;
}
containsInterpolation() {
return this.hasChildren();
}
}
class Stylesheet extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Stylesheet;
}
}
class Declarations extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Declarations;
}
}
class BodyDeclaration extends Node {
constructor(offset, length) {
super(offset, length);
}
getDeclarations() {
return this.declarations;
}
setDeclarations(decls) {
return this.setNode("declarations", decls);
}
}
class RuleSet extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Ruleset;
}
getSelectors() {
if (!this.selectors) {
this.selectors = new Nodelist(this);
}
return this.selectors;
}
isNested() {
return !!this.parent && this.parent.findParent(NodeType.Declarations) !== null;
}
}
class Selector extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Selector;
}
}
class SimpleSelector extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.SimpleSelector;
}
}
class AbstractDeclaration extends Node {
constructor(offset, length) {
super(offset, length);
}
}
class CustomPropertySet extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.CustomPropertySet;
}
}
class Declaration extends AbstractDeclaration {
constructor(offset, length) {
super(offset, length);
this.property = null;
}
get type() {
return NodeType.Declaration;
}
setProperty(node) {
return this.setNode("property", node);
}
getProperty() {
return this.property;
}
getFullPropertyName() {
const propertyName = this.property ? this.property.getName() : "unknown";
if (this.parent instanceof Declarations && this.parent.getParent() instanceof NestedProperties) {
const parentDecl = this.parent.getParent().getParent();
if (parentDecl instanceof Declaration) {
return parentDecl.getFullPropertyName() + propertyName;
}
}
return propertyName;
}
getNonPrefixedPropertyName() {
const propertyName = this.getFullPropertyName();
if (propertyName && propertyName.charAt(0) === "-") {
const vendorPrefixEnd = propertyName.indexOf("-", 1);
if (vendorPrefixEnd !== -1) {
return propertyName.substring(vendorPrefixEnd + 1);
}
}
return propertyName;
}
setValue(value) {
return this.setNode("value", value);
}
getValue() {
return this.value;
}
setNestedProperties(value) {
return this.setNode("nestedProperties", value);
}
getNestedProperties() {
return this.nestedProperties;
}
}
class CustomPropertyDeclaration extends Declaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.CustomPropertyDeclaration;
}
setPropertySet(value) {
return this.setNode("propertySet", value);
}
getPropertySet() {
return this.propertySet;
}
}
class Property extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Property;
}
setIdentifier(value) {
return this.setNode("identifier", value);
}
getIdentifier() {
return this.identifier;
}
getName() {
return trim(this.getText(), /[_\+]+$/);
}
isCustomProperty() {
return !!this.identifier && this.identifier.isCustomProperty;
}
}
class Invocation extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Invocation;
}
getArguments() {
if (!this.arguments) {
this.arguments = new Nodelist(this);
}
return this.arguments;
}
}
class Function extends Invocation {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Function;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
}
class FunctionParameter extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.FunctionParameter;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
setDefaultValue(node) {
return this.setNode("defaultValue", node, 0);
}
getDefaultValue() {
return this.defaultValue;
}
}
class FunctionArgument extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.FunctionArgument;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
setValue(node) {
return this.setNode("value", node, 0);
}
getValue() {
return this.value;
}
}
class IfStatement extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.If;
}
setExpression(node) {
return this.setNode("expression", node, 0);
}
setElseClause(elseClause) {
return this.setNode("elseClause", elseClause);
}
}
class ForStatement extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.For;
}
setVariable(node) {
return this.setNode("variable", node, 0);
}
}
class EachStatement extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Each;
}
getVariables() {
if (!this.variables) {
this.variables = new Nodelist(this);
}
return this.variables;
}
}
class WhileStatement extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.While;
}
}
class ElseStatement extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Else;
}
}
class FunctionDeclaration extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.FunctionDeclaration;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
getParameters() {
if (!this.parameters) {
this.parameters = new Nodelist(this);
}
return this.parameters;
}
}
class ViewPort extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.ViewPort;
}
}
class FontFace extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.FontFace;
}
}
class NestedProperties extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.NestedProperties;
}
}
class Keyframe extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Keyframe;
}
setKeyword(keyword) {
return this.setNode("keyword", keyword, 0);
}
getKeyword() {
return this.keyword;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
}
class KeyframeSelector extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.KeyframeSelector;
}
}
class Import extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Import;
}
setMedialist(node) {
if (node) {
node.attachTo(this);
return true;
}
return false;
}
}
class Use extends Node {
get type() {
return NodeType.Use;
}
getParameters() {
if (!this.parameters) {
this.parameters = new Nodelist(this);
}
return this.parameters;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
}
class ModuleConfiguration extends Node {
get type() {
return NodeType.ModuleConfiguration;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
setValue(node) {
return this.setNode("value", node, 0);
}
getValue() {
return this.value;
}
}
class Forward extends Node {
get type() {
return NodeType.Forward;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getMembers() {
if (!this.members) {
this.members = new Nodelist(this);
}
return this.members;
}
getParameters() {
if (!this.parameters) {
this.parameters = new Nodelist(this);
}
return this.parameters;
}
}
class ForwardVisibility extends Node {
get type() {
return NodeType.ForwardVisibility;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
}
class Namespace extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Namespace;
}
}
class Media extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Media;
}
}
class Supports extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Supports;
}
}
class Layer extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Layer;
}
setNames(names) {
return this.setNode("names", names);
}
getNames() {
return this.names;
}
}
class PropertyAtRule extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.PropertyAtRule;
}
setName(node) {
if (node) {
node.attachTo(this);
this.name = node;
return true;
}
return false;
}
getName() {
return this.name;
}
}
class Document extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Document;
}
}
class Container extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Container;
}
}
class Medialist extends Node {
constructor(offset, length) {
super(offset, length);
}
}
class MediaQuery extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.MediaQuery;
}
}
class MediaCondition extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.MediaCondition;
}
}
class MediaFeature extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.MediaFeature;
}
}
class SupportsCondition extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.SupportsCondition;
}
}
class Page extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Page;
}
}
class PageBoxMarginBox extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.PageBoxMarginBox;
}
}
class Expression extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Expression;
}
}
class BinaryExpression extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.BinaryExpression;
}
setLeft(left) {
return this.setNode("left", left);
}
getLeft() {
return this.left;
}
setRight(right) {
return this.setNode("right", right);
}
getRight() {
return this.right;
}
setOperator(value) {
return this.setNode("operator", value);
}
getOperator() {
return this.operator;
}
}
class Term extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Term;
}
setOperator(value) {
return this.setNode("operator", value);
}
getOperator() {
return this.operator;
}
setExpression(value) {
return this.setNode("expression", value);
}
getExpression() {
return this.expression;
}
}
class AttributeSelector extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.AttributeSelector;
}
setNamespacePrefix(value) {
return this.setNode("namespacePrefix", value);
}
getNamespacePrefix() {
return this.namespacePrefix;
}
setIdentifier(value) {
return this.setNode("identifier", value);
}
getIdentifier() {
return this.identifier;
}
setOperator(operator) {
return this.setNode("operator", operator);
}
getOperator() {
return this.operator;
}
se