vscode-css-languageservice 5.3.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -0
  3. package/lib/esm/beautify/beautify-css.js +57 -15
  4. package/lib/esm/cssLanguageService.d.ts +37 -37
  5. package/lib/esm/cssLanguageService.js +72 -75
  6. package/lib/esm/cssLanguageTypes.d.ts +238 -228
  7. package/lib/esm/cssLanguageTypes.js +42 -42
  8. package/lib/esm/data/webCustomData.js +21965 -21959
  9. package/lib/esm/languageFacts/builtinData.js +142 -142
  10. package/lib/esm/languageFacts/colors.js +469 -472
  11. package/lib/esm/languageFacts/dataManager.js +88 -92
  12. package/lib/esm/languageFacts/dataProvider.js +73 -79
  13. package/lib/esm/languageFacts/entry.js +137 -138
  14. package/lib/esm/languageFacts/facts.js +8 -8
  15. package/lib/esm/parser/cssErrors.js +48 -50
  16. package/lib/esm/parser/cssNodes.js +1502 -2019
  17. package/lib/esm/parser/cssParser.js +1534 -1566
  18. package/lib/esm/parser/cssScanner.js +592 -599
  19. package/lib/esm/parser/cssSymbolScope.js +311 -341
  20. package/lib/esm/parser/lessParser.js +714 -740
  21. package/lib/esm/parser/lessScanner.js +57 -78
  22. package/lib/esm/parser/scssErrors.js +18 -20
  23. package/lib/esm/parser/scssParser.js +796 -818
  24. package/lib/esm/parser/scssScanner.js +95 -116
  25. package/lib/esm/services/cssCodeActions.js +77 -81
  26. package/lib/esm/services/cssCompletion.js +1054 -1149
  27. package/lib/esm/services/cssFolding.js +190 -193
  28. package/lib/esm/services/cssFormatter.js +136 -117
  29. package/lib/esm/services/cssHover.js +148 -151
  30. package/lib/esm/services/cssNavigation.js +378 -470
  31. package/lib/esm/services/cssSelectionRange.js +47 -47
  32. package/lib/esm/services/cssValidation.js +41 -44
  33. package/lib/esm/services/lessCompletion.js +378 -397
  34. package/lib/esm/services/lint.js +518 -532
  35. package/lib/esm/services/lintRules.js +76 -83
  36. package/lib/esm/services/lintUtil.js +196 -205
  37. package/lib/esm/services/pathCompletion.js +157 -231
  38. package/lib/esm/services/scssCompletion.js +354 -378
  39. package/lib/esm/services/scssNavigation.js +82 -154
  40. package/lib/esm/services/selectorPrinting.js +492 -536
  41. package/lib/esm/utils/arrays.js +40 -46
  42. package/lib/esm/utils/objects.js +11 -11
  43. package/lib/esm/utils/resources.js +11 -24
  44. package/lib/esm/utils/strings.js +102 -104
  45. package/lib/umd/beautify/beautify-css.js +57 -15
  46. package/lib/umd/cssLanguageService.d.ts +37 -37
  47. package/lib/umd/cssLanguageService.js +99 -102
  48. package/lib/umd/cssLanguageTypes.d.ts +238 -228
  49. package/lib/umd/cssLanguageTypes.js +89 -88
  50. package/lib/umd/data/webCustomData.js +21978 -21972
  51. package/lib/umd/languageFacts/builtinData.js +154 -154
  52. package/lib/umd/languageFacts/colors.js +492 -495
  53. package/lib/umd/languageFacts/dataManager.js +101 -104
  54. package/lib/umd/languageFacts/dataProvider.js +86 -91
  55. package/lib/umd/languageFacts/entry.js +152 -153
  56. package/lib/umd/languageFacts/facts.js +29 -29
  57. package/lib/umd/parser/cssErrors.js +61 -62
  58. package/lib/umd/parser/cssNodes.js +1587 -2034
  59. package/lib/umd/parser/cssParser.js +1547 -1578
  60. package/lib/umd/parser/cssScanner.js +606 -611
  61. package/lib/umd/parser/cssSymbolScope.js +328 -353
  62. package/lib/umd/parser/lessParser.js +727 -752
  63. package/lib/umd/parser/lessScanner.js +70 -90
  64. package/lib/umd/parser/scssErrors.js +31 -32
  65. package/lib/umd/parser/scssParser.js +809 -830
  66. package/lib/umd/parser/scssScanner.js +108 -128
  67. package/lib/umd/services/cssCodeActions.js +90 -93
  68. package/lib/umd/services/cssCompletion.js +1067 -1161
  69. package/lib/umd/services/cssFolding.js +203 -206
  70. package/lib/umd/services/cssFormatter.js +150 -131
  71. package/lib/umd/services/cssHover.js +161 -163
  72. package/lib/umd/services/cssNavigation.js +391 -482
  73. package/lib/umd/services/cssSelectionRange.js +60 -60
  74. package/lib/umd/services/cssValidation.js +54 -56
  75. package/lib/umd/services/lessCompletion.js +391 -409
  76. package/lib/umd/services/lint.js +531 -544
  77. package/lib/umd/services/lintRules.js +91 -95
  78. package/lib/umd/services/lintUtil.js +210 -218
  79. package/lib/umd/services/pathCompletion.js +171 -244
  80. package/lib/umd/services/scssCompletion.js +367 -390
  81. package/lib/umd/services/scssNavigation.js +95 -166
  82. package/lib/umd/services/selectorPrinting.js +510 -550
  83. package/lib/umd/utils/arrays.js +55 -61
  84. package/lib/umd/utils/objects.js +25 -25
  85. package/lib/umd/utils/resources.js +26 -39
  86. package/lib/umd/utils/strings.js +120 -122
  87. package/package.json +11 -11
