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