vscode-css-languageservice 5.1.7 → 5.1.11

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.
@@ -50,8 +50,9 @@ var localize = nls.loadMessageBundle();
50
50
  var startsWithSchemeRegex = /^\w+:\/\//;
51
51
  var startsWithData = /^data:/;
52
52
  var CSSNavigation = /** @class */ (function () {
53
- function CSSNavigation(fileSystemProvider) {
53
+ function CSSNavigation(fileSystemProvider, resolveModuleReferences) {
54
54
  this.fileSystemProvider = fileSystemProvider;
55
+ this.resolveModuleReferences = resolveModuleReferences;
55
56
  }
56
57
  CSSNavigation.prototype.findDefinition = function (document, position, stylesheet) {
57
58
  var symbols = new Symbols(stylesheet);
@@ -281,25 +282,25 @@ var CSSNavigation = /** @class */ (function () {
281
282
  var red256 = Math.round(color.red * 255), green256 = Math.round(color.green * 255), blue256 = Math.round(color.blue * 255);
282
283
  var label;
283
284
  if (color.alpha === 1) {
284
- label = "rgb(" + red256 + ", " + green256 + ", " + blue256 + ")";
285
+ label = "rgb(".concat(red256, ", ").concat(green256, ", ").concat(blue256, ")");
285
286
  }
286
287
  else {
287
- label = "rgba(" + red256 + ", " + green256 + ", " + blue256 + ", " + color.alpha + ")";
288
+ label = "rgba(".concat(red256, ", ").concat(green256, ", ").concat(blue256, ", ").concat(color.alpha, ")");
288
289
  }
289
290
  result.push({ label: label, textEdit: TextEdit.replace(range, label) });
290
291
  if (color.alpha === 1) {
291
- label = "#" + toTwoDigitHex(red256) + toTwoDigitHex(green256) + toTwoDigitHex(blue256);
292
+ label = "#".concat(toTwoDigitHex(red256)).concat(toTwoDigitHex(green256)).concat(toTwoDigitHex(blue256));
292
293
  }
293
294
  else {
294
- label = "#" + toTwoDigitHex(red256) + toTwoDigitHex(green256) + toTwoDigitHex(blue256) + toTwoDigitHex(Math.round(color.alpha * 255));
295
+ label = "#".concat(toTwoDigitHex(red256)).concat(toTwoDigitHex(green256)).concat(toTwoDigitHex(blue256)).concat(toTwoDigitHex(Math.round(color.alpha * 255)));
295
296
  }
296
297
  result.push({ label: label, textEdit: TextEdit.replace(range, label) });
297
298
  var hsl = hslFromColor(color);
298
299
  if (hsl.a === 1) {
299
- label = "hsl(" + hsl.h + ", " + Math.round(hsl.s * 100) + "%, " + Math.round(hsl.l * 100) + "%)";
300
+ label = "hsl(".concat(hsl.h, ", ").concat(Math.round(hsl.s * 100), "%, ").concat(Math.round(hsl.l * 100), "%)");
300
301
  }
301
302
  else {
302
- label = "hsla(" + hsl.h + ", " + Math.round(hsl.s * 100) + "%, " + Math.round(hsl.l * 100) + "%, " + hsl.a + ")";
303
+ label = "hsla(".concat(hsl.h, ", ").concat(Math.round(hsl.s * 100), "%, ").concat(Math.round(hsl.l * 100), "%, ").concat(hsl.a, ")");
303
304
  }
304
305
  result.push({ label: label, textEdit: TextEdit.replace(range, label) });
305
306
  return result;
@@ -312,14 +313,12 @@ var CSSNavigation = /** @class */ (function () {
312
313
  changes: (_a = {}, _a[document.uri] = edits, _a)
313
314
  };
314
315
  };
315
- CSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext, isRawLink) {
316
+ CSSNavigation.prototype.resolveModuleReference = function (ref, documentUri, documentContext) {
316
317
  return __awaiter(this, void 0, void 0, function () {
317
318
  var moduleName, rootFolderUri, documentFolderUri, modulePath, pathWithinModule;
318
319
  return __generator(this, function (_a) {
319
320
  switch (_a.label) {
320
321
  case 0:
321
- if (!(ref[0] === '~' && ref[1] !== '/' && this.fileSystemProvider)) return [3 /*break*/, 3];
322
- ref = ref.substring(1);
323
322
  if (!startsWith(documentUri, 'file://')) return [3 /*break*/, 2];
324
323
  moduleName = getModuleNameFromPath(ref);
325
324
  rootFolderUri = documentContext.resolveReference('/', documentUri);
@@ -332,8 +331,36 @@ var CSSNavigation = /** @class */ (function () {
332
331
  return [2 /*return*/, joinPath(modulePath, pathWithinModule)];
333
332
  }
334
333
  _a.label = 2;
335
- case 2: return [2 /*return*/, documentContext.resolveReference(ref, documentUri)];
336
- case 3: return [2 /*return*/, documentContext.resolveReference(ref, documentUri)];
334
+ case 2: return [2 /*return*/, undefined];
335
+ }
336
+ });
337
+ });
338
+ };
339
+ CSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext, isRawLink) {
340
+ return __awaiter(this, void 0, void 0, function () {
341
+ var relativeReference, _a;
342
+ return __generator(this, function (_b) {
343
+ switch (_b.label) {
344
+ case 0:
345
+ relativeReference = documentContext.resolveReference(ref, documentUri);
346
+ if (!(ref[0] === '~' && ref[1] !== '/' && this.fileSystemProvider)) return [3 /*break*/, 2];
347
+ ref = ref.substring(1);
348
+ return [4 /*yield*/, this.resolveModuleReference(ref, documentUri, documentContext)];
349
+ case 1: return [2 /*return*/, (_b.sent()) || relativeReference];
350
+ case 2:
351
+ if (!this.resolveModuleReferences) return [3 /*break*/, 7];
352
+ _a = relativeReference;
353
+ if (!_a) return [3 /*break*/, 4];
354
+ return [4 /*yield*/, this.fileExists(relativeReference)];
355
+ case 3:
356
+ _a = (_b.sent());
357
+ _b.label = 4;
358
+ case 4:
359
+ if (!_a) return [3 /*break*/, 5];
360
+ return [2 /*return*/, relativeReference];
361
+ case 5: return [4 /*yield*/, this.resolveModuleReference(ref, documentUri, documentContext)];
362
+ case 6: return [2 /*return*/, (_b.sent()) || relativeReference];
363
+ case 7: return [2 /*return*/, relativeReference];
337
364
  }
338
365
  });
339
366
  });
@@ -162,7 +162,7 @@ var LintVisitor = /** @class */ (function () {
162
162
  if (atDirective) {
163
163
  return false;
164
164
  }
165
- this.addEntry(atRuleName, Rules.UnknownAtRules, "Unknown at rule " + atRuleName.getText());
165
+ this.addEntry(atRuleName, Rules.UnknownAtRules, "Unknown at rule ".concat(atRuleName.getText()));
166
166
  return true;
167
167
  };
168
168
  LintVisitor.prototype.visitKeyframe = function (node) {
@@ -44,7 +44,7 @@ var SCSSCompletion = /** @class */ (function (_super) {
44
44
  var item = {
45
45
  label: p.label,
46
46
  documentation: p.documentation,
47
- textEdit: TextEdit.replace(this.getCompletionRange(importPathNode), "'" + p.label + "'"),
47
+ textEdit: TextEdit.replace(this.getCompletionRange(importPathNode), "'".concat(p.label, "'")),
48
48
  kind: CompletionItemKind.Module
49
49
  };
50
50
  result.items.push(item);
@@ -369,7 +369,7 @@ function addReferencesToDocumentation(items) {
369
369
  markdownDoc.value += '\n\n';
370
370
  markdownDoc.value += i.references
371
371
  .map(function (r) {
372
- return "[" + r.name + "](" + r.url + ")";
372
+ return "[".concat(r.name, "](").concat(r.url, ")");
373
373
  })
374
374
  .join(' | ');
375
375
  i.documentation = markdownDoc;
@@ -61,7 +61,7 @@ import { startsWith } from '../utils/strings';
61
61
  var SCSSNavigation = /** @class */ (function (_super) {
62
62
  __extends(SCSSNavigation, _super);
63
63
  function SCSSNavigation(fileSystemProvider) {
64
- return _super.call(this, fileSystemProvider) || this;
64
+ return _super.call(this, fileSystemProvider, true) || this;
65
65
  }
66
66
  SCSSNavigation.prototype.isRawStringDocumentLinkNode = function (node) {
67
67
  return (_super.prototype.isRawStringDocumentLinkNode.call(this, node) ||
@@ -291,23 +291,23 @@ export function toElement(node, parentElement) {
291
291
  switch (unescape(operator.getText())) {
292
292
  case '|=':
293
293
  // excatly or followed by -words
294
- value = quotes.remove(unescape(expression.getText())) + "-\u2026";
294
+ value = "".concat(quotes.remove(unescape(expression.getText())), "-\u2026");
295
295
  break;
296
296
  case '^=':
297
297
  // prefix
298
- value = quotes.remove(unescape(expression.getText())) + "\u2026";
298
+ value = "".concat(quotes.remove(unescape(expression.getText())), "\u2026");
299
299
  break;
300
300
  case '$=':
301
301
  // suffix
302
- value = "\u2026" + quotes.remove(unescape(expression.getText()));
302
+ value = "\u2026".concat(quotes.remove(unescape(expression.getText())));
303
303
  break;
304
304
  case '~=':
305
305
  // one of a list of words
306
- value = " \u2026 " + quotes.remove(unescape(expression.getText())) + " \u2026 ";
306
+ value = " \u2026 ".concat(quotes.remove(unescape(expression.getText())), " \u2026 ");
307
307
  break;
308
308
  case '*=':
309
309
  // substring
310
- value = "\u2026" + quotes.remove(unescape(expression.getText())) + "\u2026";
310
+ value = "\u2026".concat(quotes.remove(unescape(expression.getText())), "\u2026");
311
311
  break;
312
312
  default:
313
313
  value = quotes.remove(unescape(expression.getText()));
@@ -82,7 +82,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
82
82
  function getCSSLanguageService(options) {
83
83
  if (options === void 0) { options = defaultLanguageServiceOptions; }
84
84
  var cssDataManager = new dataManager_1.CSSDataManager(options);
85
- return createFacade(new cssParser_1.Parser(), new cssCompletion_1.CSSCompletion(null, options, cssDataManager), new cssHover_1.CSSHover(options && options.clientCapabilities, cssDataManager), new cssNavigation_1.CSSNavigation(options && options.fileSystemProvider), new cssCodeActions_1.CSSCodeActions(cssDataManager), new cssValidation_1.CSSValidation(cssDataManager), cssDataManager);
85
+ return createFacade(new cssParser_1.Parser(), new cssCompletion_1.CSSCompletion(null, options, cssDataManager), new cssHover_1.CSSHover(options && options.clientCapabilities, cssDataManager), new cssNavigation_1.CSSNavigation(options && options.fileSystemProvider, false), new cssCodeActions_1.CSSCodeActions(cssDataManager), new cssValidation_1.CSSValidation(cssDataManager), cssDataManager);
86
86
  }
87
87
  exports.getCSSLanguageService = getCSSLanguageService;
88
88
  function getSCSSLanguageService(options) {
@@ -94,7 +94,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
94
94
  function getLESSLanguageService(options) {
95
95
  if (options === void 0) { options = defaultLanguageServiceOptions; }
96
96
  var cssDataManager = new dataManager_1.CSSDataManager(options);
97
- return createFacade(new lessParser_1.LESSParser(), new lessCompletion_1.LESSCompletion(options, cssDataManager), new cssHover_1.CSSHover(options && options.clientCapabilities, cssDataManager), new cssNavigation_1.CSSNavigation(options && options.fileSystemProvider), new cssCodeActions_1.CSSCodeActions(cssDataManager), new cssValidation_1.CSSValidation(cssDataManager), cssDataManager);
97
+ return createFacade(new lessParser_1.LESSParser(), new lessCompletion_1.LESSCompletion(options, cssDataManager), new cssHover_1.CSSHover(options && options.clientCapabilities, cssDataManager), new cssNavigation_1.CSSNavigation(options && options.fileSystemProvider, true), new cssCodeActions_1.CSSCodeActions(cssDataManager), new cssValidation_1.CSSValidation(cssDataManager), cssDataManager);
98
98
  }
99
99
  exports.getLESSLanguageService = getLESSLanguageService;
100
100
  });