@@ -1,2034 +1,1587 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- (function (factory) {
17
- if (typeof module === "object" && typeof module.exports === "object") {
18
- var v = factory(require, exports);
19
- if (v !== undefined) module.exports = v;
20
- }
21
- else if (typeof define === "function" && define.amd) {
22
- define(["require", "exports", "../utils/strings"], factory);
23
- }
24
- })(function (require, exports) {
25
- /*---------------------------------------------------------------------------------------------
26
- * Copyright (c) Microsoft Corporation. All rights reserved.
27
- * Licensed under the MIT License. See License.txt in the project root for license information.
28
- *--------------------------------------------------------------------------------------------*/
29
- 'use strict';
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- 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.RatioValue = exports.HexColorValue = exports.Operator = exports.AttributeSelector = exports.Term = exports.BinaryExpression = exports.Expression = exports.PageBoxMarginBox = exports.Page = exports.SupportsCondition = exports.MediaFeature = exports.MediaCondition = 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.UnicodeRange = exports.Nodelist = exports.Node = exports.getParentDeclaration = exports.getNodePath = exports.getNodeAtOffset = exports.ReferenceType = exports.NodeType = void 0;
32
- var strings_1 = require("../utils/strings");
33
- /// <summary>
34
- /// Nodes for the css 2.1 specification. See for reference:
35
- /// http://www.w3.org/TR/CSS21/grammar.html#grammar
36
- /// </summary>
37
- var NodeType;
38
- (function (NodeType) {
39
- NodeType[NodeType["Undefined"] = 0] = "Undefined";
40
- NodeType[NodeType["Identifier"] = 1] = "Identifier";
41
- NodeType[NodeType["Stylesheet"] = 2] = "Stylesheet";
42
- NodeType[NodeType["Ruleset"] = 3] = "Ruleset";
43
- NodeType[NodeType["Selector"] = 4] = "Selector";
44
- NodeType[NodeType["SimpleSelector"] = 5] = "SimpleSelector";
45
- NodeType[NodeType["SelectorInterpolation"] = 6] = "SelectorInterpolation";
46
- NodeType[NodeType["SelectorCombinator"] = 7] = "SelectorCombinator";
47
- NodeType[NodeType["SelectorCombinatorParent"] = 8] = "SelectorCombinatorParent";
48
- NodeType[NodeType["SelectorCombinatorSibling"] = 9] = "SelectorCombinatorSibling";
49
- NodeType[NodeType["SelectorCombinatorAllSiblings"] = 10] = "SelectorCombinatorAllSiblings";
50
- NodeType[NodeType["SelectorCombinatorShadowPiercingDescendant"] = 11] = "SelectorCombinatorShadowPiercingDescendant";
51
- NodeType[NodeType["Page"] = 12] = "Page";
52
- NodeType[NodeType["PageBoxMarginBox"] = 13] = "PageBoxMarginBox";
53
- NodeType[NodeType["ClassSelector"] = 14] = "ClassSelector";
54
- NodeType[NodeType["IdentifierSelector"] = 15] = "IdentifierSelector";
55
- NodeType[NodeType["ElementNameSelector"] = 16] = "ElementNameSelector";
56
- NodeType[NodeType["PseudoSelector"] = 17] = "PseudoSelector";
57
- NodeType[NodeType["AttributeSelector"] = 18] = "AttributeSelector";
58
- NodeType[NodeType["Declaration"] = 19] = "Declaration";
59
- NodeType[NodeType["Declarations"] = 20] = "Declarations";
60
- NodeType[NodeType["Property"] = 21] = "Property";
61
- NodeType[NodeType["Expression"] = 22] = "Expression";
62
- NodeType[NodeType["BinaryExpression"] = 23] = "BinaryExpression";
63
- NodeType[NodeType["Term"] = 24] = "Term";
64
- NodeType[NodeType["Operator"] = 25] = "Operator";
65
- NodeType[NodeType["Value"] = 26] = "Value";
66
- NodeType[NodeType["StringLiteral"] = 27] = "StringLiteral";
67
- NodeType[NodeType["URILiteral"] = 28] = "URILiteral";
68
- NodeType[NodeType["EscapedValue"] = 29] = "EscapedValue";
69
- NodeType[NodeType["Function"] = 30] = "Function";
70
- NodeType[NodeType["NumericValue"] = 31] = "NumericValue";
71
- NodeType[NodeType["HexColorValue"] = 32] = "HexColorValue";
72
- NodeType[NodeType["RatioValue"] = 33] = "RatioValue";
73
- NodeType[NodeType["MixinDeclaration"] = 34] = "MixinDeclaration";
74
- NodeType[NodeType["MixinReference"] = 35] = "MixinReference";
75
- NodeType[NodeType["VariableName"] = 36] = "VariableName";
76
- NodeType[NodeType["VariableDeclaration"] = 37] = "VariableDeclaration";
77
- NodeType[NodeType["Prio"] = 38] = "Prio";
78
- NodeType[NodeType["Interpolation"] = 39] = "Interpolation";
79
- NodeType[NodeType["NestedProperties"] = 40] = "NestedProperties";
80
- NodeType[NodeType["ExtendsReference"] = 41] = "ExtendsReference";
81
- NodeType[NodeType["SelectorPlaceholder"] = 42] = "SelectorPlaceholder";
82
- NodeType[NodeType["Debug"] = 43] = "Debug";
83
- NodeType[NodeType["If"] = 44] = "If";
84
- NodeType[NodeType["Else"] = 45] = "Else";
85
- NodeType[NodeType["For"] = 46] = "For";
86
- NodeType[NodeType["Each"] = 47] = "Each";
87
- NodeType[NodeType["While"] = 48] = "While";
88
- NodeType[NodeType["MixinContentReference"] = 49] = "MixinContentReference";
89
- NodeType[NodeType["MixinContentDeclaration"] = 50] = "MixinContentDeclaration";
90
- NodeType[NodeType["Media"] = 51] = "Media";
91
- NodeType[NodeType["Keyframe"] = 52] = "Keyframe";
92
- NodeType[NodeType["FontFace"] = 53] = "FontFace";
93
- NodeType[NodeType["Import"] = 54] = "Import";
94
- NodeType[NodeType["Namespace"] = 55] = "Namespace";
95
- NodeType[NodeType["Invocation"] = 56] = "Invocation";
96
- NodeType[NodeType["FunctionDeclaration"] = 57] = "FunctionDeclaration";
97
- NodeType[NodeType["ReturnStatement"] = 58] = "ReturnStatement";
98
- NodeType[NodeType["MediaQuery"] = 59] = "MediaQuery";
99
- NodeType[NodeType["MediaCondition"] = 60] = "MediaCondition";
100
- NodeType[NodeType["MediaFeature"] = 61] = "MediaFeature";
101
- NodeType[NodeType["FunctionParameter"] = 62] = "FunctionParameter";
102
- NodeType[NodeType["FunctionArgument"] = 63] = "FunctionArgument";
103
- NodeType[NodeType["KeyframeSelector"] = 64] = "KeyframeSelector";
104
- NodeType[NodeType["ViewPort"] = 65] = "ViewPort";
105
- NodeType[NodeType["Document"] = 66] = "Document";
106
- NodeType[NodeType["AtApplyRule"] = 67] = "AtApplyRule";
107
- NodeType[NodeType["CustomPropertyDeclaration"] = 68] = "CustomPropertyDeclaration";
108
- NodeType[NodeType["CustomPropertySet"] = 69] = "CustomPropertySet";
109
- NodeType[NodeType["ListEntry"] = 70] = "ListEntry";
110
- NodeType[NodeType["Supports"] = 71] = "Supports";
111
- NodeType[NodeType["SupportsCondition"] = 72] = "SupportsCondition";
112
- NodeType[NodeType["NamespacePrefix"] = 73] = "NamespacePrefix";
113
- NodeType[NodeType["GridLine"] = 74] = "GridLine";
114
- NodeType[NodeType["Plugin"] = 75] = "Plugin";
115
- NodeType[NodeType["UnknownAtRule"] = 76] = "UnknownAtRule";
116
- NodeType[NodeType["Use"] = 77] = "Use";
117
- NodeType[NodeType["ModuleConfiguration"] = 78] = "ModuleConfiguration";
118
- NodeType[NodeType["Forward"] = 79] = "Forward";
119
- NodeType[NodeType["ForwardVisibility"] = 80] = "ForwardVisibility";
120
- NodeType[NodeType["Module"] = 81] = "Module";
121
- NodeType[NodeType["UnicodeRange"] = 82] = "UnicodeRange";
122
- })(NodeType = exports.NodeType || (exports.NodeType = {}));
123
- var ReferenceType;
124
- (function (ReferenceType) {
125
- ReferenceType[ReferenceType["Mixin"] = 0] = "Mixin";
126
- ReferenceType[ReferenceType["Rule"] = 1] = "Rule";
127
- ReferenceType[ReferenceType["Variable"] = 2] = "Variable";
128
- ReferenceType[ReferenceType["Function"] = 3] = "Function";
129
- ReferenceType[ReferenceType["Keyframe"] = 4] = "Keyframe";
130
- ReferenceType[ReferenceType["Unknown"] = 5] = "Unknown";
131
- ReferenceType[ReferenceType["Module"] = 6] = "Module";
132
- ReferenceType[ReferenceType["Forward"] = 7] = "Forward";
133
- ReferenceType[ReferenceType["ForwardVisibility"] = 8] = "ForwardVisibility";
134
- })(ReferenceType = exports.ReferenceType || (exports.ReferenceType = {}));
135
- function getNodeAtOffset(node, offset) {
136
- var candidate = null;
137
- if (!node || offset < node.offset || offset > node.end) {
138
- return null;
139
- }
140
- // Find the shortest node at the position
141
- node.accept(function (node) {
142
- if (node.offset === -1 && node.length === -1) {
143
- return true;
144
- }
145
- if (node.offset <= offset && node.end >= offset) {
146
- if (!candidate) {
147
- candidate = node;
148
- }
149
- else if (node.length <= candidate.length) {
150
- candidate = node;
151
- }
152
- return true;
153
- }
154
- return false;
155
- });
156
- return candidate;
157
- }
158
- exports.getNodeAtOffset = getNodeAtOffset;
159
- function getNodePath(node, offset) {
160
- var candidate = getNodeAtOffset(node, offset);
161
- var path = [];
162
- while (candidate) {
163
- path.unshift(candidate);
164
- candidate = candidate.parent;
165
- }
166
- return path;
167
- }
168
- exports.getNodePath = getNodePath;
169
- function getParentDeclaration(node) {
170
- var decl = node.findParent(NodeType.Declaration);
171
- var value = decl && decl.getValue();
172
- if (value && value.encloses(node)) {
173
- return decl;
174
- }
175
- return null;
176
- }
177
- exports.getParentDeclaration = getParentDeclaration;
178
- var Node = /** @class */ (function () {
179
- function Node(offset, len, nodeType) {
180
- if (offset === void 0) { offset = -1; }
181
- if (len === void 0) { len = -1; }
182
- this.parent = null;
183
- this.offset = offset;
184
- this.length = len;
185
- if (nodeType) {
186
- this.nodeType = nodeType;
187
- }
188
- }
189
- Object.defineProperty(Node.prototype, "end", {
190
- get: function () { return this.offset + this.length; },
191
- enumerable: false,
192
- configurable: true
193
- });
194
- Object.defineProperty(Node.prototype, "type", {
195
- get: function () {
196
- return this.nodeType || NodeType.Undefined;
197
- },
198
- set: function (type) {
199
- this.nodeType = type;
200
- },
201
- enumerable: false,
202
- configurable: true
203
- });
204
- Node.prototype.getTextProvider = function () {
205
- var node = this;
206
- while (node && !node.textProvider) {
207
- node = node.parent;
208
- }
209
- if (node) {
210
- return node.textProvider;
211
- }
212
- return function () { return 'unknown'; };
213
- };
214
- Node.prototype.getText = function () {
215
- return this.getTextProvider()(this.offset, this.length);
216
- };
217
- Node.prototype.matches = function (str) {
218
- return this.length === str.length && this.getTextProvider()(this.offset, this.length) === str;
219
- };
220
- Node.prototype.startsWith = function (str) {
221
- return this.length >= str.length && this.getTextProvider()(this.offset, str.length) === str;
222
- };
223
- Node.prototype.endsWith = function (str) {
224
- return this.length >= str.length && this.getTextProvider()(this.end - str.length, str.length) === str;
225
- };
226
- Node.prototype.accept = function (visitor) {
227
- if (visitor(this) && this.children) {
228
- for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
229
- var child = _a[_i];
230
- child.accept(visitor);
231
- }
232
- }
233
- };
234
- Node.prototype.acceptVisitor = function (visitor) {
235
- this.accept(visitor.visitNode.bind(visitor));
236
- };
237
- Node.prototype.adoptChild = function (node, index) {
238
- if (index === void 0) { index = -1; }
239
- if (node.parent && node.parent.children) {
240
- var idx = node.parent.children.indexOf(node);
241
- if (idx >= 0) {
242
- node.parent.children.splice(idx, 1);
243
- }
244
- }
245
- node.parent = this;
246
- var children = this.children;
247
- if (!children) {
248
- children = this.children = [];
249
- }
250
- if (index !== -1) {
251
- children.splice(index, 0, node);
252
- }
253
- else {
254
- children.push(node);
255
- }
256
- return node;
257
- };
258
- Node.prototype.attachTo = function (parent, index) {
259
- if (index === void 0) { index = -1; }
260
- if (parent) {
261
- parent.adoptChild(this, index);
262
- }
263
- return this;
264
- };
265
- Node.prototype.collectIssues = function (results) {
266
- if (this.issues) {
267
- results.push.apply(results, this.issues);
268
- }
269
- };
270
- Node.prototype.addIssue = function (issue) {
271
- if (!this.issues) {
272
- this.issues = [];
273
- }
274
- this.issues.push(issue);
275
- };
276
- Node.prototype.hasIssue = function (rule) {
277
- return Array.isArray(this.issues) && this.issues.some(function (i) { return i.getRule() === rule; });
278
- };
279
- Node.prototype.isErroneous = function (recursive) {
280
- if (recursive === void 0) { recursive = false; }
281
- if (this.issues && this.issues.length > 0) {
282
- return true;
283
- }
284
- return recursive && Array.isArray(this.children) && this.children.some(function (c) { return c.isErroneous(true); });
285
- };
286
- Node.prototype.setNode = function (field, node, index) {
287
- if (index === void 0) { index = -1; }
288
- if (node) {
289
- node.attachTo(this, index);
290
- this[field] = node;
291
- return true;
292
- }
293
- return false;
294
- };
295
- Node.prototype.addChild = function (node) {
296
- if (node) {
297
- if (!this.children) {
298
- this.children = [];
299
- }
300
- node.attachTo(this);
301
- this.updateOffsetAndLength(node);
302
- return true;
303
- }
304
- return false;
305
- };
306
- Node.prototype.updateOffsetAndLength = function (node) {
307
- if (node.offset < this.offset || this.offset === -1) {
308
- this.offset = node.offset;
309
- }
310
- var nodeEnd = node.end;
311
- if ((nodeEnd > this.end) || this.length === -1) {
312
- this.length = nodeEnd - this.offset;
313
- }
314
- };
315
- Node.prototype.hasChildren = function () {
316
- return !!this.children && this.children.length > 0;
317
- };
318
- Node.prototype.getChildren = function () {
319
- return this.children ? this.children.slice(0) : [];
320
- };
321
- Node.prototype.getChild = function (index) {
322
- if (this.children && index < this.children.length) {
323
- return this.children[index];
324
- }
325
- return null;
326
- };
327
- Node.prototype.addChildren = function (nodes) {
328
- for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
329
- var node = nodes_1[_i];
330
- this.addChild(node);
331
- }
332
- };
333
- Node.prototype.findFirstChildBeforeOffset = function (offset) {
334
- if (this.children) {
335
- var current = null;
336
- for (var i = this.children.length - 1; i >= 0; i--) {
337
- // iterate until we find a child that has a start offset smaller than the input offset
338
- current = this.children[i];
339
- if (current.offset <= offset) {
340
- return current;
341
- }
342
- }
343
- }
344
- return null;
345
- };
346
- Node.prototype.findChildAtOffset = function (offset, goDeep) {
347
- var current = this.findFirstChildBeforeOffset(offset);
348
- if (current && current.end >= offset) {
349
- if (goDeep) {
350
- return current.findChildAtOffset(offset, true) || current;
351
- }
352
- return current;
353
- }
354
- return null;
355
- };
356
- Node.prototype.encloses = function (candidate) {
357
- return this.offset <= candidate.offset && this.offset + this.length >= candidate.offset + candidate.length;
358
- };
359
- Node.prototype.getParent = function () {
360
- var result = this.parent;
361
- while (result instanceof Nodelist) {
362
- result = result.parent;
363
- }
364
- return result;
365
- };
366
- Node.prototype.findParent = function (type) {
367
- var result = this;
368
- while (result && result.type !== type) {
369
- result = result.parent;
370
- }
371
- return result;
372
- };
373
- Node.prototype.findAParent = function () {
374
- var types = [];
375
- for (var _i = 0; _i < arguments.length; _i++) {
376
- types[_i] = arguments[_i];
377
- }
378
- var result = this;
379
- while (result && !types.some(function (t) { return result.type === t; })) {
380
- result = result.parent;
381
- }
382
- return result;
383
- };
384
- Node.prototype.setData = function (key, value) {
385
- if (!this.options) {
386
- this.options = {};
387
- }
388
- this.options[key] = value;
389
- };
390
- Node.prototype.getData = function (key) {
391
- if (!this.options || !this.options.hasOwnProperty(key)) {
392
- return null;
393
- }
394
- return this.options[key];
395
- };
396
- return Node;
397
- }());
398
- exports.Node = Node;
399
- var Nodelist = /** @class */ (function (_super) {
400
- __extends(Nodelist, _super);
401
- function Nodelist(parent, index) {
402
- if (index === void 0) { index = -1; }
403
- var _this = _super.call(this, -1, -1) || this;
404
- _this.attachTo(parent, index);
405
- _this.offset = -1;
406
- _this.length = -1;
407
- return _this;
408
- }
409
- return Nodelist;
410
- }(Node));
411
- exports.Nodelist = Nodelist;
412
- var UnicodeRange = /** @class */ (function (_super) {
413
- __extends(UnicodeRange, _super);
414
- function UnicodeRange(offset, length) {
415
- return _super.call(this, offset, length) || this;
416
- }
417
- Object.defineProperty(UnicodeRange.prototype, "type", {
418
- get: function () {
419
- return NodeType.UnicodeRange;
420
- },
421
- enumerable: false,
422
- configurable: true
423
- });
424
- UnicodeRange.prototype.setRangeStart = function (rangeStart) {
425
- return this.setNode('rangeStart', rangeStart);
426
- };
427
- UnicodeRange.prototype.getRangeStart = function () {
428
- return this.rangeStart;
429
- };
430
- UnicodeRange.prototype.setRangeEnd = function (rangeEnd) {
431
- return this.setNode('rangeEnd', rangeEnd);
432
- };
433
- UnicodeRange.prototype.getRangeEnd = function () {
434
- return this.rangeEnd;
435
- };
436
- return UnicodeRange;
437
- }(Node));
438
- exports.UnicodeRange = UnicodeRange;
439
- var Identifier = /** @class */ (function (_super) {
440
- __extends(Identifier, _super);
441
- function Identifier(offset, length) {
442
- var _this = _super.call(this, offset, length) || this;
443
- _this.isCustomProperty = false;
444
- return _this;
445
- }
446
- Object.defineProperty(Identifier.prototype, "type", {
447
- get: function () {
448
- return NodeType.Identifier;
449
- },
450
- enumerable: false,
451
- configurable: true
452
- });
453
- Identifier.prototype.containsInterpolation = function () {
454
- return this.hasChildren();
455
- };
456
- return Identifier;
457
- }(Node));
458
- exports.Identifier = Identifier;
459
- var Stylesheet = /** @class */ (function (_super) {
460
- __extends(Stylesheet, _super);
461
- function Stylesheet(offset, length) {
462
- return _super.call(this, offset, length) || this;
463
- }
464
- Object.defineProperty(Stylesheet.prototype, "type", {
465
- get: function () {
466
- return NodeType.Stylesheet;
467
- },
468
- enumerable: false,
469
- configurable: true
470
- });
471
- return Stylesheet;
472
- }(Node));
473
- exports.Stylesheet = Stylesheet;
474
- var Declarations = /** @class */ (function (_super) {
475
- __extends(Declarations, _super);
476
- function Declarations(offset, length) {
477
- return _super.call(this, offset, length) || this;
478
- }
479
- Object.defineProperty(Declarations.prototype, "type", {
480
- get: function () {
481
- return NodeType.Declarations;
482
- },
483
- enumerable: false,
484
- configurable: true
485
- });
486
- return Declarations;
487
- }(Node));
488
- exports.Declarations = Declarations;
489
- var BodyDeclaration = /** @class */ (function (_super) {
490
- __extends(BodyDeclaration, _super);
491
- function BodyDeclaration(offset, length) {
492
- return _super.call(this, offset, length) || this;
493
- }
494
- BodyDeclaration.prototype.getDeclarations = function () {
495
- return this.declarations;
496
- };
497
- BodyDeclaration.prototype.setDeclarations = function (decls) {
498
- return this.setNode('declarations', decls);
499
- };
500
- return BodyDeclaration;
501
- }(Node));
502
- exports.BodyDeclaration = BodyDeclaration;
503
- var RuleSet = /** @class */ (function (_super) {
504
- __extends(RuleSet, _super);
505
- function RuleSet(offset, length) {
506
- return _super.call(this, offset, length) || this;
507
- }
508
- Object.defineProperty(RuleSet.prototype, "type", {
509
- get: function () {
510
- return NodeType.Ruleset;
511
- },
512
- enumerable: false,
513
- configurable: true
514
- });
515
- RuleSet.prototype.getSelectors = function () {
516
- if (!this.selectors) {
517
- this.selectors = new Nodelist(this);
518
- }
519
- return this.selectors;
520
- };
521
- RuleSet.prototype.isNested = function () {
522
- return !!this.parent && this.parent.findParent(NodeType.Declarations) !== null;
523
- };
524
- return RuleSet;
525
- }(BodyDeclaration));
526
- exports.RuleSet = RuleSet;
527
- var Selector = /** @class */ (function (_super) {
528
- __extends(Selector, _super);
529
- function Selector(offset, length) {
530
- return _super.call(this, offset, length) || this;
531
- }
532
- Object.defineProperty(Selector.prototype, "type", {
533
- get: function () {
534
- return NodeType.Selector;
535
- },
536
- enumerable: false,
537
- configurable: true
538
- });
539
- return Selector;
540
- }(Node));
541
- exports.Selector = Selector;
542
- var SimpleSelector = /** @class */ (function (_super) {
543
- __extends(SimpleSelector, _super);
544
- function SimpleSelector(offset, length) {
545
- return _super.call(this, offset, length) || this;
546
- }
547
- Object.defineProperty(SimpleSelector.prototype, "type", {
548
- get: function () {
549
- return NodeType.SimpleSelector;
550
- },
551
- enumerable: false,
552
- configurable: true
553
- });
554
- return SimpleSelector;
555
- }(Node));
556
- exports.SimpleSelector = SimpleSelector;
557
- var AtApplyRule = /** @class */ (function (_super) {
558
- __extends(AtApplyRule, _super);
559
- function AtApplyRule(offset, length) {
560
- return _super.call(this, offset, length) || this;
561
- }
562
- Object.defineProperty(AtApplyRule.prototype, "type", {
563
- get: function () {
564
- return NodeType.AtApplyRule;
565
- },
566
- enumerable: false,
567
- configurable: true
568
- });
569
- AtApplyRule.prototype.setIdentifier = function (node) {
570
- return this.setNode('identifier', node, 0);
571
- };
572
- AtApplyRule.prototype.getIdentifier = function () {
573
- return this.identifier;
574
- };
575
- AtApplyRule.prototype.getName = function () {
576
- return this.identifier ? this.identifier.getText() : '';
577
- };
578
- return AtApplyRule;
579
- }(Node));
580
- exports.AtApplyRule = AtApplyRule;
581
- var AbstractDeclaration = /** @class */ (function (_super) {
582
- __extends(AbstractDeclaration, _super);
583
- function AbstractDeclaration(offset, length) {
584
- return _super.call(this, offset, length) || this;
585
- }
586
- return AbstractDeclaration;
587
- }(Node));
588
- exports.AbstractDeclaration = AbstractDeclaration;
589
- var CustomPropertySet = /** @class */ (function (_super) {
590
- __extends(CustomPropertySet, _super);
591
- function CustomPropertySet(offset, length) {
592
- return _super.call(this, offset, length) || this;
593
- }
594
- Object.defineProperty(CustomPropertySet.prototype, "type", {
595
- get: function () {
596
- return NodeType.CustomPropertySet;
597
- },
598
- enumerable: false,
599
- configurable: true
600
- });
601
- return CustomPropertySet;
602
- }(BodyDeclaration));
603
- exports.CustomPropertySet = CustomPropertySet;
604
- var Declaration = /** @class */ (function (_super) {
605
- __extends(Declaration, _super);
606
- function Declaration(offset, length) {
607
- var _this = _super.call(this, offset, length) || this;
608
- _this.property = null;
609
- return _this;
610
- }
611
- Object.defineProperty(Declaration.prototype, "type", {
612
- get: function () {
613
- return NodeType.Declaration;
614
- },
615
- enumerable: false,
616
- configurable: true
617
- });
618
- Declaration.prototype.setProperty = function (node) {
619
- return this.setNode('property', node);
620
- };
621
- Declaration.prototype.getProperty = function () {
622
- return this.property;
623
- };
624
- Declaration.prototype.getFullPropertyName = function () {
625
- var propertyName = this.property ? this.property.getName() : 'unknown';
626
- if (this.parent instanceof Declarations && this.parent.getParent() instanceof NestedProperties) {
627
- var parentDecl = this.parent.getParent().getParent();
628
- if (parentDecl instanceof Declaration) {
629
- return parentDecl.getFullPropertyName() + propertyName;
630
- }
631
- }
632
- return propertyName;
633
- };
634
- Declaration.prototype.getNonPrefixedPropertyName = function () {
635
- var propertyName = this.getFullPropertyName();
636
- if (propertyName && propertyName.charAt(0) === '-') {
637
- var vendorPrefixEnd = propertyName.indexOf('-', 1);
638
- if (vendorPrefixEnd !== -1) {
639
- return propertyName.substring(vendorPrefixEnd + 1);
640
- }
641
- }
642
- return propertyName;
643
- };
644
- Declaration.prototype.setValue = function (value) {
645
- return this.setNode('value', value);
646
- };
647
- Declaration.prototype.getValue = function () {
648
- return this.value;
649
- };
650
- Declaration.prototype.setNestedProperties = function (value) {
651
- return this.setNode('nestedProperties', value);
652
- };
653
- Declaration.prototype.getNestedProperties = function () {
654
- return this.nestedProperties;
655
- };
656
- return Declaration;
657
- }(AbstractDeclaration));
658
- exports.Declaration = Declaration;
659
- var CustomPropertyDeclaration = /** @class */ (function (_super) {
660
- __extends(CustomPropertyDeclaration, _super);
661
- function CustomPropertyDeclaration(offset, length) {
662
- return _super.call(this, offset, length) || this;
663
- }
664
- Object.defineProperty(CustomPropertyDeclaration.prototype, "type", {
665
- get: function () {
666
- return NodeType.CustomPropertyDeclaration;
667
- },
668
- enumerable: false,
669
- configurable: true
670
- });
671
- CustomPropertyDeclaration.prototype.setPropertySet = function (value) {
672
- return this.setNode('propertySet', value);
673
- };
674
- CustomPropertyDeclaration.prototype.getPropertySet = function () {
675
- return this.propertySet;
676
- };
677
- return CustomPropertyDeclaration;
678
- }(Declaration));
679
- exports.CustomPropertyDeclaration = CustomPropertyDeclaration;
680
- var Property = /** @class */ (function (_super) {
681
- __extends(Property, _super);
682
- function Property(offset, length) {
683
- return _super.call(this, offset, length) || this;
684
- }
685
- Object.defineProperty(Property.prototype, "type", {
686
- get: function () {
687
- return NodeType.Property;
688
- },
689
- enumerable: false,
690
- configurable: true
691
- });
692
- Property.prototype.setIdentifier = function (value) {
693
- return this.setNode('identifier', value);
694
- };
695
- Property.prototype.getIdentifier = function () {
696
- return this.identifier;
697
- };
698
- Property.prototype.getName = function () {
699
- return (0, strings_1.trim)(this.getText(), /[_\+]+$/); /* +_: less merge */
700
- };
701
- Property.prototype.isCustomProperty = function () {
702
- return !!this.identifier && this.identifier.isCustomProperty;
703
- };
704
- return Property;
705
- }(Node));
706
- exports.Property = Property;
707
- var Invocation = /** @class */ (function (_super) {
708
- __extends(Invocation, _super);
709
- function Invocation(offset, length) {
710
- return _super.call(this, offset, length) || this;
711
- }
712
- Object.defineProperty(Invocation.prototype, "type", {
713
- get: function () {
714
- return NodeType.Invocation;
715
- },
716
- enumerable: false,
717
- configurable: true
718
- });
719
- Invocation.prototype.getArguments = function () {
720
- if (!this.arguments) {
721
- this.arguments = new Nodelist(this);
722
- }
723
- return this.arguments;
724
- };
725
- return Invocation;
726
- }(Node));
727
- exports.Invocation = Invocation;
728
- var Function = /** @class */ (function (_super) {
729
- __extends(Function, _super);
730
- function Function(offset, length) {
731
- return _super.call(this, offset, length) || this;
732
- }
733
- Object.defineProperty(Function.prototype, "type", {
734
- get: function () {
735
- return NodeType.Function;
736
- },
737
- enumerable: false,
738
- configurable: true
739
- });
740
- Function.prototype.setIdentifier = function (node) {
741
- return this.setNode('identifier', node, 0);
742
- };
743
- Function.prototype.getIdentifier = function () {
744
- return this.identifier;
745
- };
746
- Function.prototype.getName = function () {
747
- return this.identifier ? this.identifier.getText() : '';
748
- };
749
- return Function;
750
- }(Invocation));
751
- exports.Function = Function;
752
- var FunctionParameter = /** @class */ (function (_super) {
753
- __extends(FunctionParameter, _super);
754
- function FunctionParameter(offset, length) {
755
- return _super.call(this, offset, length) || this;
756
- }
757
- Object.defineProperty(FunctionParameter.prototype, "type", {
758
- get: function () {
759
- return NodeType.FunctionParameter;
760
- },
761
- enumerable: false,
762
- configurable: true
763
- });
764
- FunctionParameter.prototype.setIdentifier = function (node) {
765
- return this.setNode('identifier', node, 0);
766
- };
767
- FunctionParameter.prototype.getIdentifier = function () {
768
- return this.identifier;
769
- };
770
- FunctionParameter.prototype.getName = function () {
771
- return this.identifier ? this.identifier.getText() : '';
772
- };
773
- FunctionParameter.prototype.setDefaultValue = function (node) {
774
- return this.setNode('defaultValue', node, 0);
775
- };
776
- FunctionParameter.prototype.getDefaultValue = function () {
777
- return this.defaultValue;
778
- };
779
- return FunctionParameter;
780
- }(Node));
781
- exports.FunctionParameter = FunctionParameter;
782
- var FunctionArgument = /** @class */ (function (_super) {
783
- __extends(FunctionArgument, _super);
784
- function FunctionArgument(offset, length) {
785
- return _super.call(this, offset, length) || this;
786
- }
787
- Object.defineProperty(FunctionArgument.prototype, "type", {
788
- get: function () {
789
- return NodeType.FunctionArgument;
790
- },
791
- enumerable: false,
792
- configurable: true
793
- });
794
- FunctionArgument.prototype.setIdentifier = function (node) {
795
- return this.setNode('identifier', node, 0);
796
- };
797
- FunctionArgument.prototype.getIdentifier = function () {
798
- return this.identifier;
799
- };
800
- FunctionArgument.prototype.getName = function () {
801
- return this.identifier ? this.identifier.getText() : '';
802
- };
803
- FunctionArgument.prototype.setValue = function (node) {
804
- return this.setNode('value', node, 0);
805
- };
806
- FunctionArgument.prototype.getValue = function () {
807
- return this.value;
808
- };
809
- return FunctionArgument;
810
- }(Node));
811
- exports.FunctionArgument = FunctionArgument;
812
- var IfStatement = /** @class */ (function (_super) {
813
- __extends(IfStatement, _super);
814
- function IfStatement(offset, length) {
815
- return _super.call(this, offset, length) || this;
816
- }
817
- Object.defineProperty(IfStatement.prototype, "type", {
818
- get: function () {
819
- return NodeType.If;
820
- },
821
- enumerable: false,
822
- configurable: true
823
- });
824
- IfStatement.prototype.setExpression = function (node) {
825
- return this.setNode('expression', node, 0);
826
- };
827
- IfStatement.prototype.setElseClause = function (elseClause) {
828
- return this.setNode('elseClause', elseClause);
829
- };
830
- return IfStatement;
831
- }(BodyDeclaration));
832
- exports.IfStatement = IfStatement;
833
- var ForStatement = /** @class */ (function (_super) {
834
- __extends(ForStatement, _super);
835
- function ForStatement(offset, length) {
836
- return _super.call(this, offset, length) || this;
837
- }
838
- Object.defineProperty(ForStatement.prototype, "type", {
839
- get: function () {
840
- return NodeType.For;
841
- },
842
- enumerable: false,
843
- configurable: true
844
- });
845
- ForStatement.prototype.setVariable = function (node) {
846
- return this.setNode('variable', node, 0);
847
- };
848
- return ForStatement;
849
- }(BodyDeclaration));
850
- exports.ForStatement = ForStatement;
851
- var EachStatement = /** @class */ (function (_super) {
852
- __extends(EachStatement, _super);
853
- function EachStatement(offset, length) {
854
- return _super.call(this, offset, length) || this;
855
- }
856
- Object.defineProperty(EachStatement.prototype, "type", {
857
- get: function () {
858
- return NodeType.Each;
859
- },
860
- enumerable: false,
861
- configurable: true
862
- });
863
- EachStatement.prototype.getVariables = function () {
864
- if (!this.variables) {
865
- this.variables = new Nodelist(this);
866
- }
867
- return this.variables;
868
- };
869
- return EachStatement;
870
- }(BodyDeclaration));
871
- exports.EachStatement = EachStatement;
872
- var WhileStatement = /** @class */ (function (_super) {
873
- __extends(WhileStatement, _super);
874
- function WhileStatement(offset, length) {
875
- return _super.call(this, offset, length) || this;
876
- }
877
- Object.defineProperty(WhileStatement.prototype, "type", {
878
- get: function () {
879
- return NodeType.While;
880
- },
881
- enumerable: false,
882
- configurable: true
883
- });
884
- return WhileStatement;
885
- }(BodyDeclaration));
886
- exports.WhileStatement = WhileStatement;
887
- var ElseStatement = /** @class */ (function (_super) {
888
- __extends(ElseStatement, _super);
889
- function ElseStatement(offset, length) {
890
- return _super.call(this, offset, length) || this;
891
- }
892
- Object.defineProperty(ElseStatement.prototype, "type", {
893
- get: function () {
894
- return NodeType.Else;
895
- },
896
- enumerable: false,
897
- configurable: true
898
- });
899
- return ElseStatement;
900
- }(BodyDeclaration));
901
- exports.ElseStatement = ElseStatement;
902
- var FunctionDeclaration = /** @class */ (function (_super) {
903
- __extends(FunctionDeclaration, _super);
904
- function FunctionDeclaration(offset, length) {
905
- return _super.call(this, offset, length) || this;
906
- }
907
- Object.defineProperty(FunctionDeclaration.prototype, "type", {
908
- get: function () {
909
- return NodeType.FunctionDeclaration;
910
- },
911
- enumerable: false,
912
- configurable: true
913
- });
914
- FunctionDeclaration.prototype.setIdentifier = function (node) {
915
- return this.setNode('identifier', node, 0);
916
- };
917
- FunctionDeclaration.prototype.getIdentifier = function () {
918
- return this.identifier;
919
- };
920
- FunctionDeclaration.prototype.getName = function () {
921
- return this.identifier ? this.identifier.getText() : '';
922
- };
923
- FunctionDeclaration.prototype.getParameters = function () {
924
- if (!this.parameters) {
925
- this.parameters = new Nodelist(this);
926
- }
927
- return this.parameters;
928
- };
929
- return FunctionDeclaration;
930
- }(BodyDeclaration));
931
- exports.FunctionDeclaration = FunctionDeclaration;
932
- var ViewPort = /** @class */ (function (_super) {
933
- __extends(ViewPort, _super);
934
- function ViewPort(offset, length) {
935
- return _super.call(this, offset, length) || this;
936
- }
937
- Object.defineProperty(ViewPort.prototype, "type", {
938
- get: function () {
939
- return NodeType.ViewPort;
940
- },
941
- enumerable: false,
942
- configurable: true
943
- });
944
- return ViewPort;
945
- }(BodyDeclaration));
946
- exports.ViewPort = ViewPort;
947
- var FontFace = /** @class */ (function (_super) {
948
- __extends(FontFace, _super);
949
- function FontFace(offset, length) {
950
- return _super.call(this, offset, length) || this;
951
- }
952
- Object.defineProperty(FontFace.prototype, "type", {
953
- get: function () {
954
- return NodeType.FontFace;
955
- },
956
- enumerable: false,
957
- configurable: true
958
- });
959
- return FontFace;
960
- }(BodyDeclaration));
961
- exports.FontFace = FontFace;
962
- var NestedProperties = /** @class */ (function (_super) {
963
- __extends(NestedProperties, _super);
964
- function NestedProperties(offset, length) {
965
- return _super.call(this, offset, length) || this;
966
- }
967
- Object.defineProperty(NestedProperties.prototype, "type", {
968
- get: function () {
969
- return NodeType.NestedProperties;
970
- },
971
- enumerable: false,
972
- configurable: true
973
- });
974
- return NestedProperties;
975
- }(BodyDeclaration));
976
- exports.NestedProperties = NestedProperties;
977
- var Keyframe = /** @class */ (function (_super) {
978
- __extends(Keyframe, _super);
979
- function Keyframe(offset, length) {
980
- return _super.call(this, offset, length) || this;
981
- }
982
- Object.defineProperty(Keyframe.prototype, "type", {
983
- get: function () {
984
- return NodeType.Keyframe;
985
- },
986
- enumerable: false,
987
- configurable: true
988
- });
989
- Keyframe.prototype.setKeyword = function (keyword) {
990
- return this.setNode('keyword', keyword, 0);
991
- };
992
- Keyframe.prototype.getKeyword = function () {
993
- return this.keyword;
994
- };
995
- Keyframe.prototype.setIdentifier = function (node) {
996
- return this.setNode('identifier', node, 0);
997
- };
998
- Keyframe.prototype.getIdentifier = function () {
999
- return this.identifier;
1000
- };
1001
- Keyframe.prototype.getName = function () {
1002
- return this.identifier ? this.identifier.getText() : '';
1003
- };
1004
- return Keyframe;
1005
- }(BodyDeclaration));
1006
- exports.Keyframe = Keyframe;
1007
- var KeyframeSelector = /** @class */ (function (_super) {
1008
- __extends(KeyframeSelector, _super);
1009
- function KeyframeSelector(offset, length) {
1010
- return _super.call(this, offset, length) || this;
1011
- }
1012
- Object.defineProperty(KeyframeSelector.prototype, "type", {
1013
- get: function () {
1014
- return NodeType.KeyframeSelector;
1015
- },
1016
- enumerable: false,
1017
- configurable: true
1018
- });
1019
- return KeyframeSelector;
1020
- }(BodyDeclaration));
1021
- exports.KeyframeSelector = KeyframeSelector;
1022
- var Import = /** @class */ (function (_super) {
1023
- __extends(Import, _super);
1024
- function Import(offset, length) {
1025
- return _super.call(this, offset, length) || this;
1026
- }
1027
- Object.defineProperty(Import.prototype, "type", {
1028
- get: function () {
1029
- return NodeType.Import;
1030
- },
1031
- enumerable: false,
1032
- configurable: true
1033
- });
1034
- Import.prototype.setMedialist = function (node) {
1035
- if (node) {
1036
- node.attachTo(this);
1037
- return true;
1038
- }
1039
- return false;
1040
- };
1041
- return Import;
1042
- }(Node));
1043
- exports.Import = Import;
1044
- var Use = /** @class */ (function (_super) {
1045
- __extends(Use, _super);
1046
- function Use() {
1047
- return _super !== null && _super.apply(this, arguments) || this;
1048
- }
1049
- Object.defineProperty(Use.prototype, "type", {
1050
- get: function () {
1051
- return NodeType.Use;
1052
- },
1053
- enumerable: false,
1054
- configurable: true
1055
- });
1056
- Use.prototype.getParameters = function () {
1057
- if (!this.parameters) {
1058
- this.parameters = new Nodelist(this);
1059
- }
1060
- return this.parameters;
1061
- };
1062
- Use.prototype.setIdentifier = function (node) {
1063
- return this.setNode('identifier', node, 0);
1064
- };
1065
- Use.prototype.getIdentifier = function () {
1066
- return this.identifier;
1067
- };
1068
- return Use;
1069
- }(Node));
1070
- exports.Use = Use;
1071
- var ModuleConfiguration = /** @class */ (function (_super) {
1072
- __extends(ModuleConfiguration, _super);
1073
- function ModuleConfiguration() {
1074
- return _super !== null && _super.apply(this, arguments) || this;
1075
- }
1076
- Object.defineProperty(ModuleConfiguration.prototype, "type", {
1077
- get: function () {
1078
- return NodeType.ModuleConfiguration;
1079
- },
1080
- enumerable: false,
1081
- configurable: true
1082
- });
1083
- ModuleConfiguration.prototype.setIdentifier = function (node) {
1084
- return this.setNode('identifier', node, 0);
1085
- };
1086
- ModuleConfiguration.prototype.getIdentifier = function () {
1087
- return this.identifier;
1088
- };
1089
- ModuleConfiguration.prototype.getName = function () {
1090
- return this.identifier ? this.identifier.getText() : '';
1091
- };
1092
- ModuleConfiguration.prototype.setValue = function (node) {
1093
- return this.setNode('value', node, 0);
1094
- };
1095
- ModuleConfiguration.prototype.getValue = function () {
1096
- return this.value;
1097
- };
1098
- return ModuleConfiguration;
1099
- }(Node));
1100
- exports.ModuleConfiguration = ModuleConfiguration;
1101
- var Forward = /** @class */ (function (_super) {
1102
- __extends(Forward, _super);
1103
- function Forward() {
1104
- return _super !== null && _super.apply(this, arguments) || this;
1105
- }
1106
- Object.defineProperty(Forward.prototype, "type", {
1107
- get: function () {
1108
- return NodeType.Forward;
1109
- },
1110
- enumerable: false,
1111
- configurable: true
1112
- });
1113
- Forward.prototype.setIdentifier = function (node) {
1114
- return this.setNode('identifier', node, 0);
1115
- };
1116
- Forward.prototype.getIdentifier = function () {
1117
- return this.identifier;
1118
- };
1119
- Forward.prototype.getMembers = function () {
1120
- if (!this.members) {
1121
- this.members = new Nodelist(this);
1122
- }
1123
- return this.members;
1124
- };
1125
- Forward.prototype.getParameters = function () {
1126
- if (!this.parameters) {
1127
- this.parameters = new Nodelist(this);
1128
- }
1129
- return this.parameters;
1130
- };
1131
- return Forward;
1132
- }(Node));
1133
- exports.Forward = Forward;
1134
- var ForwardVisibility = /** @class */ (function (_super) {
1135
- __extends(ForwardVisibility, _super);
1136
- function ForwardVisibility() {
1137
- return _super !== null && _super.apply(this, arguments) || this;
1138
- }
1139
- Object.defineProperty(ForwardVisibility.prototype, "type", {
1140
- get: function () {
1141
- return NodeType.ForwardVisibility;
1142
- },
1143
- enumerable: false,
1144
- configurable: true
1145
- });
1146
- ForwardVisibility.prototype.setIdentifier = function (node) {
1147
- return this.setNode('identifier', node, 0);
1148
- };
1149
- ForwardVisibility.prototype.getIdentifier = function () {
1150
- return this.identifier;
1151
- };
1152
- return ForwardVisibility;
1153
- }(Node));
1154
- exports.ForwardVisibility = ForwardVisibility;
1155
- var Namespace = /** @class */ (function (_super) {
1156
- __extends(Namespace, _super);
1157
- function Namespace(offset, length) {
1158
- return _super.call(this, offset, length) || this;
1159
- }
1160
- Object.defineProperty(Namespace.prototype, "type", {
1161
- get: function () {
1162
- return NodeType.Namespace;
1163
- },
1164
- enumerable: false,
1165
- configurable: true
1166
- });
1167
- return Namespace;
1168
- }(Node));
1169
- exports.Namespace = Namespace;
1170
- var Media = /** @class */ (function (_super) {
1171
- __extends(Media, _super);
1172
- function Media(offset, length) {
1173
- return _super.call(this, offset, length) || this;
1174
- }
1175
- Object.defineProperty(Media.prototype, "type", {
1176
- get: function () {
1177
- return NodeType.Media;
1178
- },
1179
- enumerable: false,
1180
- configurable: true
1181
- });
1182
- return Media;
1183
- }(BodyDeclaration));
1184
- exports.Media = Media;
1185
- var Supports = /** @class */ (function (_super) {
1186
- __extends(Supports, _super);
1187
- function Supports(offset, length) {
1188
- return _super.call(this, offset, length) || this;
1189
- }
1190
- Object.defineProperty(Supports.prototype, "type", {
1191
- get: function () {
1192
- return NodeType.Supports;
1193
- },
1194
- enumerable: false,
1195
- configurable: true
1196
- });
1197
- return Supports;
1198
- }(BodyDeclaration));
1199
- exports.Supports = Supports;
1200
- var Document = /** @class */ (function (_super) {
1201
- __extends(Document, _super);
1202
- function Document(offset, length) {
1203
- return _super.call(this, offset, length) || this;
1204
- }
1205
- Object.defineProperty(Document.prototype, "type", {
1206
- get: function () {
1207
- return NodeType.Document;
1208
- },
1209
- enumerable: false,
1210
- configurable: true
1211
- });
1212
- return Document;
1213
- }(BodyDeclaration));
1214
- exports.Document = Document;
1215
- var Medialist = /** @class */ (function (_super) {
1216
- __extends(Medialist, _super);
1217
- function Medialist(offset, length) {
1218
- return _super.call(this, offset, length) || this;
1219
- }
1220
- Medialist.prototype.getMediums = function () {
1221
- if (!this.mediums) {
1222
- this.mediums = new Nodelist(this);
1223
- }
1224
- return this.mediums;
1225
- };
1226
- return Medialist;
1227
- }(Node));
1228
- exports.Medialist = Medialist;
1229
- var MediaQuery = /** @class */ (function (_super) {
1230
- __extends(MediaQuery, _super);
1231
- function MediaQuery(offset, length) {
1232
- return _super.call(this, offset, length) || this;
1233
- }
1234
- Object.defineProperty(MediaQuery.prototype, "type", {
1235
- get: function () {
1236
- return NodeType.MediaQuery;
1237
- },
1238
- enumerable: false,
1239
- configurable: true
1240
- });
1241
- return MediaQuery;
1242
- }(Node));
1243
- exports.MediaQuery = MediaQuery;
1244
- var MediaCondition = /** @class */ (function (_super) {
1245
- __extends(MediaCondition, _super);
1246
- function MediaCondition(offset, length) {
1247
- return _super.call(this, offset, length) || this;
1248
- }
1249
- Object.defineProperty(MediaCondition.prototype, "type", {
1250
- get: function () {
1251
- return NodeType.MediaCondition;
1252
- },
1253
- enumerable: false,
1254
- configurable: true
1255
- });
1256
- return MediaCondition;
1257
- }(Node));
1258
- exports.MediaCondition = MediaCondition;
1259
- var MediaFeature = /** @class */ (function (_super) {
1260
- __extends(MediaFeature, _super);
1261
- function MediaFeature(offset, length) {
1262
- return _super.call(this, offset, length) || this;
1263
- }
1264
- Object.defineProperty(MediaFeature.prototype, "type", {
1265
- get: function () {
1266
- return NodeType.MediaFeature;
1267
- },
1268
- enumerable: false,
1269
- configurable: true
1270
- });
1271
- return MediaFeature;
1272
- }(Node));
1273
- exports.MediaFeature = MediaFeature;
1274
- var SupportsCondition = /** @class */ (function (_super) {
1275
- __extends(SupportsCondition, _super);
1276
- function SupportsCondition(offset, length) {
1277
- return _super.call(this, offset, length) || this;
1278
- }
1279
- Object.defineProperty(SupportsCondition.prototype, "type", {
1280
- get: function () {
1281
- return NodeType.SupportsCondition;
1282
- },
1283
- enumerable: false,
1284
- configurable: true
1285
- });
1286
- return SupportsCondition;
1287
- }(Node));
1288
- exports.SupportsCondition = SupportsCondition;
1289
- var Page = /** @class */ (function (_super) {
1290
- __extends(Page, _super);
1291
- function Page(offset, length) {
1292
- return _super.call(this, offset, length) || this;
1293
- }
1294
- Object.defineProperty(Page.prototype, "type", {
1295
- get: function () {
1296
- return NodeType.Page;
1297
- },
1298
- enumerable: false,
1299
- configurable: true
1300
- });
1301
- return Page;
1302
- }(BodyDeclaration));
1303
- exports.Page = Page;
1304
- var PageBoxMarginBox = /** @class */ (function (_super) {
1305
- __extends(PageBoxMarginBox, _super);
1306
- function PageBoxMarginBox(offset, length) {
1307
- return _super.call(this, offset, length) || this;
1308
- }
1309
- Object.defineProperty(PageBoxMarginBox.prototype, "type", {
1310
- get: function () {
1311
- return NodeType.PageBoxMarginBox;
1312
- },
1313
- enumerable: false,
1314
- configurable: true
1315
- });
1316
- return PageBoxMarginBox;
1317
- }(BodyDeclaration));
1318
- exports.PageBoxMarginBox = PageBoxMarginBox;
1319
- var Expression = /** @class */ (function (_super) {
1320
- __extends(Expression, _super);
1321
- function Expression(offset, length) {
1322
- return _super.call(this, offset, length) || this;
1323
- }
1324
- Object.defineProperty(Expression.prototype, "type", {
1325
- get: function () {
1326
- return NodeType.Expression;
1327
- },
1328
- enumerable: false,
1329
- configurable: true
1330
- });
1331
- return Expression;
1332
- }(Node));
1333
- exports.Expression = Expression;
1334
- var BinaryExpression = /** @class */ (function (_super) {
1335
- __extends(BinaryExpression, _super);
1336
- function BinaryExpression(offset, length) {
1337
- return _super.call(this, offset, length) || this;
1338
- }
1339
- Object.defineProperty(BinaryExpression.prototype, "type", {
1340
- get: function () {
1341
- return NodeType.BinaryExpression;
1342
- },
1343
- enumerable: false,
1344
- configurable: true
1345
- });
1346
- BinaryExpression.prototype.setLeft = function (left) {
1347
- return this.setNode('left', left);
1348
- };
1349
- BinaryExpression.prototype.getLeft = function () {
1350
- return this.left;
1351
- };
1352
- BinaryExpression.prototype.setRight = function (right) {
1353
- return this.setNode('right', right);
1354
- };
1355
- BinaryExpression.prototype.getRight = function () {
1356
- return this.right;
1357
- };
1358
- BinaryExpression.prototype.setOperator = function (value) {
1359
- return this.setNode('operator', value);
1360
- };
1361
- BinaryExpression.prototype.getOperator = function () {
1362
- return this.operator;
1363
- };
1364
- return BinaryExpression;
1365
- }(Node));
1366
- exports.BinaryExpression = BinaryExpression;
1367
- var Term = /** @class */ (function (_super) {
1368
- __extends(Term, _super);
1369
- function Term(offset, length) {
1370
- return _super.call(this, offset, length) || this;
1371
- }
1372
- Object.defineProperty(Term.prototype, "type", {
1373
- get: function () {
1374
- return NodeType.Term;
1375
- },
1376
- enumerable: false,
1377
- configurable: true
1378
- });
1379
- Term.prototype.setOperator = function (value) {
1380
- return this.setNode('operator', value);
1381
- };
1382
- Term.prototype.getOperator = function () {
1383
- return this.operator;
1384
- };
1385
- Term.prototype.setExpression = function (value) {
1386
- return this.setNode('expression', value);
1387
- };
1388
- Term.prototype.getExpression = function () {
1389
- return this.expression;
1390
- };
1391
- return Term;
1392
- }(Node));
1393
- exports.Term = Term;
1394
- var AttributeSelector = /** @class */ (function (_super) {
1395
- __extends(AttributeSelector, _super);
1396
- function AttributeSelector(offset, length) {
1397
- return _super.call(this, offset, length) || this;
1398
- }
1399
- Object.defineProperty(AttributeSelector.prototype, "type", {
1400
- get: function () {
1401
- return NodeType.AttributeSelector;
1402
- },
1403
- enumerable: false,
1404
- configurable: true
1405
- });
1406
- AttributeSelector.prototype.setNamespacePrefix = function (value) {
1407
- return this.setNode('namespacePrefix', value);
1408
- };
1409
- AttributeSelector.prototype.getNamespacePrefix = function () {
1410
- return this.namespacePrefix;
1411
- };
1412
- AttributeSelector.prototype.setIdentifier = function (value) {
1413
- return this.setNode('identifier', value);
1414
- };
1415
- AttributeSelector.prototype.getIdentifier = function () {
1416
- return this.identifier;
1417
- };
1418
- AttributeSelector.prototype.setOperator = function (operator) {
1419
- return this.setNode('operator', operator);
1420
- };
1421
- AttributeSelector.prototype.getOperator = function () {
1422
- return this.operator;
1423
- };
1424
- AttributeSelector.prototype.setValue = function (value) {
1425
- return this.setNode('value', value);
1426
- };
1427
- AttributeSelector.prototype.getValue = function () {
1428
- return this.value;
1429
- };
1430
- return AttributeSelector;
1431
- }(Node));
1432
- exports.AttributeSelector = AttributeSelector;
1433
- var Operator = /** @class */ (function (_super) {
1434
- __extends(Operator, _super);
1435
- function Operator(offset, length) {
1436
- return _super.call(this, offset, length) || this;
1437
- }
1438
- Object.defineProperty(Operator.prototype, "type", {
1439
- get: function () {
1440
- return NodeType.Operator;
1441
- },
1442
- enumerable: false,
1443
- configurable: true
1444
- });
1445
- return Operator;
1446
- }(Node));
1447
- exports.Operator = Operator;
1448
- var HexColorValue = /** @class */ (function (_super) {
1449
- __extends(HexColorValue, _super);
1450
- function HexColorValue(offset, length) {
1451
- return _super.call(this, offset, length) || this;
1452
- }
1453
- Object.defineProperty(HexColorValue.prototype, "type", {
1454
- get: function () {
1455
- return NodeType.HexColorValue;
1456
- },
1457
- enumerable: false,
1458
- configurable: true
1459
- });
1460
- return HexColorValue;
1461
- }(Node));
1462
- exports.HexColorValue = HexColorValue;
1463
- var RatioValue = /** @class */ (function (_super) {
1464
- __extends(RatioValue, _super);
1465
- function RatioValue(offset, length) {
1466
- return _super.call(this, offset, length) || this;
1467
- }
1468
- Object.defineProperty(RatioValue.prototype, "type", {
1469
- get: function () {
1470
- return NodeType.RatioValue;
1471
- },
1472
- enumerable: false,
1473
- configurable: true
1474
- });
1475
- return RatioValue;
1476
- }(Node));
1477
- exports.RatioValue = RatioValue;
1478
- var _dot = '.'.charCodeAt(0), _0 = '0'.charCodeAt(0), _9 = '9'.charCodeAt(0);
1479
- var NumericValue = /** @class */ (function (_super) {
1480
- __extends(NumericValue, _super);
1481
- function NumericValue(offset, length) {
1482
- return _super.call(this, offset, length) || this;
1483
- }
1484
- Object.defineProperty(NumericValue.prototype, "type", {
1485
- get: function () {
1486
- return NodeType.NumericValue;
1487
- },
1488
- enumerable: false,
1489
- configurable: true
1490
- });
1491
- NumericValue.prototype.getValue = function () {
1492
- var raw = this.getText();
1493
- var unitIdx = 0;
1494
- var code;
1495
- for (var i = 0, len = raw.length; i < len; i++) {
1496
- code = raw.charCodeAt(i);
1497
- if (!(_0 <= code && code <= _9 || code === _dot)) {
1498
- break;
1499
- }
1500
- unitIdx += 1;
1501
- }
1502
- return {
1503
- value: raw.substring(0, unitIdx),
1504
- unit: unitIdx < raw.length ? raw.substring(unitIdx) : undefined
1505
- };
1506
- };
1507
- return NumericValue;
1508
- }(Node));
1509
- exports.NumericValue = NumericValue;
1510
- var VariableDeclaration = /** @class */ (function (_super) {
1511
- __extends(VariableDeclaration, _super);
1512
- function VariableDeclaration(offset, length) {
1513
- var _this = _super.call(this, offset, length) || this;
1514
- _this.variable = null;
1515
- _this.value = null;
1516
- _this.needsSemicolon = true;
1517
- return _this;
1518
- }
1519
- Object.defineProperty(VariableDeclaration.prototype, "type", {
1520
- get: function () {
1521
- return NodeType.VariableDeclaration;
1522
- },
1523
- enumerable: false,
1524
- configurable: true
1525
- });
1526
- VariableDeclaration.prototype.setVariable = function (node) {
1527
- if (node) {
1528
- node.attachTo(this);
1529
- this.variable = node;
1530
- return true;
1531
- }
1532
- return false;
1533
- };
1534
- VariableDeclaration.prototype.getVariable = function () {
1535
- return this.variable;
1536
- };
1537
- VariableDeclaration.prototype.getName = function () {
1538
- return this.variable ? this.variable.getName() : '';
1539
- };
1540
- VariableDeclaration.prototype.setValue = function (node) {
1541
- if (node) {
1542
- node.attachTo(this);
1543
- this.value = node;
1544
- return true;
1545
- }
1546
- return false;
1547
- };
1548
- VariableDeclaration.prototype.getValue = function () {
1549
- return this.value;
1550
- };
1551
- return VariableDeclaration;
1552
- }(AbstractDeclaration));
1553
- exports.VariableDeclaration = VariableDeclaration;
1554
- var Interpolation = /** @class */ (function (_super) {
1555
- __extends(Interpolation, _super);
1556
- // private _interpolations: void; // workaround for https://github.com/Microsoft/TypeScript/issues/18276
1557
- function Interpolation(offset, length) {
1558
- return _super.call(this, offset, length) || this;
1559
- }
1560
- Object.defineProperty(Interpolation.prototype, "type", {
1561
- get: function () {
1562
- return NodeType.Interpolation;
1563
- },
1564
- enumerable: false,
1565
- configurable: true
1566
- });
1567
- return Interpolation;
1568
- }(Node));
1569
- exports.Interpolation = Interpolation;
1570
- var Variable = /** @class */ (function (_super) {
1571
- __extends(Variable, _super);
1572
- function Variable(offset, length) {
1573
- return _super.call(this, offset, length) || this;
1574
- }
1575
- Object.defineProperty(Variable.prototype, "type", {
1576
- get: function () {
1577
- return NodeType.VariableName;
1578
- },
1579
- enumerable: false,
1580
- configurable: true
1581
- });
1582
- Variable.prototype.getName = function () {
1583
- return this.getText();
1584
- };
1585
- return Variable;
1586
- }(Node));
1587
- exports.Variable = Variable;
1588
- var ExtendsReference = /** @class */ (function (_super) {
1589
- __extends(ExtendsReference, _super);
1590
- function ExtendsReference(offset, length) {
1591
- return _super.call(this, offset, length) || this;
1592
- }
1593
- Object.defineProperty(ExtendsReference.prototype, "type", {
1594
- get: function () {
1595
- return NodeType.ExtendsReference;
1596
- },
1597
- enumerable: false,
1598
- configurable: true
1599
- });
1600
- ExtendsReference.prototype.getSelectors = function () {
1601
- if (!this.selectors) {
1602
- this.selectors = new Nodelist(this);
1603
- }
1604
- return this.selectors;
1605
- };
1606
- return ExtendsReference;
1607
- }(Node));
1608
- exports.ExtendsReference = ExtendsReference;
1609
- var MixinContentReference = /** @class */ (function (_super) {
1610
- __extends(MixinContentReference, _super);
1611
- function MixinContentReference(offset, length) {
1612
- return _super.call(this, offset, length) || this;
1613
- }
1614
- Object.defineProperty(MixinContentReference.prototype, "type", {
1615
- get: function () {
1616
- return NodeType.MixinContentReference;
1617
- },
1618
- enumerable: false,
1619
- configurable: true
1620
- });
1621
- MixinContentReference.prototype.getArguments = function () {
1622
- if (!this.arguments) {
1623
- this.arguments = new Nodelist(this);
1624
- }
1625
- return this.arguments;
1626
- };
1627
- return MixinContentReference;
1628
- }(Node));
1629
- exports.MixinContentReference = MixinContentReference;
1630
- var MixinContentDeclaration = /** @class */ (function (_super) {
1631
- __extends(MixinContentDeclaration, _super);
1632
- function MixinContentDeclaration(offset, length) {
1633
- return _super.call(this, offset, length) || this;
1634
- }
1635
- Object.defineProperty(MixinContentDeclaration.prototype, "type", {
1636
- get: function () {
1637
- return NodeType.MixinContentReference;
1638
- },
1639
- enumerable: false,
1640
- configurable: true
1641
- });
1642
- MixinContentDeclaration.prototype.getParameters = function () {
1643
- if (!this.parameters) {
1644
- this.parameters = new Nodelist(this);
1645
- }
1646
- return this.parameters;
1647
- };
1648
- return MixinContentDeclaration;
1649
- }(BodyDeclaration));
1650
- exports.MixinContentDeclaration = MixinContentDeclaration;
1651
- var MixinReference = /** @class */ (function (_super) {
1652
- __extends(MixinReference, _super);
1653
- function MixinReference(offset, length) {
1654
- return _super.call(this, offset, length) || this;
1655
- }
1656
- Object.defineProperty(MixinReference.prototype, "type", {
1657
- get: function () {
1658
- return NodeType.MixinReference;
1659
- },
1660
- enumerable: false,
1661
- configurable: true
1662
- });
1663
- MixinReference.prototype.getNamespaces = function () {
1664
- if (!this.namespaces) {
1665
- this.namespaces = new Nodelist(this);
1666
- }
1667
- return this.namespaces;
1668
- };
1669
- MixinReference.prototype.setIdentifier = function (node) {
1670
- return this.setNode('identifier', node, 0);
1671
- };
1672
- MixinReference.prototype.getIdentifier = function () {
1673
- return this.identifier;
1674
- };
1675
- MixinReference.prototype.getName = function () {
1676
- return this.identifier ? this.identifier.getText() : '';
1677
- };
1678
- MixinReference.prototype.getArguments = function () {
1679
- if (!this.arguments) {
1680
- this.arguments = new Nodelist(this);
1681
- }
1682
- return this.arguments;
1683
- };
1684
- MixinReference.prototype.setContent = function (node) {
1685
- return this.setNode('content', node);
1686
- };
1687
- MixinReference.prototype.getContent = function () {
1688
- return this.content;
1689
- };
1690
- return MixinReference;
1691
- }(Node));
1692
- exports.MixinReference = MixinReference;
1693
- var MixinDeclaration = /** @class */ (function (_super) {
1694
- __extends(MixinDeclaration, _super);
1695
- function MixinDeclaration(offset, length) {
1696
- return _super.call(this, offset, length) || this;
1697
- }
1698
- Object.defineProperty(MixinDeclaration.prototype, "type", {
1699
- get: function () {
1700
- return NodeType.MixinDeclaration;
1701
- },
1702
- enumerable: false,
1703
- configurable: true
1704
- });
1705
- MixinDeclaration.prototype.setIdentifier = function (node) {
1706
- return this.setNode('identifier', node, 0);
1707
- };
1708
- MixinDeclaration.prototype.getIdentifier = function () {
1709
- return this.identifier;
1710
- };
1711
- MixinDeclaration.prototype.getName = function () {
1712
- return this.identifier ? this.identifier.getText() : '';
1713
- };
1714
- MixinDeclaration.prototype.getParameters = function () {
1715
- if (!this.parameters) {
1716
- this.parameters = new Nodelist(this);
1717
- }
1718
- return this.parameters;
1719
- };
1720
- MixinDeclaration.prototype.setGuard = function (node) {
1721
- if (node) {
1722
- node.attachTo(this);
1723
- this.guard = node;
1724
- }
1725
- return false;
1726
- };
1727
- return MixinDeclaration;
1728
- }(BodyDeclaration));
1729
- exports.MixinDeclaration = MixinDeclaration;
1730
- var UnknownAtRule = /** @class */ (function (_super) {
1731
- __extends(UnknownAtRule, _super);
1732
- function UnknownAtRule(offset, length) {
1733
- return _super.call(this, offset, length) || this;
1734
- }
1735
- Object.defineProperty(UnknownAtRule.prototype, "type", {
1736
- get: function () {
1737
- return NodeType.UnknownAtRule;
1738
- },
1739
- enumerable: false,
1740
- configurable: true
1741
- });
1742
- UnknownAtRule.prototype.setAtRuleName = function (atRuleName) {
1743
- this.atRuleName = atRuleName;
1744
- };
1745
- UnknownAtRule.prototype.getAtRuleName = function () {
1746
- return this.atRuleName;
1747
- };
1748
- return UnknownAtRule;
1749
- }(BodyDeclaration));
1750
- exports.UnknownAtRule = UnknownAtRule;
1751
- var ListEntry = /** @class */ (function (_super) {
1752
- __extends(ListEntry, _super);
1753
- function ListEntry() {
1754
- return _super !== null && _super.apply(this, arguments) || this;
1755
- }
1756
- Object.defineProperty(ListEntry.prototype, "type", {
1757
- get: function () {
1758
- return NodeType.ListEntry;
1759
- },
1760
- enumerable: false,
1761
- configurable: true
1762
- });
1763
- ListEntry.prototype.setKey = function (node) {
1764
- return this.setNode('key', node, 0);
1765
- };
1766
- ListEntry.prototype.setValue = function (node) {
1767
- return this.setNode('value', node, 1);
1768
- };
1769
- return ListEntry;
1770
- }(Node));
1771
- exports.ListEntry = ListEntry;
1772
- var LessGuard = /** @class */ (function (_super) {
1773
- __extends(LessGuard, _super);
1774
- function LessGuard() {
1775
- return _super !== null && _super.apply(this, arguments) || this;
1776
- }
1777
- LessGuard.prototype.getConditions = function () {
1778
- if (!this.conditions) {
1779
- this.conditions = new Nodelist(this);
1780
- }
1781
- return this.conditions;
1782
- };
1783
- return LessGuard;
1784
- }(Node));
1785
- exports.LessGuard = LessGuard;
1786
- var GuardCondition = /** @class */ (function (_super) {
1787
- __extends(GuardCondition, _super);
1788
- function GuardCondition() {
1789
- return _super !== null && _super.apply(this, arguments) || this;
1790
- }
1791
- GuardCondition.prototype.setVariable = function (node) {
1792
- return this.setNode('variable', node);
1793
- };
1794
- return GuardCondition;
1795
- }(Node));
1796
- exports.GuardCondition = GuardCondition;
1797
- var Module = /** @class */ (function (_super) {
1798
- __extends(Module, _super);
1799
- function Module() {
1800
- return _super !== null && _super.apply(this, arguments) || this;
1801
- }
1802
- Object.defineProperty(Module.prototype, "type", {
1803
- get: function () {
1804
- return NodeType.Module;
1805
- },
1806
- enumerable: false,
1807
- configurable: true
1808
- });
1809
- Module.prototype.setIdentifier = function (node) {
1810
- return this.setNode('identifier', node, 0);
1811
- };
1812
- Module.prototype.getIdentifier = function () {
1813
- return this.identifier;
1814
- };
1815
- return Module;
1816
- }(Node));
1817
- exports.Module = Module;
1818
- var Level;
1819
- (function (Level) {
1820
- Level[Level["Ignore"] = 1] = "Ignore";
1821
- Level[Level["Warning"] = 2] = "Warning";
1822
- Level[Level["Error"] = 4] = "Error";
1823
- })(Level = exports.Level || (exports.Level = {}));
1824
- var Marker = /** @class */ (function () {
1825
- function Marker(node, rule, level, message, offset, length) {
1826
- if (offset === void 0) { offset = node.offset; }
1827
- if (length === void 0) { length = node.length; }
1828
- this.node = node;
1829
- this.rule = rule;
1830
- this.level = level;
1831
- this.message = message || rule.message;
1832
- this.offset = offset;
1833
- this.length = length;
1834
- }
1835
- Marker.prototype.getRule = function () {
1836
- return this.rule;
1837
- };
1838
- Marker.prototype.getLevel = function () {
1839
- return this.level;
1840
- };
1841
- Marker.prototype.getOffset = function () {
1842
- return this.offset;
1843
- };
1844
- Marker.prototype.getLength = function () {
1845
- return this.length;
1846
- };
1847
- Marker.prototype.getNode = function () {
1848
- return this.node;
1849
- };
1850
- Marker.prototype.getMessage = function () {
1851
- return this.message;
1852
- };
1853
- return Marker;
1854
- }());
1855
- exports.Marker = Marker;
1856
- /*
1857
- export class DefaultVisitor implements IVisitor {
1858
-
1859
- public visitNode(node:Node):boolean {
1860
- switch (node.type) {
1861
- case NodeType.Stylesheet:
1862
- return this.visitStylesheet(<Stylesheet> node);
1863
- case NodeType.FontFace:
1864
- return this.visitFontFace(<FontFace> node);
1865
- case NodeType.Ruleset:
1866
- return this.visitRuleSet(<RuleSet> node);
1867
- case NodeType.Selector:
1868
- return this.visitSelector(<Selector> node);
1869
- case NodeType.SimpleSelector:
1870
- return this.visitSimpleSelector(<SimpleSelector> node);
1871
- case NodeType.Declaration:
1872
- return this.visitDeclaration(<Declaration> node);
1873
- case NodeType.Function:
1874
- return this.visitFunction(<Function> node);
1875
- case NodeType.FunctionDeclaration:
1876
- return this.visitFunctionDeclaration(<FunctionDeclaration> node);
1877
- case NodeType.FunctionParameter:
1878
- return this.visitFunctionParameter(<FunctionParameter> node);
1879
- case NodeType.FunctionArgument:
1880
- return this.visitFunctionArgument(<FunctionArgument> node);
1881
- case NodeType.Term:
1882
- return this.visitTerm(<Term> node);
1883
- case NodeType.Declaration:
1884
- return this.visitExpression(<Expression> node);
1885
- case NodeType.NumericValue:
1886
- return this.visitNumericValue(<NumericValue> node);
1887
- case NodeType.Page:
1888
- return this.visitPage(<Page> node);
1889
- case NodeType.PageBoxMarginBox:
1890
- return this.visitPageBoxMarginBox(<PageBoxMarginBox> node);
1891
- case NodeType.Property:
1892
- return this.visitProperty(<Property> node);
1893
- case NodeType.NumericValue:
1894
- return this.visitNodelist(<Nodelist> node);
1895
- case NodeType.Import:
1896
- return this.visitImport(<Import> node);
1897
- case NodeType.Namespace:
1898
- return this.visitNamespace(<Namespace> node);
1899
- case NodeType.Keyframe:
1900
- return this.visitKeyframe(<Keyframe> node);
1901
- case NodeType.KeyframeSelector:
1902
- return this.visitKeyframeSelector(<KeyframeSelector> node);
1903
- case NodeType.MixinDeclaration:
1904
- return this.visitMixinDeclaration(<MixinDeclaration> node);
1905
- case NodeType.MixinReference:
1906
- return this.visitMixinReference(<MixinReference> node);
1907
- case NodeType.Variable:
1908
- return this.visitVariable(<Variable> node);
1909
- case NodeType.VariableDeclaration:
1910
- return this.visitVariableDeclaration(<VariableDeclaration> node);
1911
- }
1912
- return this.visitUnknownNode(node);
1913
- }
1914
-
1915
- public visitFontFace(node:FontFace):boolean {
1916
- return true;
1917
- }
1918
-
1919
- public visitKeyframe(node:Keyframe):boolean {
1920
- return true;
1921
- }
1922
-
1923
- public visitKeyframeSelector(node:KeyframeSelector):boolean {
1924
- return true;
1925
- }
1926
-
1927
- public visitStylesheet(node:Stylesheet):boolean {
1928
- return true;
1929
- }
1930
-
1931
- public visitProperty(Node:Property):boolean {
1932
- return true;
1933
- }
1934
-
1935
- public visitRuleSet(node:RuleSet):boolean {
1936
- return true;
1937
- }
1938
-
1939
- public visitSelector(node:Selector):boolean {
1940
- return true;
1941
- }
1942
-
1943
- public visitSimpleSelector(node:SimpleSelector):boolean {
1944
- return true;
1945
- }
1946
-
1947
- public visitDeclaration(node:Declaration):boolean {
1948
- return true;
1949
- }
1950
-
1951
- public visitFunction(node:Function):boolean {
1952
- return true;
1953
- }
1954
-
1955
- public visitFunctionDeclaration(node:FunctionDeclaration):boolean {
1956
- return true;
1957
- }
1958
-
1959
- public visitInvocation(node:Invocation):boolean {
1960
- return true;
1961
- }
1962
-
1963
- public visitTerm(node:Term):boolean {
1964
- return true;
1965
- }
1966
-
1967
- public visitImport(node:Import):boolean {
1968
- return true;
1969
- }
1970
-
1971
- public visitNamespace(node:Namespace):boolean {
1972
- return true;
1973
- }
1974
-
1975
- public visitExpression(node:Expression):boolean {
1976
- return true;
1977
- }
1978
-
1979
- public visitNumericValue(node:NumericValue):boolean {
1980
- return true;
1981
- }
1982
-
1983
- public visitPage(node:Page):boolean {
1984
- return true;
1985
- }
1986
-
1987
- public visitPageBoxMarginBox(node:PageBoxMarginBox):boolean {
1988
- return true;
1989
- }
1990
-
1991
- public visitNodelist(node:Nodelist):boolean {
1992
- return true;
1993
- }
1994
-
1995
- public visitVariableDeclaration(node:VariableDeclaration):boolean {
1996
- return true;
1997
- }
1998
-
1999
- public visitVariable(node:Variable):boolean {
2000
- return true;
2001
- }
2002
-
2003
- public visitMixinDeclaration(node:MixinDeclaration):boolean {
2004
- return true;
2005
- }
2006
-
2007
- public visitMixinReference(node:MixinReference):boolean {
2008
- return true;
2009
- }
2010
-
2011
- public visitUnknownNode(node:Node):boolean {
2012
- return true;
2013
- }
2014
- }
2015
- */
2016
- var ParseErrorCollector = /** @class */ (function () {
2017
- function ParseErrorCollector() {
2018
- this.entries = [];
2019
- }
2020
- ParseErrorCollector.entries = function (node) {
2021
- var visitor = new ParseErrorCollector();
2022
- node.acceptVisitor(visitor);
2023
- return visitor.entries;
2024
- };
2025
- ParseErrorCollector.prototype.visitNode = function (node) {
2026
- if (node.isErroneous()) {
2027
- node.collectIssues(this.entries);
2028
- }
2029
- return true;
2030
- };
2031
- return ParseErrorCollector;
2032
- }());
2033
- exports.ParseErrorCollector = ParseErrorCollector;
2034
- });
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "../utils/strings"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ /*---------------------------------------------------------------------------------------------
11
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12
+ * Licensed under the MIT License. See License.txt in the project root for license information.
13
+ *--------------------------------------------------------------------------------------------*/
14
+ 'use strict';
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ 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.RatioValue = exports.HexColorValue = exports.Operator = exports.AttributeSelector = exports.Term = exports.BinaryExpression = exports.Expression = exports.PageBoxMarginBox = exports.Page = exports.SupportsCondition = exports.MediaFeature = exports.MediaCondition = 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.UnicodeRange = exports.Nodelist = exports.Node = exports.getParentDeclaration = exports.getNodePath = exports.getNodeAtOffset = exports.ReferenceType = exports.NodeType = void 0;
17
+ const strings_1 = require("../utils/strings");
18
+ /// <summary>
19
+ /// Nodes for the css 2.1 specification. See for reference:
20
+ /// http://www.w3.org/TR/CSS21/grammar.html#grammar
21
+ /// </summary>
22
+ var NodeType;
23
+ (function (NodeType) {
24
+ NodeType[NodeType["Undefined"] = 0] = "Undefined";
25
+ NodeType[NodeType["Identifier"] = 1] = "Identifier";
26
+ NodeType[NodeType["Stylesheet"] = 2] = "Stylesheet";
27
+ NodeType[NodeType["Ruleset"] = 3] = "Ruleset";
28
+ NodeType[NodeType["Selector"] = 4] = "Selector";
29
+ NodeType[NodeType["SimpleSelector"] = 5] = "SimpleSelector";
30
+ NodeType[NodeType["SelectorInterpolation"] = 6] = "SelectorInterpolation";
31
+ NodeType[NodeType["SelectorCombinator"] = 7] = "SelectorCombinator";
32
+ NodeType[NodeType["SelectorCombinatorParent"] = 8] = "SelectorCombinatorParent";
33
+ NodeType[NodeType["SelectorCombinatorSibling"] = 9] = "SelectorCombinatorSibling";
34
+ NodeType[NodeType["SelectorCombinatorAllSiblings"] = 10] = "SelectorCombinatorAllSiblings";
35
+ NodeType[NodeType["SelectorCombinatorShadowPiercingDescendant"] = 11] = "SelectorCombinatorShadowPiercingDescendant";
36
+ NodeType[NodeType["Page"] = 12] = "Page";
37
+ NodeType[NodeType["PageBoxMarginBox"] = 13] = "PageBoxMarginBox";
38
+ NodeType[NodeType["ClassSelector"] = 14] = "ClassSelector";
39
+ NodeType[NodeType["IdentifierSelector"] = 15] = "IdentifierSelector";
40
+ NodeType[NodeType["ElementNameSelector"] = 16] = "ElementNameSelector";
41
+ NodeType[NodeType["PseudoSelector"] = 17] = "PseudoSelector";
42
+ NodeType[NodeType["AttributeSelector"] = 18] = "AttributeSelector";
43
+ NodeType[NodeType["Declaration"] = 19] = "Declaration";
44
+ NodeType[NodeType["Declarations"] = 20] = "Declarations";
45
+ NodeType[NodeType["Property"] = 21] = "Property";
46
+ NodeType[NodeType["Expression"] = 22] = "Expression";
47
+ NodeType[NodeType["BinaryExpression"] = 23] = "BinaryExpression";
48
+ NodeType[NodeType["Term"] = 24] = "Term";
49
+ NodeType[NodeType["Operator"] = 25] = "Operator";
50
+ NodeType[NodeType["Value"] = 26] = "Value";
51
+ NodeType[NodeType["StringLiteral"] = 27] = "StringLiteral";
52
+ NodeType[NodeType["URILiteral"] = 28] = "URILiteral";
53
+ NodeType[NodeType["EscapedValue"] = 29] = "EscapedValue";
54
+ NodeType[NodeType["Function"] = 30] = "Function";
55
+ NodeType[NodeType["NumericValue"] = 31] = "NumericValue";
56
+ NodeType[NodeType["HexColorValue"] = 32] = "HexColorValue";
57
+ NodeType[NodeType["RatioValue"] = 33] = "RatioValue";
58
+ NodeType[NodeType["MixinDeclaration"] = 34] = "MixinDeclaration";
59
+ NodeType[NodeType["MixinReference"] = 35] = "MixinReference";
60
+ NodeType[NodeType["VariableName"] = 36] = "VariableName";
61
+ NodeType[NodeType["VariableDeclaration"] = 37] = "VariableDeclaration";
62
+ NodeType[NodeType["Prio"] = 38] = "Prio";
63
+ NodeType[NodeType["Interpolation"] = 39] = "Interpolation";
64
+ NodeType[NodeType["NestedProperties"] = 40] = "NestedProperties";
65
+ NodeType[NodeType["ExtendsReference"] = 41] = "ExtendsReference";
66
+ NodeType[NodeType["SelectorPlaceholder"] = 42] = "SelectorPlaceholder";
67
+ NodeType[NodeType["Debug"] = 43] = "Debug";
68
+ NodeType[NodeType["If"] = 44] = "If";
69
+ NodeType[NodeType["Else"] = 45] = "Else";
70
+ NodeType[NodeType["For"] = 46] = "For";
71
+ NodeType[NodeType["Each"] = 47] = "Each";
72
+ NodeType[NodeType["While"] = 48] = "While";
73
+ NodeType[NodeType["MixinContentReference"] = 49] = "MixinContentReference";
74
+ NodeType[NodeType["MixinContentDeclaration"] = 50] = "MixinContentDeclaration";
75
+ NodeType[NodeType["Media"] = 51] = "Media";
76
+ NodeType[NodeType["Keyframe"] = 52] = "Keyframe";
77
+ NodeType[NodeType["FontFace"] = 53] = "FontFace";
78
+ NodeType[NodeType["Import"] = 54] = "Import";
79
+ NodeType[NodeType["Namespace"] = 55] = "Namespace";
80
+ NodeType[NodeType["Invocation"] = 56] = "Invocation";
81
+ NodeType[NodeType["FunctionDeclaration"] = 57] = "FunctionDeclaration";
82
+ NodeType[NodeType["ReturnStatement"] = 58] = "ReturnStatement";
83
+ NodeType[NodeType["MediaQuery"] = 59] = "MediaQuery";
84
+ NodeType[NodeType["MediaCondition"] = 60] = "MediaCondition";
85
+ NodeType[NodeType["MediaFeature"] = 61] = "MediaFeature";
86
+ NodeType[NodeType["FunctionParameter"] = 62] = "FunctionParameter";
87
+ NodeType[NodeType["FunctionArgument"] = 63] = "FunctionArgument";
88
+ NodeType[NodeType["KeyframeSelector"] = 64] = "KeyframeSelector";
89
+ NodeType[NodeType["ViewPort"] = 65] = "ViewPort";
90
+ NodeType[NodeType["Document"] = 66] = "Document";
91
+ NodeType[NodeType["AtApplyRule"] = 67] = "AtApplyRule";
92
+ NodeType[NodeType["CustomPropertyDeclaration"] = 68] = "CustomPropertyDeclaration";
93
+ NodeType[NodeType["CustomPropertySet"] = 69] = "CustomPropertySet";
94
+ NodeType[NodeType["ListEntry"] = 70] = "ListEntry";
95
+ NodeType[NodeType["Supports"] = 71] = "Supports";
96
+ NodeType[NodeType["SupportsCondition"] = 72] = "SupportsCondition";
97
+ NodeType[NodeType["NamespacePrefix"] = 73] = "NamespacePrefix";
98
+ NodeType[NodeType["GridLine"] = 74] = "GridLine";
99
+ NodeType[NodeType["Plugin"] = 75] = "Plugin";
100
+ NodeType[NodeType["UnknownAtRule"] = 76] = "UnknownAtRule";
101
+ NodeType[NodeType["Use"] = 77] = "Use";
102
+ NodeType[NodeType["ModuleConfiguration"] = 78] = "ModuleConfiguration";
103
+ NodeType[NodeType["Forward"] = 79] = "Forward";
104
+ NodeType[NodeType["ForwardVisibility"] = 80] = "ForwardVisibility";
105
+ NodeType[NodeType["Module"] = 81] = "Module";
106
+ NodeType[NodeType["UnicodeRange"] = 82] = "UnicodeRange";
107
+ })(NodeType = exports.NodeType || (exports.NodeType = {}));
108
+ var ReferenceType;
109
+ (function (ReferenceType) {
110
+ ReferenceType[ReferenceType["Mixin"] = 0] = "Mixin";
111
+ ReferenceType[ReferenceType["Rule"] = 1] = "Rule";
112
+ ReferenceType[ReferenceType["Variable"] = 2] = "Variable";
113
+ ReferenceType[ReferenceType["Function"] = 3] = "Function";
114
+ ReferenceType[ReferenceType["Keyframe"] = 4] = "Keyframe";
115
+ ReferenceType[ReferenceType["Unknown"] = 5] = "Unknown";
116
+ ReferenceType[ReferenceType["Module"] = 6] = "Module";
117
+ ReferenceType[ReferenceType["Forward"] = 7] = "Forward";
118
+ ReferenceType[ReferenceType["ForwardVisibility"] = 8] = "ForwardVisibility";
119
+ })(ReferenceType = exports.ReferenceType || (exports.ReferenceType = {}));
120
+ function getNodeAtOffset(node, offset) {
121
+ let candidate = null;
122
+ if (!node || offset < node.offset || offset > node.end) {
123
+ return null;
124
+ }
125
+ // Find the shortest node at the position
126
+ node.accept((node) => {
127
+ if (node.offset === -1 && node.length === -1) {
128
+ return true;
129
+ }
130
+ if (node.offset <= offset && node.end >= offset) {
131
+ if (!candidate) {
132
+ candidate = node;
133
+ }
134
+ else if (node.length <= candidate.length) {
135
+ candidate = node;
136
+ }
137
+ return true;
138
+ }
139
+ return false;
140
+ });
141
+ return candidate;
142
+ }
143
+ exports.getNodeAtOffset = getNodeAtOffset;
144
+ function getNodePath(node, offset) {
145
+ let candidate = getNodeAtOffset(node, offset);
146
+ const path = [];
147
+ while (candidate) {
148
+ path.unshift(candidate);
149
+ candidate = candidate.parent;
150
+ }
151
+ return path;
152
+ }
153
+ exports.getNodePath = getNodePath;
154
+ function getParentDeclaration(node) {
155
+ const decl = node.findParent(NodeType.Declaration);
156
+ const value = decl && decl.getValue();
157
+ if (value && value.encloses(node)) {
158
+ return decl;
159
+ }
160
+ return null;
161
+ }
162
+ exports.getParentDeclaration = getParentDeclaration;
163
+ class Node {
164
+ constructor(offset = -1, len = -1, nodeType) {
165
+ this.parent = null;
166
+ this.offset = offset;
167
+ this.length = len;
168
+ if (nodeType) {
169
+ this.nodeType = nodeType;
170
+ }
171
+ }
172
+ get end() { return this.offset + this.length; }
173
+ set type(type) {
174
+ this.nodeType = type;
175
+ }
176
+ get type() {
177
+ return this.nodeType || NodeType.Undefined;
178
+ }
179
+ getTextProvider() {
180
+ let node = this;
181
+ while (node && !node.textProvider) {
182
+ node = node.parent;
183
+ }
184
+ if (node) {
185
+ return node.textProvider;
186
+ }
187
+ return () => { return 'unknown'; };
188
+ }
189
+ getText() {
190
+ return this.getTextProvider()(this.offset, this.length);
191
+ }
192
+ matches(str) {
193
+ return this.length === str.length && this.getTextProvider()(this.offset, this.length) === str;
194
+ }
195
+ startsWith(str) {
196
+ return this.length >= str.length && this.getTextProvider()(this.offset, str.length) === str;
197
+ }
198
+ endsWith(str) {
199
+ return this.length >= str.length && this.getTextProvider()(this.end - str.length, str.length) === str;
200
+ }
201
+ accept(visitor) {
202
+ if (visitor(this) && this.children) {
203
+ for (const child of this.children) {
204
+ child.accept(visitor);
205
+ }
206
+ }
207
+ }
208
+ acceptVisitor(visitor) {
209
+ this.accept(visitor.visitNode.bind(visitor));
210
+ }
211
+ adoptChild(node, index = -1) {
212
+ if (node.parent && node.parent.children) {
213
+ const idx = node.parent.children.indexOf(node);
214
+ if (idx >= 0) {
215
+ node.parent.children.splice(idx, 1);
216
+ }
217
+ }
218
+ node.parent = this;
219
+ let children = this.children;
220
+ if (!children) {
221
+ children = this.children = [];
222
+ }
223
+ if (index !== -1) {
224
+ children.splice(index, 0, node);
225
+ }
226
+ else {
227
+ children.push(node);
228
+ }
229
+ return node;
230
+ }
231
+ attachTo(parent, index = -1) {
232
+ if (parent) {
233
+ parent.adoptChild(this, index);
234
+ }
235
+ return this;
236
+ }
237
+ collectIssues(results) {
238
+ if (this.issues) {
239
+ results.push.apply(results, this.issues);
240
+ }
241
+ }
242
+ addIssue(issue) {
243
+ if (!this.issues) {
244
+ this.issues = [];
245
+ }
246
+ this.issues.push(issue);
247
+ }
248
+ hasIssue(rule) {
249
+ return Array.isArray(this.issues) && this.issues.some(i => i.getRule() === rule);
250
+ }
251
+ isErroneous(recursive = false) {
252
+ if (this.issues && this.issues.length > 0) {
253
+ return true;
254
+ }
255
+ return recursive && Array.isArray(this.children) && this.children.some(c => c.isErroneous(true));
256
+ }
257
+ setNode(field, node, index = -1) {
258
+ if (node) {
259
+ node.attachTo(this, index);
260
+ this[field] = node;
261
+ return true;
262
+ }
263
+ return false;
264
+ }
265
+ addChild(node) {
266
+ if (node) {
267
+ if (!this.children) {
268
+ this.children = [];
269
+ }
270
+ node.attachTo(this);
271
+ this.updateOffsetAndLength(node);
272
+ return true;
273
+ }
274
+ return false;
275
+ }
276
+ updateOffsetAndLength(node) {
277
+ if (node.offset < this.offset || this.offset === -1) {
278
+ this.offset = node.offset;
279
+ }
280
+ const nodeEnd = node.end;
281
+ if ((nodeEnd > this.end) || this.length === -1) {
282
+ this.length = nodeEnd - this.offset;
283
+ }
284
+ }
285
+ hasChildren() {
286
+ return !!this.children && this.children.length > 0;
287
+ }
288
+ getChildren() {
289
+ return this.children ? this.children.slice(0) : [];
290
+ }
291
+ getChild(index) {
292
+ if (this.children && index < this.children.length) {
293
+ return this.children[index];
294
+ }
295
+ return null;
296
+ }
297
+ addChildren(nodes) {
298
+ for (const node of nodes) {
299
+ this.addChild(node);
300
+ }
301
+ }
302
+ findFirstChildBeforeOffset(offset) {
303
+ if (this.children) {
304
+ let current = null;
305
+ for (let i = this.children.length - 1; i >= 0; i--) {
306
+ // iterate until we find a child that has a start offset smaller than the input offset
307
+ current = this.children[i];
308
+ if (current.offset <= offset) {
309
+ return current;
310
+ }
311
+ }
312
+ }
313
+ return null;
314
+ }
315
+ findChildAtOffset(offset, goDeep) {
316
+ const current = this.findFirstChildBeforeOffset(offset);
317
+ if (current && current.end >= offset) {
318
+ if (goDeep) {
319
+ return current.findChildAtOffset(offset, true) || current;
320
+ }
321
+ return current;
322
+ }
323
+ return null;
324
+ }
325
+ encloses(candidate) {
326
+ return this.offset <= candidate.offset && this.offset + this.length >= candidate.offset + candidate.length;
327
+ }
328
+ getParent() {
329
+ let result = this.parent;
330
+ while (result instanceof Nodelist) {
331
+ result = result.parent;
332
+ }
333
+ return result;
334
+ }
335
+ findParent(type) {
336
+ let result = this;
337
+ while (result && result.type !== type) {
338
+ result = result.parent;
339
+ }
340
+ return result;
341
+ }
342
+ findAParent(...types) {
343
+ let result = this;
344
+ while (result && !types.some(t => result.type === t)) {
345
+ result = result.parent;
346
+ }
347
+ return result;
348
+ }
349
+ setData(key, value) {
350
+ if (!this.options) {
351
+ this.options = {};
352
+ }
353
+ this.options[key] = value;
354
+ }
355
+ getData(key) {
356
+ if (!this.options || !this.options.hasOwnProperty(key)) {
357
+ return null;
358
+ }
359
+ return this.options[key];
360
+ }
361
+ }
362
+ exports.Node = Node;
363
+ class Nodelist extends Node {
364
+ constructor(parent, index = -1) {
365
+ super(-1, -1);
366
+ this.attachTo(parent, index);
367
+ this.offset = -1;
368
+ this.length = -1;
369
+ }
370
+ }
371
+ exports.Nodelist = Nodelist;
372
+ class UnicodeRange extends Node {
373
+ constructor(offset, length) {
374
+ super(offset, length);
375
+ }
376
+ get type() {
377
+ return NodeType.UnicodeRange;
378
+ }
379
+ setRangeStart(rangeStart) {
380
+ return this.setNode('rangeStart', rangeStart);
381
+ }
382
+ getRangeStart() {
383
+ return this.rangeStart;
384
+ }
385
+ setRangeEnd(rangeEnd) {
386
+ return this.setNode('rangeEnd', rangeEnd);
387
+ }
388
+ getRangeEnd() {
389
+ return this.rangeEnd;
390
+ }
391
+ }
392
+ exports.UnicodeRange = UnicodeRange;
393
+ class Identifier extends Node {
394
+ constructor(offset, length) {
395
+ super(offset, length);
396
+ this.isCustomProperty = false;
397
+ }
398
+ get type() {
399
+ return NodeType.Identifier;
400
+ }
401
+ containsInterpolation() {
402
+ return this.hasChildren();
403
+ }
404
+ }
405
+ exports.Identifier = Identifier;
406
+ class Stylesheet extends Node {
407
+ constructor(offset, length) {
408
+ super(offset, length);
409
+ }
410
+ get type() {
411
+ return NodeType.Stylesheet;
412
+ }
413
+ }
414
+ exports.Stylesheet = Stylesheet;
415
+ class Declarations extends Node {
416
+ constructor(offset, length) {
417
+ super(offset, length);
418
+ }
419
+ get type() {
420
+ return NodeType.Declarations;
421
+ }
422
+ }
423
+ exports.Declarations = Declarations;
424
+ class BodyDeclaration extends Node {
425
+ constructor(offset, length) {
426
+ super(offset, length);
427
+ }
428
+ getDeclarations() {
429
+ return this.declarations;
430
+ }
431
+ setDeclarations(decls) {
432
+ return this.setNode('declarations', decls);
433
+ }
434
+ }
435
+ exports.BodyDeclaration = BodyDeclaration;
436
+ class RuleSet extends BodyDeclaration {
437
+ constructor(offset, length) {
438
+ super(offset, length);
439
+ }
440
+ get type() {
441
+ return NodeType.Ruleset;
442
+ }
443
+ getSelectors() {
444
+ if (!this.selectors) {
445
+ this.selectors = new Nodelist(this);
446
+ }
447
+ return this.selectors;
448
+ }
449
+ isNested() {
450
+ return !!this.parent && this.parent.findParent(NodeType.Declarations) !== null;
451
+ }
452
+ }
453
+ exports.RuleSet = RuleSet;
454
+ class Selector extends Node {
455
+ constructor(offset, length) {
456
+ super(offset, length);
457
+ }
458
+ get type() {
459
+ return NodeType.Selector;
460
+ }
461
+ }
462
+ exports.Selector = Selector;
463
+ class SimpleSelector extends Node {
464
+ constructor(offset, length) {
465
+ super(offset, length);
466
+ }
467
+ get type() {
468
+ return NodeType.SimpleSelector;
469
+ }
470
+ }
471
+ exports.SimpleSelector = SimpleSelector;
472
+ class AtApplyRule extends Node {
473
+ constructor(offset, length) {
474
+ super(offset, length);
475
+ }
476
+ get type() {
477
+ return NodeType.AtApplyRule;
478
+ }
479
+ setIdentifier(node) {
480
+ return this.setNode('identifier', node, 0);
481
+ }
482
+ getIdentifier() {
483
+ return this.identifier;
484
+ }
485
+ getName() {
486
+ return this.identifier ? this.identifier.getText() : '';
487
+ }
488
+ }
489
+ exports.AtApplyRule = AtApplyRule;
490
+ class AbstractDeclaration extends Node {
491
+ constructor(offset, length) {
492
+ super(offset, length);
493
+ }
494
+ }
495
+ exports.AbstractDeclaration = AbstractDeclaration;
496
+ class CustomPropertySet extends BodyDeclaration {
497
+ constructor(offset, length) {
498
+ super(offset, length);
499
+ }
500
+ get type() {
501
+ return NodeType.CustomPropertySet;
502
+ }
503
+ }
504
+ exports.CustomPropertySet = CustomPropertySet;
505
+ class Declaration extends AbstractDeclaration {
506
+ constructor(offset, length) {
507
+ super(offset, length);
508
+ this.property = null;
509
+ }
510
+ get type() {
511
+ return NodeType.Declaration;
512
+ }
513
+ setProperty(node) {
514
+ return this.setNode('property', node);
515
+ }
516
+ getProperty() {
517
+ return this.property;
518
+ }
519
+ getFullPropertyName() {
520
+ const propertyName = this.property ? this.property.getName() : 'unknown';
521
+ if (this.parent instanceof Declarations && this.parent.getParent() instanceof NestedProperties) {
522
+ const parentDecl = this.parent.getParent().getParent();
523
+ if (parentDecl instanceof Declaration) {
524
+ return parentDecl.getFullPropertyName() + propertyName;
525
+ }
526
+ }
527
+ return propertyName;
528
+ }
529
+ getNonPrefixedPropertyName() {
530
+ const propertyName = this.getFullPropertyName();
531
+ if (propertyName && propertyName.charAt(0) === '-') {
532
+ const vendorPrefixEnd = propertyName.indexOf('-', 1);
533
+ if (vendorPrefixEnd !== -1) {
534
+ return propertyName.substring(vendorPrefixEnd + 1);
535
+ }
536
+ }
537
+ return propertyName;
538
+ }
539
+ setValue(value) {
540
+ return this.setNode('value', value);
541
+ }
542
+ getValue() {
543
+ return this.value;
544
+ }
545
+ setNestedProperties(value) {
546
+ return this.setNode('nestedProperties', value);
547
+ }
548
+ getNestedProperties() {
549
+ return this.nestedProperties;
550
+ }
551
+ }
552
+ exports.Declaration = Declaration;
553
+ class CustomPropertyDeclaration extends Declaration {
554
+ constructor(offset, length) {
555
+ super(offset, length);
556
+ }
557
+ get type() {
558
+ return NodeType.CustomPropertyDeclaration;
559
+ }
560
+ setPropertySet(value) {
561
+ return this.setNode('propertySet', value);
562
+ }
563
+ getPropertySet() {
564
+ return this.propertySet;
565
+ }
566
+ }
567
+ exports.CustomPropertyDeclaration = CustomPropertyDeclaration;
568
+ class Property extends Node {
569
+ constructor(offset, length) {
570
+ super(offset, length);
571
+ }
572
+ get type() {
573
+ return NodeType.Property;
574
+ }
575
+ setIdentifier(value) {
576
+ return this.setNode('identifier', value);
577
+ }
578
+ getIdentifier() {
579
+ return this.identifier;
580
+ }
581
+ getName() {
582
+ return (0, strings_1.trim)(this.getText(), /[_\+]+$/); /* +_: less merge */
583
+ }
584
+ isCustomProperty() {
585
+ return !!this.identifier && this.identifier.isCustomProperty;
586
+ }
587
+ }
588
+ exports.Property = Property;
589
+ class Invocation extends Node {
590
+ constructor(offset, length) {
591
+ super(offset, length);
592
+ }
593
+ get type() {
594
+ return NodeType.Invocation;
595
+ }
596
+ getArguments() {
597
+ if (!this.arguments) {
598
+ this.arguments = new Nodelist(this);
599
+ }
600
+ return this.arguments;
601
+ }
602
+ }
603
+ exports.Invocation = Invocation;
604
+ class Function extends Invocation {
605
+ constructor(offset, length) {
606
+ super(offset, length);
607
+ }
608
+ get type() {
609
+ return NodeType.Function;
610
+ }
611
+ setIdentifier(node) {
612
+ return this.setNode('identifier', node, 0);
613
+ }
614
+ getIdentifier() {
615
+ return this.identifier;
616
+ }
617
+ getName() {
618
+ return this.identifier ? this.identifier.getText() : '';
619
+ }
620
+ }
621
+ exports.Function = Function;
622
+ class FunctionParameter extends Node {
623
+ constructor(offset, length) {
624
+ super(offset, length);
625
+ }
626
+ get type() {
627
+ return NodeType.FunctionParameter;
628
+ }
629
+ setIdentifier(node) {
630
+ return this.setNode('identifier', node, 0);
631
+ }
632
+ getIdentifier() {
633
+ return this.identifier;
634
+ }
635
+ getName() {
636
+ return this.identifier ? this.identifier.getText() : '';
637
+ }
638
+ setDefaultValue(node) {
639
+ return this.setNode('defaultValue', node, 0);
640
+ }
641
+ getDefaultValue() {
642
+ return this.defaultValue;
643
+ }
644
+ }
645
+ exports.FunctionParameter = FunctionParameter;
646
+ class FunctionArgument extends Node {
647
+ constructor(offset, length) {
648
+ super(offset, length);
649
+ }
650
+ get type() {
651
+ return NodeType.FunctionArgument;
652
+ }
653
+ setIdentifier(node) {
654
+ return this.setNode('identifier', node, 0);
655
+ }
656
+ getIdentifier() {
657
+ return this.identifier;
658
+ }
659
+ getName() {
660
+ return this.identifier ? this.identifier.getText() : '';
661
+ }
662
+ setValue(node) {
663
+ return this.setNode('value', node, 0);
664
+ }
665
+ getValue() {
666
+ return this.value;
667
+ }
668
+ }
669
+ exports.FunctionArgument = FunctionArgument;
670
+ class IfStatement extends BodyDeclaration {
671
+ constructor(offset, length) {
672
+ super(offset, length);
673
+ }
674
+ get type() {
675
+ return NodeType.If;
676
+ }
677
+ setExpression(node) {
678
+ return this.setNode('expression', node, 0);
679
+ }
680
+ setElseClause(elseClause) {
681
+ return this.setNode('elseClause', elseClause);
682
+ }
683
+ }
684
+ exports.IfStatement = IfStatement;
685
+ class ForStatement extends BodyDeclaration {
686
+ constructor(offset, length) {
687
+ super(offset, length);
688
+ }
689
+ get type() {
690
+ return NodeType.For;
691
+ }
692
+ setVariable(node) {
693
+ return this.setNode('variable', node, 0);
694
+ }
695
+ }
696
+ exports.ForStatement = ForStatement;
697
+ class EachStatement extends BodyDeclaration {
698
+ constructor(offset, length) {
699
+ super(offset, length);
700
+ }
701
+ get type() {
702
+ return NodeType.Each;
703
+ }
704
+ getVariables() {
705
+ if (!this.variables) {
706
+ this.variables = new Nodelist(this);
707
+ }
708
+ return this.variables;
709
+ }
710
+ }
711
+ exports.EachStatement = EachStatement;
712
+ class WhileStatement extends BodyDeclaration {
713
+ constructor(offset, length) {
714
+ super(offset, length);
715
+ }
716
+ get type() {
717
+ return NodeType.While;
718
+ }
719
+ }
720
+ exports.WhileStatement = WhileStatement;
721
+ class ElseStatement extends BodyDeclaration {
722
+ constructor(offset, length) {
723
+ super(offset, length);
724
+ }
725
+ get type() {
726
+ return NodeType.Else;
727
+ }
728
+ }
729
+ exports.ElseStatement = ElseStatement;
730
+ class FunctionDeclaration extends BodyDeclaration {
731
+ constructor(offset, length) {
732
+ super(offset, length);
733
+ }
734
+ get type() {
735
+ return NodeType.FunctionDeclaration;
736
+ }
737
+ setIdentifier(node) {
738
+ return this.setNode('identifier', node, 0);
739
+ }
740
+ getIdentifier() {
741
+ return this.identifier;
742
+ }
743
+ getName() {
744
+ return this.identifier ? this.identifier.getText() : '';
745
+ }
746
+ getParameters() {
747
+ if (!this.parameters) {
748
+ this.parameters = new Nodelist(this);
749
+ }
750
+ return this.parameters;
751
+ }
752
+ }
753
+ exports.FunctionDeclaration = FunctionDeclaration;
754
+ class ViewPort extends BodyDeclaration {
755
+ constructor(offset, length) {
756
+ super(offset, length);
757
+ }
758
+ get type() {
759
+ return NodeType.ViewPort;
760
+ }
761
+ }
762
+ exports.ViewPort = ViewPort;
763
+ class FontFace extends BodyDeclaration {
764
+ constructor(offset, length) {
765
+ super(offset, length);
766
+ }
767
+ get type() {
768
+ return NodeType.FontFace;
769
+ }
770
+ }
771
+ exports.FontFace = FontFace;
772
+ class NestedProperties extends BodyDeclaration {
773
+ constructor(offset, length) {
774
+ super(offset, length);
775
+ }
776
+ get type() {
777
+ return NodeType.NestedProperties;
778
+ }
779
+ }
780
+ exports.NestedProperties = NestedProperties;
781
+ class Keyframe extends BodyDeclaration {
782
+ constructor(offset, length) {
783
+ super(offset, length);
784
+ }
785
+ get type() {
786
+ return NodeType.Keyframe;
787
+ }
788
+ setKeyword(keyword) {
789
+ return this.setNode('keyword', keyword, 0);
790
+ }
791
+ getKeyword() {
792
+ return this.keyword;
793
+ }
794
+ setIdentifier(node) {
795
+ return this.setNode('identifier', node, 0);
796
+ }
797
+ getIdentifier() {
798
+ return this.identifier;
799
+ }
800
+ getName() {
801
+ return this.identifier ? this.identifier.getText() : '';
802
+ }
803
+ }
804
+ exports.Keyframe = Keyframe;
805
+ class KeyframeSelector extends BodyDeclaration {
806
+ constructor(offset, length) {
807
+ super(offset, length);
808
+ }
809
+ get type() {
810
+ return NodeType.KeyframeSelector;
811
+ }
812
+ }
813
+ exports.KeyframeSelector = KeyframeSelector;
814
+ class Import extends Node {
815
+ constructor(offset, length) {
816
+ super(offset, length);
817
+ }
818
+ get type() {
819
+ return NodeType.Import;
820
+ }
821
+ setMedialist(node) {
822
+ if (node) {
823
+ node.attachTo(this);
824
+ return true;
825
+ }
826
+ return false;
827
+ }
828
+ }
829
+ exports.Import = Import;
830
+ class Use extends Node {
831
+ get type() {
832
+ return NodeType.Use;
833
+ }
834
+ getParameters() {
835
+ if (!this.parameters) {
836
+ this.parameters = new Nodelist(this);
837
+ }
838
+ return this.parameters;
839
+ }
840
+ setIdentifier(node) {
841
+ return this.setNode('identifier', node, 0);
842
+ }
843
+ getIdentifier() {
844
+ return this.identifier;
845
+ }
846
+ }
847
+ exports.Use = Use;
848
+ class ModuleConfiguration extends Node {
849
+ get type() {
850
+ return NodeType.ModuleConfiguration;
851
+ }
852
+ setIdentifier(node) {
853
+ return this.setNode('identifier', node, 0);
854
+ }
855
+ getIdentifier() {
856
+ return this.identifier;
857
+ }
858
+ getName() {
859
+ return this.identifier ? this.identifier.getText() : '';
860
+ }
861
+ setValue(node) {
862
+ return this.setNode('value', node, 0);
863
+ }
864
+ getValue() {
865
+ return this.value;
866
+ }
867
+ }
868
+ exports.ModuleConfiguration = ModuleConfiguration;
869
+ class Forward extends Node {
870
+ get type() {
871
+ return NodeType.Forward;
872
+ }
873
+ setIdentifier(node) {
874
+ return this.setNode('identifier', node, 0);
875
+ }
876
+ getIdentifier() {
877
+ return this.identifier;
878
+ }
879
+ getMembers() {
880
+ if (!this.members) {
881
+ this.members = new Nodelist(this);
882
+ }
883
+ return this.members;
884
+ }
885
+ getParameters() {
886
+ if (!this.parameters) {
887
+ this.parameters = new Nodelist(this);
888
+ }
889
+ return this.parameters;
890
+ }
891
+ }
892
+ exports.Forward = Forward;
893
+ class ForwardVisibility extends Node {
894
+ get type() {
895
+ return NodeType.ForwardVisibility;
896
+ }
897
+ setIdentifier(node) {
898
+ return this.setNode('identifier', node, 0);
899
+ }
900
+ getIdentifier() {
901
+ return this.identifier;
902
+ }
903
+ }
904
+ exports.ForwardVisibility = ForwardVisibility;
905
+ class Namespace extends Node {
906
+ constructor(offset, length) {
907
+ super(offset, length);
908
+ }
909
+ get type() {
910
+ return NodeType.Namespace;
911
+ }
912
+ }
913
+ exports.Namespace = Namespace;
914
+ class Media extends BodyDeclaration {
915
+ constructor(offset, length) {
916
+ super(offset, length);
917
+ }
918
+ get type() {
919
+ return NodeType.Media;
920
+ }
921
+ }
922
+ exports.Media = Media;
923
+ class Supports extends BodyDeclaration {
924
+ constructor(offset, length) {
925
+ super(offset, length);
926
+ }
927
+ get type() {
928
+ return NodeType.Supports;
929
+ }
930
+ }
931
+ exports.Supports = Supports;
932
+ class Document extends BodyDeclaration {
933
+ constructor(offset, length) {
934
+ super(offset, length);
935
+ }
936
+ get type() {
937
+ return NodeType.Document;
938
+ }
939
+ }
940
+ exports.Document = Document;
941
+ class Medialist extends Node {
942
+ constructor(offset, length) {
943
+ super(offset, length);
944
+ }
945
+ getMediums() {
946
+ if (!this.mediums) {
947
+ this.mediums = new Nodelist(this);
948
+ }
949
+ return this.mediums;
950
+ }
951
+ }
952
+ exports.Medialist = Medialist;
953
+ class MediaQuery extends Node {
954
+ constructor(offset, length) {
955
+ super(offset, length);
956
+ }
957
+ get type() {
958
+ return NodeType.MediaQuery;
959
+ }
960
+ }
961
+ exports.MediaQuery = MediaQuery;
962
+ class MediaCondition extends Node {
963
+ constructor(offset, length) {
964
+ super(offset, length);
965
+ }
966
+ get type() {
967
+ return NodeType.MediaCondition;
968
+ }
969
+ }
970
+ exports.MediaCondition = MediaCondition;
971
+ class MediaFeature extends Node {
972
+ constructor(offset, length) {
973
+ super(offset, length);
974
+ }
975
+ get type() {
976
+ return NodeType.MediaFeature;
977
+ }
978
+ }
979
+ exports.MediaFeature = MediaFeature;
980
+ class SupportsCondition extends Node {
981
+ constructor(offset, length) {
982
+ super(offset, length);
983
+ }
984
+ get type() {
985
+ return NodeType.SupportsCondition;
986
+ }
987
+ }
988
+ exports.SupportsCondition = SupportsCondition;
989
+ class Page extends BodyDeclaration {
990
+ constructor(offset, length) {
991
+ super(offset, length);
992
+ }
993
+ get type() {
994
+ return NodeType.Page;
995
+ }
996
+ }
997
+ exports.Page = Page;
998
+ class PageBoxMarginBox extends BodyDeclaration {
999
+ constructor(offset, length) {
1000
+ super(offset, length);
1001
+ }
1002
+ get type() {
1003
+ return NodeType.PageBoxMarginBox;
1004
+ }
1005
+ }
1006
+ exports.PageBoxMarginBox = PageBoxMarginBox;
1007
+ class Expression extends Node {
1008
+ constructor(offset, length) {
1009
+ super(offset, length);
1010
+ }
1011
+ get type() {
1012
+ return NodeType.Expression;
1013
+ }
1014
+ }
1015
+ exports.Expression = Expression;
1016
+ class BinaryExpression extends Node {
1017
+ constructor(offset, length) {
1018
+ super(offset, length);
1019
+ }
1020
+ get type() {
1021
+ return NodeType.BinaryExpression;
1022
+ }
1023
+ setLeft(left) {
1024
+ return this.setNode('left', left);
1025
+ }
1026
+ getLeft() {
1027
+ return this.left;
1028
+ }
1029
+ setRight(right) {
1030
+ return this.setNode('right', right);
1031
+ }
1032
+ getRight() {
1033
+ return this.right;
1034
+ }
1035
+ setOperator(value) {
1036
+ return this.setNode('operator', value);
1037
+ }
1038
+ getOperator() {
1039
+ return this.operator;
1040
+ }
1041
+ }
1042
+ exports.BinaryExpression = BinaryExpression;
1043
+ class Term extends Node {
1044
+ constructor(offset, length) {
1045
+ super(offset, length);
1046
+ }
1047
+ get type() {
1048
+ return NodeType.Term;
1049
+ }
1050
+ setOperator(value) {
1051
+ return this.setNode('operator', value);
1052
+ }
1053
+ getOperator() {
1054
+ return this.operator;
1055
+ }
1056
+ setExpression(value) {
1057
+ return this.setNode('expression', value);
1058
+ }
1059
+ getExpression() {
1060
+ return this.expression;
1061
+ }
1062
+ }
1063
+ exports.Term = Term;
1064
+ class AttributeSelector extends Node {
1065
+ constructor(offset, length) {
1066
+ super(offset, length);
1067
+ }
1068
+ get type() {
1069
+ return NodeType.AttributeSelector;
1070
+ }
1071
+ setNamespacePrefix(value) {
1072
+ return this.setNode('namespacePrefix', value);
1073
+ }
1074
+ getNamespacePrefix() {
1075
+ return this.namespacePrefix;
1076
+ }
1077
+ setIdentifier(value) {
1078
+ return this.setNode('identifier', value);
1079
+ }
1080
+ getIdentifier() {
1081
+ return this.identifier;
1082
+ }
1083
+ setOperator(operator) {
1084
+ return this.setNode('operator', operator);
1085
+ }
1086
+ getOperator() {
1087
+ return this.operator;
1088
+ }
1089
+ setValue(value) {
1090
+ return this.setNode('value', value);
1091
+ }
1092
+ getValue() {
1093
+ return this.value;
1094
+ }
1095
+ }
1096
+ exports.AttributeSelector = AttributeSelector;
1097
+ class Operator extends Node {
1098
+ constructor(offset, length) {
1099
+ super(offset, length);
1100
+ }
1101
+ get type() {
1102
+ return NodeType.Operator;
1103
+ }
1104
+ }
1105
+ exports.Operator = Operator;
1106
+ class HexColorValue extends Node {
1107
+ constructor(offset, length) {
1108
+ super(offset, length);
1109
+ }
1110
+ get type() {
1111
+ return NodeType.HexColorValue;
1112
+ }
1113
+ }
1114
+ exports.HexColorValue = HexColorValue;
1115
+ class RatioValue extends Node {
1116
+ constructor(offset, length) {
1117
+ super(offset, length);
1118
+ }
1119
+ get type() {
1120
+ return NodeType.RatioValue;
1121
+ }
1122
+ }
1123
+ exports.RatioValue = RatioValue;
1124
+ const _dot = '.'.charCodeAt(0), _0 = '0'.charCodeAt(0), _9 = '9'.charCodeAt(0);
1125
+ class NumericValue extends Node {
1126
+ constructor(offset, length) {
1127
+ super(offset, length);
1128
+ }
1129
+ get type() {
1130
+ return NodeType.NumericValue;
1131
+ }
1132
+ getValue() {
1133
+ const raw = this.getText();
1134
+ let unitIdx = 0;
1135
+ let code;
1136
+ for (let i = 0, len = raw.length; i < len; i++) {
1137
+ code = raw.charCodeAt(i);
1138
+ if (!(_0 <= code && code <= _9 || code === _dot)) {
1139
+ break;
1140
+ }
1141
+ unitIdx += 1;
1142
+ }
1143
+ return {
1144
+ value: raw.substring(0, unitIdx),
1145
+ unit: unitIdx < raw.length ? raw.substring(unitIdx) : undefined
1146
+ };
1147
+ }
1148
+ }
1149
+ exports.NumericValue = NumericValue;
1150
+ class VariableDeclaration extends AbstractDeclaration {
1151
+ constructor(offset, length) {
1152
+ super(offset, length);
1153
+ this.variable = null;
1154
+ this.value = null;
1155
+ this.needsSemicolon = true;
1156
+ }
1157
+ get type() {
1158
+ return NodeType.VariableDeclaration;
1159
+ }
1160
+ setVariable(node) {
1161
+ if (node) {
1162
+ node.attachTo(this);
1163
+ this.variable = node;
1164
+ return true;
1165
+ }
1166
+ return false;
1167
+ }
1168
+ getVariable() {
1169
+ return this.variable;
1170
+ }
1171
+ getName() {
1172
+ return this.variable ? this.variable.getName() : '';
1173
+ }
1174
+ setValue(node) {
1175
+ if (node) {
1176
+ node.attachTo(this);
1177
+ this.value = node;
1178
+ return true;
1179
+ }
1180
+ return false;
1181
+ }
1182
+ getValue() {
1183
+ return this.value;
1184
+ }
1185
+ }
1186
+ exports.VariableDeclaration = VariableDeclaration;
1187
+ class Interpolation extends Node {
1188
+ // private _interpolations: void; // workaround for https://github.com/Microsoft/TypeScript/issues/18276
1189
+ constructor(offset, length) {
1190
+ super(offset, length);
1191
+ }
1192
+ get type() {
1193
+ return NodeType.Interpolation;
1194
+ }
1195
+ }
1196
+ exports.Interpolation = Interpolation;
1197
+ class Variable extends Node {
1198
+ constructor(offset, length) {
1199
+ super(offset, length);
1200
+ }
1201
+ get type() {
1202
+ return NodeType.VariableName;
1203
+ }
1204
+ getName() {
1205
+ return this.getText();
1206
+ }
1207
+ }
1208
+ exports.Variable = Variable;
1209
+ class ExtendsReference extends Node {
1210
+ constructor(offset, length) {
1211
+ super(offset, length);
1212
+ }
1213
+ get type() {
1214
+ return NodeType.ExtendsReference;
1215
+ }
1216
+ getSelectors() {
1217
+ if (!this.selectors) {
1218
+ this.selectors = new Nodelist(this);
1219
+ }
1220
+ return this.selectors;
1221
+ }
1222
+ }
1223
+ exports.ExtendsReference = ExtendsReference;
1224
+ class MixinContentReference extends Node {
1225
+ constructor(offset, length) {
1226
+ super(offset, length);
1227
+ }
1228
+ get type() {
1229
+ return NodeType.MixinContentReference;
1230
+ }
1231
+ getArguments() {
1232
+ if (!this.arguments) {
1233
+ this.arguments = new Nodelist(this);
1234
+ }
1235
+ return this.arguments;
1236
+ }
1237
+ }
1238
+ exports.MixinContentReference = MixinContentReference;
1239
+ class MixinContentDeclaration extends BodyDeclaration {
1240
+ constructor(offset, length) {
1241
+ super(offset, length);
1242
+ }
1243
+ get type() {
1244
+ return NodeType.MixinContentReference;
1245
+ }
1246
+ getParameters() {
1247
+ if (!this.parameters) {
1248
+ this.parameters = new Nodelist(this);
1249
+ }
1250
+ return this.parameters;
1251
+ }
1252
+ }
1253
+ exports.MixinContentDeclaration = MixinContentDeclaration;
1254
+ class MixinReference extends Node {
1255
+ constructor(offset, length) {
1256
+ super(offset, length);
1257
+ }
1258
+ get type() {
1259
+ return NodeType.MixinReference;
1260
+ }
1261
+ getNamespaces() {
1262
+ if (!this.namespaces) {
1263
+ this.namespaces = new Nodelist(this);
1264
+ }
1265
+ return this.namespaces;
1266
+ }
1267
+ setIdentifier(node) {
1268
+ return this.setNode('identifier', node, 0);
1269
+ }
1270
+ getIdentifier() {
1271
+ return this.identifier;
1272
+ }
1273
+ getName() {
1274
+ return this.identifier ? this.identifier.getText() : '';
1275
+ }
1276
+ getArguments() {
1277
+ if (!this.arguments) {
1278
+ this.arguments = new Nodelist(this);
1279
+ }
1280
+ return this.arguments;
1281
+ }
1282
+ setContent(node) {
1283
+ return this.setNode('content', node);
1284
+ }
1285
+ getContent() {
1286
+ return this.content;
1287
+ }
1288
+ }
1289
+ exports.MixinReference = MixinReference;
1290
+ class MixinDeclaration extends BodyDeclaration {
1291
+ constructor(offset, length) {
1292
+ super(offset, length);
1293
+ }
1294
+ get type() {
1295
+ return NodeType.MixinDeclaration;
1296
+ }
1297
+ setIdentifier(node) {
1298
+ return this.setNode('identifier', node, 0);
1299
+ }
1300
+ getIdentifier() {
1301
+ return this.identifier;
1302
+ }
1303
+ getName() {
1304
+ return this.identifier ? this.identifier.getText() : '';
1305
+ }
1306
+ getParameters() {
1307
+ if (!this.parameters) {
1308
+ this.parameters = new Nodelist(this);
1309
+ }
1310
+ return this.parameters;
1311
+ }
1312
+ setGuard(node) {
1313
+ if (node) {
1314
+ node.attachTo(this);
1315
+ this.guard = node;
1316
+ }
1317
+ return false;
1318
+ }
1319
+ }
1320
+ exports.MixinDeclaration = MixinDeclaration;
1321
+ class UnknownAtRule extends BodyDeclaration {
1322
+ constructor(offset, length) {
1323
+ super(offset, length);
1324
+ }
1325
+ get type() {
1326
+ return NodeType.UnknownAtRule;
1327
+ }
1328
+ setAtRuleName(atRuleName) {
1329
+ this.atRuleName = atRuleName;
1330
+ }
1331
+ getAtRuleName() {
1332
+ return this.atRuleName;
1333
+ }
1334
+ }
1335
+ exports.UnknownAtRule = UnknownAtRule;
1336
+ class ListEntry extends Node {
1337
+ get type() {
1338
+ return NodeType.ListEntry;
1339
+ }
1340
+ setKey(node) {
1341
+ return this.setNode('key', node, 0);
1342
+ }
1343
+ setValue(node) {
1344
+ return this.setNode('value', node, 1);
1345
+ }
1346
+ }
1347
+ exports.ListEntry = ListEntry;
1348
+ class LessGuard extends Node {
1349
+ getConditions() {
1350
+ if (!this.conditions) {
1351
+ this.conditions = new Nodelist(this);
1352
+ }
1353
+ return this.conditions;
1354
+ }
1355
+ }
1356
+ exports.LessGuard = LessGuard;
1357
+ class GuardCondition extends Node {
1358
+ setVariable(node) {
1359
+ return this.setNode('variable', node);
1360
+ }
1361
+ }
1362
+ exports.GuardCondition = GuardCondition;
1363
+ class Module extends Node {
1364
+ get type() {
1365
+ return NodeType.Module;
1366
+ }
1367
+ setIdentifier(node) {
1368
+ return this.setNode('identifier', node, 0);
1369
+ }
1370
+ getIdentifier() {
1371
+ return this.identifier;
1372
+ }
1373
+ }
1374
+ exports.Module = Module;
1375
+ var Level;
1376
+ (function (Level) {
1377
+ Level[Level["Ignore"] = 1] = "Ignore";
1378
+ Level[Level["Warning"] = 2] = "Warning";
1379
+ Level[Level["Error"] = 4] = "Error";
1380
+ })(Level = exports.Level || (exports.Level = {}));
1381
+ class Marker {
1382
+ constructor(node, rule, level, message, offset = node.offset, length = node.length) {
1383
+ this.node = node;
1384
+ this.rule = rule;
1385
+ this.level = level;
1386
+ this.message = message || rule.message;
1387
+ this.offset = offset;
1388
+ this.length = length;
1389
+ }
1390
+ getRule() {
1391
+ return this.rule;
1392
+ }
1393
+ getLevel() {
1394
+ return this.level;
1395
+ }
1396
+ getOffset() {
1397
+ return this.offset;
1398
+ }
1399
+ getLength() {
1400
+ return this.length;
1401
+ }
1402
+ getNode() {
1403
+ return this.node;
1404
+ }
1405
+ getMessage() {
1406
+ return this.message;
1407
+ }
1408
+ }
1409
+ exports.Marker = Marker;
1410
+ /*
1411
+ export class DefaultVisitor implements IVisitor {
1412
+
1413
+ public visitNode(node:Node):boolean {
1414
+ switch (node.type) {
1415
+ case NodeType.Stylesheet:
1416
+ return this.visitStylesheet(<Stylesheet> node);
1417
+ case NodeType.FontFace:
1418
+ return this.visitFontFace(<FontFace> node);
1419
+ case NodeType.Ruleset:
1420
+ return this.visitRuleSet(<RuleSet> node);
1421
+ case NodeType.Selector:
1422
+ return this.visitSelector(<Selector> node);
1423
+ case NodeType.SimpleSelector:
1424
+ return this.visitSimpleSelector(<SimpleSelector> node);
1425
+ case NodeType.Declaration:
1426
+ return this.visitDeclaration(<Declaration> node);
1427
+ case NodeType.Function:
1428
+ return this.visitFunction(<Function> node);
1429
+ case NodeType.FunctionDeclaration:
1430
+ return this.visitFunctionDeclaration(<FunctionDeclaration> node);
1431
+ case NodeType.FunctionParameter:
1432
+ return this.visitFunctionParameter(<FunctionParameter> node);
1433
+ case NodeType.FunctionArgument:
1434
+ return this.visitFunctionArgument(<FunctionArgument> node);
1435
+ case NodeType.Term:
1436
+ return this.visitTerm(<Term> node);
1437
+ case NodeType.Declaration:
1438
+ return this.visitExpression(<Expression> node);
1439
+ case NodeType.NumericValue:
1440
+ return this.visitNumericValue(<NumericValue> node);
1441
+ case NodeType.Page:
1442
+ return this.visitPage(<Page> node);
1443
+ case NodeType.PageBoxMarginBox:
1444
+ return this.visitPageBoxMarginBox(<PageBoxMarginBox> node);
1445
+ case NodeType.Property:
1446
+ return this.visitProperty(<Property> node);
1447
+ case NodeType.NumericValue:
1448
+ return this.visitNodelist(<Nodelist> node);
1449
+ case NodeType.Import:
1450
+ return this.visitImport(<Import> node);
1451
+ case NodeType.Namespace:
1452
+ return this.visitNamespace(<Namespace> node);
1453
+ case NodeType.Keyframe:
1454
+ return this.visitKeyframe(<Keyframe> node);
1455
+ case NodeType.KeyframeSelector:
1456
+ return this.visitKeyframeSelector(<KeyframeSelector> node);
1457
+ case NodeType.MixinDeclaration:
1458
+ return this.visitMixinDeclaration(<MixinDeclaration> node);
1459
+ case NodeType.MixinReference:
1460
+ return this.visitMixinReference(<MixinReference> node);
1461
+ case NodeType.Variable:
1462
+ return this.visitVariable(<Variable> node);
1463
+ case NodeType.VariableDeclaration:
1464
+ return this.visitVariableDeclaration(<VariableDeclaration> node);
1465
+ }
1466
+ return this.visitUnknownNode(node);
1467
+ }
1468
+
1469
+ public visitFontFace(node:FontFace):boolean {
1470
+ return true;
1471
+ }
1472
+
1473
+ public visitKeyframe(node:Keyframe):boolean {
1474
+ return true;
1475
+ }
1476
+
1477
+ public visitKeyframeSelector(node:KeyframeSelector):boolean {
1478
+ return true;
1479
+ }
1480
+
1481
+ public visitStylesheet(node:Stylesheet):boolean {
1482
+ return true;
1483
+ }
1484
+
1485
+ public visitProperty(Node:Property):boolean {
1486
+ return true;
1487
+ }
1488
+
1489
+ public visitRuleSet(node:RuleSet):boolean {
1490
+ return true;
1491
+ }
1492
+
1493
+ public visitSelector(node:Selector):boolean {
1494
+ return true;
1495
+ }
1496
+
1497
+ public visitSimpleSelector(node:SimpleSelector):boolean {
1498
+ return true;
1499
+ }
1500
+
1501
+ public visitDeclaration(node:Declaration):boolean {
1502
+ return true;
1503
+ }
1504
+
1505
+ public visitFunction(node:Function):boolean {
1506
+ return true;
1507
+ }
1508
+
1509
+ public visitFunctionDeclaration(node:FunctionDeclaration):boolean {
1510
+ return true;
1511
+ }
1512
+
1513
+ public visitInvocation(node:Invocation):boolean {
1514
+ return true;
1515
+ }
1516
+
1517
+ public visitTerm(node:Term):boolean {
1518
+ return true;
1519
+ }
1520
+
1521
+ public visitImport(node:Import):boolean {
1522
+ return true;
1523
+ }
1524
+
1525
+ public visitNamespace(node:Namespace):boolean {
1526
+ return true;
1527
+ }
1528
+
1529
+ public visitExpression(node:Expression):boolean {
1530
+ return true;
1531
+ }
1532
+
1533
+ public visitNumericValue(node:NumericValue):boolean {
1534
+ return true;
1535
+ }
1536
+
1537
+ public visitPage(node:Page):boolean {
1538
+ return true;
1539
+ }
1540
+
1541
+ public visitPageBoxMarginBox(node:PageBoxMarginBox):boolean {
1542
+ return true;
1543
+ }
1544
+
1545
+ public visitNodelist(node:Nodelist):boolean {
1546
+ return true;
1547
+ }
1548
+
1549
+ public visitVariableDeclaration(node:VariableDeclaration):boolean {
1550
+ return true;
1551
+ }
1552
+
1553
+ public visitVariable(node:Variable):boolean {
1554
+ return true;
1555
+ }
1556
+
1557
+ public visitMixinDeclaration(node:MixinDeclaration):boolean {
1558
+ return true;
1559
+ }
1560
+
1561
+ public visitMixinReference(node:MixinReference):boolean {
1562
+ return true;
1563
+ }
1564
+
1565
+ public visitUnknownNode(node:Node):boolean {
1566
+ return true;
1567
+ }
1568
+ }
1569
+ */
1570
+ class ParseErrorCollector {
1571
+ constructor() {
1572
+ this.entries = [];
1573
+ }
1574
+ static entries(node) {
1575
+ const visitor = new ParseErrorCollector();
1576
+ node.acceptVisitor(visitor);
1577
+ return visitor.entries;
1578
+ }
1579
+ visitNode(node) {
1580
+ if (node.isErroneous()) {
1581
+ node.collectIssues(this.entries);
1582
+ }
1583
+ return true;
1584
+ }
1585
+ }
1586
+ exports.ParseErrorCollector = ParseErrorCollector;
1587
+ });