vscode-css-languageservice 4.3.0-next.0 → 4.3.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.
package/CHANGELOG.md CHANGED
@@ -1,30 +1,32 @@
1
- 4.3.0 - 2020-05-25
2
- ===================
3
- - module resolving in urls (`~foo/hello.html`) when using `LanguageService.findDocumentLinks2` and if `fileSystemProvider` is provided.
4
- - new API `LanguageService.doComplete2`. Support path completion if `fileSystemProvider.readDirectory` is provided.
5
1
 
6
2
 
3
+ 4.3.0 - 2020-06-26
4
+ ===================
5
+ * module resolving in urls (`~foo/hello.html`) when using `LanguageService.findDocumentLinks2` and if `fileSystemProvider` is provided.
6
+ * new API `LanguageService.doComplete2`. Support path completion if `fileSystemProvider.readDirectory` is provided.
7
+ * `DocumentContext.resolveReference` can also return undefined (if the ref is invalid)
8
+
7
9
  4.2.0 - 2020-05-14
8
10
  ===================
9
- * new API `LanguageServiceOptions.useDefaultDataProvider` to control whether the default data provider is used. Defaults to true
10
- * new API `LanguageService.setDataProviders` to update the data providers.
11
+ * new API `LanguageServiceOptions.useDefaultDataProvider` to control whether the default data provider is used. Defaults to true
12
+ * new API `LanguageService.setDataProviders` to update the data providers.
11
13
 
12
14
  4.1.0 - 2020-02-23
13
15
  ===================
14
- * markdown descriptions in completions and hover
15
- * new API `LanguageServiceOptions.clientCapabilities` with `ClientCapabilities` for completion documentationFormat and hover content
16
- * extended format of CustomData (version 1.1) with MarkupContent contents and reference links
17
- * dynamically resolved links for scss include statements
18
- * new API `LanguageService.findDocumentLinks2`: Also returns dynamically resolved links if `fileSystemProvider` is provided
19
- * new API `LanguageServiceOptions.fileSystemProvider` with `FileSystemProvider` to query the file system (currently used to resolve the location of included files)
20
- * new API `CompletionSettings.completePropertyWithSemicolon`
21
- * new API `ICompletionParticipant.onCssMixinReference`
22
- * Switch to `TextDocument` from `vscode-languageserver-textdocument` (reexported from the main module)
16
+ * markdown descriptions in completions and hover
17
+ * new API `LanguageServiceOptions.clientCapabilities` with `ClientCapabilities` for completion documentationFormat and hover content
18
+ * extended format of CustomData (version 1.1) with MarkupContent contents and reference links
19
+ * dynamically resolved links for scss include statements
20
+ * new API `LanguageService.findDocumentLinks2`: Also returns dynamically resolved links if `fileSystemProvider` is provided
21
+ * new API `LanguageServiceOptions.fileSystemProvider` with `FileSystemProvider` to query the file system (currently used to resolve the location of included files)
22
+ * new API `CompletionSettings.completePropertyWithSemicolon`
23
+ * new API `ICompletionParticipant.onCssMixinReference`
24
+ * Switch to `TextDocument` from `vscode-languageserver-textdocument` (reexported from the main module)
23
25
 
24
26
  4.0.0 / 2019-06-12
25
27
  ===================
26
- * `LanguageServiceOptions.customDataProviders` allows you to use custom datasets for properties, at-properties, pseudo-classes and pseudo-elements.
27
- * New API `LanguageService.getSelectionRanges`
28
+ * `LanguageServiceOptions.customDataProviders` allows you to use custom datasets for properties, at-properties, pseudo-classes and pseudo-elements.
29
+ * New API `LanguageService.getSelectionRanges`
28
30
 
29
31
  3.0.12 / 2018-10-29
30
32
  ===================
@@ -3,6 +3,11 @@
3
3
  In VS Code, there are two ways of loading custom CSS datasets:
4
4
 
5
5
  1. With setting `css.customData`
6
+ ```json
7
+ "css.customData": [
8
+ "./foo.css-data.json"
9
+ ]
10
+ ```
6
11
  2. With an extension that contributes `contributes.css.customData`
7
12
 
8
13
  Both setting point to a list of JSON files. This document describes the shape of the JSON files.
@@ -37,6 +42,7 @@ All top-level properties share two basic properties, `name` and `description`. F
37
42
 
38
43
  ```jsonc
39
44
  {
45
+ "version": 1.1,
40
46
  "properties": [
41
47
  { "name": "foo", "description": "Foo property" }
42
48
  ],
@@ -44,7 +44,7 @@ export interface ICompletionParticipant {
44
44
  onCssMixinReference?: (context: MixinReferenceCompletionContext) => void;
45
45
  }
46
46
  export interface DocumentContext {
47
- resolveReference(ref: string, base?: string): string;
47
+ resolveReference(ref: string, baseUrl: string): string | undefined;
48
48
  }
49
49
  /**
50
50
  * Describes what LSP capabilities the client supports
@@ -42,6 +42,9 @@ export function getEntryDescription(entry, doesSupportMarkdown) {
42
42
  }
43
43
  return result;
44
44
  }
45
+ export function textToMarkedString(text) {
46
+ return text.replace(/[\\`*_{}[\]()#+\-.!<>]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
47
+ }
45
48
  function getEntryStringDescription(entry) {
46
49
  if (!entry.description || entry.description === '') {
47
50
  return '';
@@ -77,18 +80,14 @@ function getEntryMarkdownDescription(entry) {
77
80
  if (entry.status) {
78
81
  result += getEntryStatus(entry.status);
79
82
  }
80
- if (typeof entry.description === 'string') {
81
- result += entry.description;
82
- }
83
- else {
84
- result = entry.description.value;
85
- }
83
+ var description = typeof entry.description === 'string' ? entry.description : entry.description.value;
84
+ result += textToMarkedString(description);
86
85
  var browserLabel = getBrowserLabel(entry.browsers);
87
86
  if (browserLabel) {
88
- result += '\n\n(' + browserLabel + ')';
87
+ result += '\n\n(' + textToMarkedString(browserLabel) + ')';
89
88
  }
90
- if ('syntax' in entry) {
91
- result += "\n\nSyntax: " + entry.syntax;
89
+ if ('syntax' in entry && entry.syntax) {
90
+ result += "\n\nSyntax: " + textToMarkedString(entry.syntax);
92
91
  }
93
92
  if (entry.references && entry.references.length > 0) {
94
93
  result += '\n\n';
@@ -85,11 +85,17 @@ var SCSSParser = /** @class */ (function (_super) {
85
85
  if (!node.setValue(this._parseExpr())) {
86
86
  return this.finish(node, ParseError.VariableValueExpected, [], panic);
87
87
  }
88
- while (this.accept(TokenType.Exclamation)) {
89
- if (!this.peekRegExp(TokenType.Ident, /^(default|global)$/)) {
90
- return this.finish(node, ParseError.UnknownKeyword);
88
+ while (this.peek(TokenType.Exclamation)) {
89
+ if (node.addChild(this._tryParsePrio())) {
90
+ // !important
91
+ }
92
+ else {
93
+ this.consumeToken();
94
+ if (!this.peekRegExp(TokenType.Ident, /^(default|global)$/)) {
95
+ return this.finish(node, ParseError.UnknownKeyword);
96
+ }
97
+ this.consumeToken();
91
98
  }
92
- this.consumeToken();
93
99
  }
94
100
  if (this.peek(TokenType.SemiColon)) {
95
101
  node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
@@ -170,7 +176,7 @@ var SCSSParser = /** @class */ (function (_super) {
170
176
  return this._parseModuleMember() ||
171
177
  this._parseVariable() ||
172
178
  this._parseSelectorCombinator() ||
173
- this._tryParsePrio() ||
179
+ //this._tryParsePrio() ||
174
180
  _super.prototype._parseTermExpression.call(this);
175
181
  };
176
182
  SCSSParser.prototype._parseInterpolation = function () {
@@ -628,6 +634,9 @@ var SCSSParser = /** @class */ (function (_super) {
628
634
  node.addChild(this._parsePrio()); // #9859
629
635
  return this.finish(node);
630
636
  }
637
+ else if (node.setValue(this._tryParsePrio())) {
638
+ return this.finish(node);
639
+ }
631
640
  return null;
632
641
  };
633
642
  SCSSParser.prototype._parseURLArgument = function () {
@@ -118,33 +118,44 @@ var CSSNavigation = /** @class */ (function () {
118
118
  for (var i = 0; i < links.length; i++) {
119
119
  var target = links[i].target;
120
120
  if (target && !(/^\w+:\/\//g.test(target))) {
121
- links[i].target = documentContext.resolveReference(target, document.uri);
121
+ var resolved = documentContext.resolveReference(target, document.uri);
122
+ if (resolved) {
123
+ links[i].target = resolved;
124
+ }
122
125
  }
123
126
  }
124
127
  return links;
125
128
  };
126
129
  CSSNavigation.prototype.findDocumentLinks2 = function (document, stylesheet, documentContext) {
127
130
  return __awaiter(this, void 0, void 0, function () {
128
- var links, i, target, _a;
129
- return __generator(this, function (_b) {
130
- switch (_b.label) {
131
+ var links, resolvedLinks, _i, links_1, link, target, resolvedTarget;
132
+ return __generator(this, function (_a) {
133
+ switch (_a.label) {
131
134
  case 0:
132
135
  links = this.findUnresolvedLinks(document, stylesheet);
133
- i = 0;
134
- _b.label = 1;
136
+ resolvedLinks = [];
137
+ _i = 0, links_1 = links;
138
+ _a.label = 1;
135
139
  case 1:
136
- if (!(i < links.length)) return [3 /*break*/, 4];
137
- target = links[i].target;
140
+ if (!(_i < links_1.length)) return [3 /*break*/, 5];
141
+ link = links_1[_i];
142
+ target = link.target;
138
143
  if (!(target && !(/^\w+:\/\//g.test(target)))) return [3 /*break*/, 3];
139
- _a = links[i];
140
144
  return [4 /*yield*/, this.resolveRelativeReference(target, document.uri, documentContext)];
141
145
  case 2:
142
- _a.target = _b.sent();
143
- _b.label = 3;
146
+ resolvedTarget = _a.sent();
147
+ if (resolvedTarget !== undefined) {
148
+ link.target = resolvedTarget;
149
+ resolvedLinks.push(link);
150
+ }
151
+ return [3 /*break*/, 4];
144
152
  case 3:
145
- i++;
153
+ resolvedLinks.push(link);
154
+ _a.label = 4;
155
+ case 4:
156
+ _i++;
146
157
  return [3 /*break*/, 1];
147
- case 4: return [2 /*return*/, links];
158
+ case 5: return [2 /*return*/, resolvedLinks];
148
159
  }
149
160
  });
150
161
  });
@@ -60,9 +60,6 @@ var PathCompletionParticipant = /** @class */ (function () {
60
60
  switch (_f.label) {
61
61
  case 0:
62
62
  result = { items: [], isIncomplete: false };
63
- if (!(startsWith(document.uri, 'file:'))) {
64
- return [2 /*return*/, result];
65
- }
66
63
  _i = 0, _a = this.literalCompletions;
67
64
  _f.label = 1;
68
65
  case 1:
@@ -139,6 +136,7 @@ var PathCompletionParticipant = /** @class */ (function () {
139
136
  replaceRange = pathToReplaceRange(valueBeforeCursor, fullValue, fullValueRange);
140
137
  valueBeforeLastSlash = valueBeforeCursor.substring(0, valueBeforeCursor.lastIndexOf('/') + 1);
141
138
  parentDir = documentContext.resolveReference(valueBeforeLastSlash || '.', currentDocUri);
139
+ if (!parentDir) return [3 /*break*/, 4];
142
140
  _b.label = 1;
143
141
  case 1:
144
142
  _b.trys.push([1, 3, , 4]);
@@ -156,8 +154,8 @@ var PathCompletionParticipant = /** @class */ (function () {
156
154
  return [2 /*return*/, result];
157
155
  case 3:
158
156
  e_1 = _b.sent();
159
- return [2 /*return*/, []];
160
- case 4: return [2 /*return*/];
157
+ return [3 /*break*/, 4];
158
+ case 4: return [2 /*return*/, []];
161
159
  }
162
160
  });
163
161
  });
@@ -16,17 +16,6 @@ var __extends = (this && this.__extends) || (function () {
16
16
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
17
  };
18
18
  })();
19
- var __assign = (this && this.__assign) || function () {
20
- __assign = Object.assign || function(t) {
21
- for (var s, i = 1, n = arguments.length; i < n; i++) {
22
- s = arguments[i];
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
24
- t[p] = s[p];
25
- }
26
- return t;
27
- };
28
- return __assign.apply(this, arguments);
29
- };
30
19
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
31
20
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
32
21
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -66,6 +55,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
66
55
  import { CSSNavigation } from './cssNavigation';
67
56
  import * as nodes from '../parser/cssNodes';
68
57
  import { URI } from 'vscode-uri';
58
+ import { startsWith } from '../utils/strings';
59
+ import { extname } from '../utils/resources';
69
60
  var SCSSNavigation = /** @class */ (function (_super) {
70
61
  __extends(SCSSNavigation, _super);
71
62
  function SCSSNavigation(fileSystemProvider) {
@@ -76,7 +67,7 @@ var SCSSNavigation = /** @class */ (function (_super) {
76
67
  node.type === nodes.NodeType.Use ||
77
68
  node.type === nodes.NodeType.Forward);
78
69
  };
79
- SCSSNavigation.prototype.findDocumentLinks2 = function (document, stylesheet, documentContext) {
70
+ SCSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext) {
80
71
  return __awaiter(this, void 0, void 0, function () {
81
72
  function toPathVariations(uri) {
82
73
  // No valid path
@@ -118,63 +109,41 @@ var SCSSNavigation = /** @class */ (function (_super) {
118
109
  var cssPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '.css');
119
110
  return [normalizedPath, underScorePath, indexPath, indexUnderscoreUri, cssPath];
120
111
  }
121
- var links, fsProvider, validLinks, i, target, parsedUri, pathVariations, j;
112
+ var target, parsedUri, pathVariations, j, e_1;
122
113
  return __generator(this, function (_a) {
123
114
  switch (_a.label) {
124
115
  case 0:
125
- links = this.findDocumentLinks(document, stylesheet, documentContext);
126
- fsProvider = this.fileSystemProvider;
127
- validLinks = [];
128
- if (!fsProvider) return [3 /*break*/, 9];
129
- i = 0;
130
- _a.label = 1;
131
- case 1:
132
- if (!(i < links.length)) return [3 /*break*/, 8];
133
- target = links[i].target;
134
- if (!target) {
135
- return [3 /*break*/, 7];
136
- }
137
- parsedUri = null;
138
- try {
139
- parsedUri = URI.parse(target);
116
+ if (startsWith(ref, 'sass:')) {
117
+ return [2 /*return*/, undefined]; // sass library
140
118
  }
141
- catch (e) {
142
- if (e instanceof URIError) {
143
- return [3 /*break*/, 7];
144
- }
145
- throw e;
146
- }
147
- pathVariations = toPathVariations(parsedUri);
148
- if (!!pathVariations) return [3 /*break*/, 3];
149
- return [4 /*yield*/, this.fileExists(target)];
119
+ return [4 /*yield*/, _super.prototype.resolveRelativeReference.call(this, ref, documentUri, documentContext)];
120
+ case 1:
121
+ target = _a.sent();
122
+ if (!(this.fileSystemProvider && target && extname(target).length === 0)) return [3 /*break*/, 8];
123
+ _a.label = 2;
150
124
  case 2:
151
- if (_a.sent()) {
152
- validLinks.push(links[i]);
153
- }
154
- return [3 /*break*/, 7];
155
- case 3:
125
+ _a.trys.push([2, 7, , 8]);
126
+ parsedUri = URI.parse(target);
127
+ pathVariations = toPathVariations(parsedUri);
128
+ if (!pathVariations) return [3 /*break*/, 6];
156
129
  j = 0;
157
- _a.label = 4;
158
- case 4:
159
- if (!(j < pathVariations.length)) return [3 /*break*/, 7];
130
+ _a.label = 3;
131
+ case 3:
132
+ if (!(j < pathVariations.length)) return [3 /*break*/, 6];
160
133
  return [4 /*yield*/, this.fileExists(pathVariations[j])];
161
- case 5:
134
+ case 4:
162
135
  if (_a.sent()) {
163
- validLinks.push(__assign(__assign({}, links[i]), { target: pathVariations[j] }));
164
- return [3 /*break*/, 7];
136
+ return [2 /*return*/, pathVariations[j]];
165
137
  }
166
- _a.label = 6;
167
- case 6:
138
+ _a.label = 5;
139
+ case 5:
168
140
  j++;
169
- return [3 /*break*/, 4];
141
+ return [3 /*break*/, 3];
142
+ case 6: return [2 /*return*/, undefined];
170
143
  case 7:
171
- i++;
172
- return [3 /*break*/, 1];
173
- case 8: return [3 /*break*/, 10];
174
- case 9:
175
- validLinks.push.apply(validLinks, links);
176
- _a.label = 10;
177
- case 10: return [2 /*return*/, validLinks];
144
+ e_1 = _a.sent();
145
+ return [3 /*break*/, 8];
146
+ case 8: return [2 /*return*/, target];
178
147
  }
179
148
  });
180
149
  });
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { URI } from "vscode-uri";
6
- import { endsWith, startsWith } from "./strings";
7
6
  var Slash = '/'.charCodeAt(0);
7
+ var Dot = '.'.charCodeAt(0);
8
8
  export function isAbsolutePath(path) {
9
9
  return path.charCodeAt(0) === Slash;
10
10
  }
@@ -16,26 +16,64 @@ export function basename(uri) {
16
16
  var lastIndexOfSlash = uri.lastIndexOf('/');
17
17
  return uri.substr(lastIndexOfSlash + 1);
18
18
  }
19
+ export function extname(uri) {
20
+ for (var i = uri.length - 1; i >= 0; i--) {
21
+ var ch = uri.charCodeAt(i);
22
+ if (ch === Dot) {
23
+ if (i > 0 && uri.charCodeAt(i - 1) !== Slash) {
24
+ return uri.substr(i);
25
+ }
26
+ else {
27
+ break;
28
+ }
29
+ }
30
+ else if (ch === Slash) {
31
+ break;
32
+ }
33
+ }
34
+ return '';
35
+ }
36
+ export function resolvePath(uriString, path) {
37
+ if (isAbsolutePath(path)) {
38
+ var uri = URI.parse(uriString);
39
+ var parts = path.split('/');
40
+ return uri.with({ path: normalizePath(parts) }).toString();
41
+ }
42
+ return joinPath(uriString, path);
43
+ }
44
+ export function normalizePath(parts) {
45
+ var newParts = [];
46
+ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
47
+ var part = parts_1[_i];
48
+ if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) {
49
+ // ignore
50
+ }
51
+ else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) {
52
+ newParts.pop();
53
+ }
54
+ else {
55
+ newParts.push(part);
56
+ }
57
+ }
58
+ if (parts.length > 1 && parts[parts.length - 1].length === 0) {
59
+ newParts.push('');
60
+ }
61
+ var res = newParts.join('/');
62
+ if (parts[0].length === 0) {
63
+ res = '/' + res;
64
+ }
65
+ return res;
66
+ }
19
67
  export function joinPath(uriString) {
20
68
  var paths = [];
21
69
  for (var _i = 1; _i < arguments.length; _i++) {
22
70
  paths[_i - 1] = arguments[_i];
23
71
  }
24
72
  var uri = URI.parse(uriString);
25
- var uriPath = uri.path;
73
+ var parts = uri.path.split('/');
26
74
  for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
27
75
  var path = paths_1[_a];
28
- if (!endsWith(uriPath, '/') && !startsWith(path, '/')) {
29
- uriPath += '/';
30
- }
31
- uriPath += path;
76
+ parts.push.apply(parts, path.split('/'));
32
77
  }
33
- return uri.with({ path: uriPath }).toString();
34
- }
35
- export function resolvePath(uriString, path) {
36
- if (isAbsolutePath(path)) {
37
- var uri = URI.parse(uriString);
38
- return uri.with({ path: path }).toString();
39
- }
40
- return joinPath(uriString, path);
78
+ return uri.with({ path: normalizePath(parts) }).toString();
41
79
  }
@@ -44,7 +44,7 @@ export interface ICompletionParticipant {
44
44
  onCssMixinReference?: (context: MixinReferenceCompletionContext) => void;
45
45
  }
46
46
  export interface DocumentContext {
47
- resolveReference(ref: string, base?: string): string;
47
+ resolveReference(ref: string, baseUrl: string): string | undefined;
48
48
  }
49
49
  /**
50
50
  * Describes what LSP capabilities the client supports
@@ -53,6 +53,10 @@
53
53
  return result;
54
54
  }
55
55
  exports.getEntryDescription = getEntryDescription;
56
+ function textToMarkedString(text) {
57
+ return text.replace(/[\\`*_{}[\]()#+\-.!<>]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
58
+ }
59
+ exports.textToMarkedString = textToMarkedString;
56
60
  function getEntryStringDescription(entry) {
57
61
  if (!entry.description || entry.description === '') {
58
62
  return '';
@@ -88,18 +92,14 @@
88
92
  if (entry.status) {
89
93
  result += getEntryStatus(entry.status);
90
94
  }
91
- if (typeof entry.description === 'string') {
92
- result += entry.description;
93
- }
94
- else {
95
- result = entry.description.value;
96
- }
95
+ var description = typeof entry.description === 'string' ? entry.description : entry.description.value;
96
+ result += textToMarkedString(description);
97
97
  var browserLabel = getBrowserLabel(entry.browsers);
98
98
  if (browserLabel) {
99
- result += '\n\n(' + browserLabel + ')';
99
+ result += '\n\n(' + textToMarkedString(browserLabel) + ')';
100
100
  }
101
- if ('syntax' in entry) {
102
- result += "\n\nSyntax: " + entry.syntax;
101
+ if ('syntax' in entry && entry.syntax) {
102
+ result += "\n\nSyntax: " + textToMarkedString(entry.syntax);
103
103
  }
104
104
  if (entry.references && entry.references.length > 0) {
105
105
  result += '\n\n';
@@ -95,11 +95,17 @@ var __extends = (this && this.__extends) || (function () {
95
95
  if (!node.setValue(this._parseExpr())) {
96
96
  return this.finish(node, cssErrors_1.ParseError.VariableValueExpected, [], panic);
97
97
  }
98
- while (this.accept(cssScanner_1.TokenType.Exclamation)) {
99
- if (!this.peekRegExp(cssScanner_1.TokenType.Ident, /^(default|global)$/)) {
100
- return this.finish(node, cssErrors_1.ParseError.UnknownKeyword);
98
+ while (this.peek(cssScanner_1.TokenType.Exclamation)) {
99
+ if (node.addChild(this._tryParsePrio())) {
100
+ // !important
101
+ }
102
+ else {
103
+ this.consumeToken();
104
+ if (!this.peekRegExp(cssScanner_1.TokenType.Ident, /^(default|global)$/)) {
105
+ return this.finish(node, cssErrors_1.ParseError.UnknownKeyword);
106
+ }
107
+ this.consumeToken();
101
108
  }
102
- this.consumeToken();
103
109
  }
104
110
  if (this.peek(cssScanner_1.TokenType.SemiColon)) {
105
111
  node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
@@ -180,7 +186,7 @@ var __extends = (this && this.__extends) || (function () {
180
186
  return this._parseModuleMember() ||
181
187
  this._parseVariable() ||
182
188
  this._parseSelectorCombinator() ||
183
- this._tryParsePrio() ||
189
+ //this._tryParsePrio() ||
184
190
  _super.prototype._parseTermExpression.call(this);
185
191
  };
186
192
  SCSSParser.prototype._parseInterpolation = function () {
@@ -638,6 +644,9 @@ var __extends = (this && this.__extends) || (function () {
638
644
  node.addChild(this._parsePrio()); // #9859
639
645
  return this.finish(node);
640
646
  }
647
+ else if (node.setValue(this._tryParsePrio())) {
648
+ return this.finish(node);
649
+ }
641
650
  return null;
642
651
  };
643
652
  SCSSParser.prototype._parseURLArgument = function () {
@@ -128,33 +128,44 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
128
128
  for (var i = 0; i < links.length; i++) {
129
129
  var target = links[i].target;
130
130
  if (target && !(/^\w+:\/\//g.test(target))) {
131
- links[i].target = documentContext.resolveReference(target, document.uri);
131
+ var resolved = documentContext.resolveReference(target, document.uri);
132
+ if (resolved) {
133
+ links[i].target = resolved;
134
+ }
132
135
  }
133
136
  }
134
137
  return links;
135
138
  };
136
139
  CSSNavigation.prototype.findDocumentLinks2 = function (document, stylesheet, documentContext) {
137
140
  return __awaiter(this, void 0, void 0, function () {
138
- var links, i, target, _a;
139
- return __generator(this, function (_b) {
140
- switch (_b.label) {
141
+ var links, resolvedLinks, _i, links_1, link, target, resolvedTarget;
142
+ return __generator(this, function (_a) {
143
+ switch (_a.label) {
141
144
  case 0:
142
145
  links = this.findUnresolvedLinks(document, stylesheet);
143
- i = 0;
144
- _b.label = 1;
146
+ resolvedLinks = [];
147
+ _i = 0, links_1 = links;
148
+ _a.label = 1;
145
149
  case 1:
146
- if (!(i < links.length)) return [3 /*break*/, 4];
147
- target = links[i].target;
150
+ if (!(_i < links_1.length)) return [3 /*break*/, 5];
151
+ link = links_1[_i];
152
+ target = link.target;
148
153
  if (!(target && !(/^\w+:\/\//g.test(target)))) return [3 /*break*/, 3];
149
- _a = links[i];
150
154
  return [4 /*yield*/, this.resolveRelativeReference(target, document.uri, documentContext)];
151
155
  case 2:
152
- _a.target = _b.sent();
153
- _b.label = 3;
156
+ resolvedTarget = _a.sent();
157
+ if (resolvedTarget !== undefined) {
158
+ link.target = resolvedTarget;
159
+ resolvedLinks.push(link);
160
+ }
161
+ return [3 /*break*/, 4];
154
162
  case 3:
155
- i++;
163
+ resolvedLinks.push(link);
164
+ _a.label = 4;
165
+ case 4:
166
+ _i++;
156
167
  return [3 /*break*/, 1];
157
- case 4: return [2 /*return*/, links];
168
+ case 5: return [2 /*return*/, resolvedLinks];
158
169
  }
159
170
  });
160
171
  });
@@ -71,9 +71,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
71
71
  switch (_f.label) {
72
72
  case 0:
73
73
  result = { items: [], isIncomplete: false };
74
- if (!(strings_1.startsWith(document.uri, 'file:'))) {
75
- return [2 /*return*/, result];
76
- }
77
74
  _i = 0, _a = this.literalCompletions;
78
75
  _f.label = 1;
79
76
  case 1:
@@ -150,6 +147,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
150
147
  replaceRange = pathToReplaceRange(valueBeforeCursor, fullValue, fullValueRange);
151
148
  valueBeforeLastSlash = valueBeforeCursor.substring(0, valueBeforeCursor.lastIndexOf('/') + 1);
152
149
  parentDir = documentContext.resolveReference(valueBeforeLastSlash || '.', currentDocUri);
150
+ if (!parentDir) return [3 /*break*/, 4];
153
151
  _b.label = 1;
154
152
  case 1:
155
153
  _b.trys.push([1, 3, , 4]);
@@ -167,8 +165,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
167
165
  return [2 /*return*/, result];
168
166
  case 3:
169
167
  e_1 = _b.sent();
170
- return [2 /*return*/, []];
171
- case 4: return [2 /*return*/];
168
+ return [3 /*break*/, 4];
169
+ case 4: return [2 /*return*/, []];
172
170
  }
173
171
  });
174
172
  });
@@ -11,17 +11,6 @@ var __extends = (this && this.__extends) || (function () {
11
11
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
12
  };
13
13
  })();
14
- var __assign = (this && this.__assign) || function () {
15
- __assign = Object.assign || function(t) {
16
- for (var s, i = 1, n = arguments.length; i < n; i++) {
17
- s = arguments[i];
18
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
- t[p] = s[p];
20
- }
21
- return t;
22
- };
23
- return __assign.apply(this, arguments);
24
- };
25
14
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
15
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
16
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -64,7 +53,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
64
53
  if (v !== undefined) module.exports = v;
65
54
  }
66
55
  else if (typeof define === "function" && define.amd) {
67
- define(["require", "exports", "./cssNavigation", "../parser/cssNodes", "vscode-uri"], factory);
56
+ define(["require", "exports", "./cssNavigation", "../parser/cssNodes", "vscode-uri", "../utils/strings", "../utils/resources"], factory);
68
57
  }
69
58
  })(function (require, exports) {
70
59
  /*---------------------------------------------------------------------------------------------
@@ -76,6 +65,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
76
65
  var cssNavigation_1 = require("./cssNavigation");
77
66
  var nodes = require("../parser/cssNodes");
78
67
  var vscode_uri_1 = require("vscode-uri");
68
+ var strings_1 = require("../utils/strings");
69
+ var resources_1 = require("../utils/resources");
79
70
  var SCSSNavigation = /** @class */ (function (_super) {
80
71
  __extends(SCSSNavigation, _super);
81
72
  function SCSSNavigation(fileSystemProvider) {
@@ -86,7 +77,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
86
77
  node.type === nodes.NodeType.Use ||
87
78
  node.type === nodes.NodeType.Forward);
88
79
  };
89
- SCSSNavigation.prototype.findDocumentLinks2 = function (document, stylesheet, documentContext) {
80
+ SCSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext) {
90
81
  return __awaiter(this, void 0, void 0, function () {
91
82
  function toPathVariations(uri) {
92
83
  // No valid path
@@ -128,63 +119,41 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
128
119
  var cssPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '.css');
129
120
  return [normalizedPath, underScorePath, indexPath, indexUnderscoreUri, cssPath];
130
121
  }
131
- var links, fsProvider, validLinks, i, target, parsedUri, pathVariations, j;
122
+ var target, parsedUri, pathVariations, j, e_1;
132
123
  return __generator(this, function (_a) {
133
124
  switch (_a.label) {
134
125
  case 0:
135
- links = this.findDocumentLinks(document, stylesheet, documentContext);
136
- fsProvider = this.fileSystemProvider;
137
- validLinks = [];
138
- if (!fsProvider) return [3 /*break*/, 9];
139
- i = 0;
140
- _a.label = 1;
141
- case 1:
142
- if (!(i < links.length)) return [3 /*break*/, 8];
143
- target = links[i].target;
144
- if (!target) {
145
- return [3 /*break*/, 7];
146
- }
147
- parsedUri = null;
148
- try {
149
- parsedUri = vscode_uri_1.URI.parse(target);
126
+ if (strings_1.startsWith(ref, 'sass:')) {
127
+ return [2 /*return*/, undefined]; // sass library
150
128
  }
151
- catch (e) {
152
- if (e instanceof URIError) {
153
- return [3 /*break*/, 7];
154
- }
155
- throw e;
156
- }
157
- pathVariations = toPathVariations(parsedUri);
158
- if (!!pathVariations) return [3 /*break*/, 3];
159
- return [4 /*yield*/, this.fileExists(target)];
129
+ return [4 /*yield*/, _super.prototype.resolveRelativeReference.call(this, ref, documentUri, documentContext)];
130
+ case 1:
131
+ target = _a.sent();
132
+ if (!(this.fileSystemProvider && target && resources_1.extname(target).length === 0)) return [3 /*break*/, 8];
133
+ _a.label = 2;
160
134
  case 2:
161
- if (_a.sent()) {
162
- validLinks.push(links[i]);
163
- }
164
- return [3 /*break*/, 7];
165
- case 3:
135
+ _a.trys.push([2, 7, , 8]);
136
+ parsedUri = vscode_uri_1.URI.parse(target);
137
+ pathVariations = toPathVariations(parsedUri);
138
+ if (!pathVariations) return [3 /*break*/, 6];
166
139
  j = 0;
167
- _a.label = 4;
168
- case 4:
169
- if (!(j < pathVariations.length)) return [3 /*break*/, 7];
140
+ _a.label = 3;
141
+ case 3:
142
+ if (!(j < pathVariations.length)) return [3 /*break*/, 6];
170
143
  return [4 /*yield*/, this.fileExists(pathVariations[j])];
171
- case 5:
144
+ case 4:
172
145
  if (_a.sent()) {
173
- validLinks.push(__assign(__assign({}, links[i]), { target: pathVariations[j] }));
174
- return [3 /*break*/, 7];
146
+ return [2 /*return*/, pathVariations[j]];
175
147
  }
176
- _a.label = 6;
177
- case 6:
148
+ _a.label = 5;
149
+ case 5:
178
150
  j++;
179
- return [3 /*break*/, 4];
151
+ return [3 /*break*/, 3];
152
+ case 6: return [2 /*return*/, undefined];
180
153
  case 7:
181
- i++;
182
- return [3 /*break*/, 1];
183
- case 8: return [3 /*break*/, 10];
184
- case 9:
185
- validLinks.push.apply(validLinks, links);
186
- _a.label = 10;
187
- case 10: return [2 /*return*/, validLinks];
154
+ e_1 = _a.sent();
155
+ return [3 /*break*/, 8];
156
+ case 8: return [2 /*return*/, target];
188
157
  }
189
158
  });
190
159
  });
@@ -8,14 +8,14 @@
8
8
  if (v !== undefined) module.exports = v;
9
9
  }
10
10
  else if (typeof define === "function" && define.amd) {
11
- define(["require", "exports", "vscode-uri", "./strings"], factory);
11
+ define(["require", "exports", "vscode-uri"], factory);
12
12
  }
13
13
  })(function (require, exports) {
14
14
  "use strict";
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  var vscode_uri_1 = require("vscode-uri");
17
- var strings_1 = require("./strings");
18
17
  var Slash = '/'.charCodeAt(0);
18
+ var Dot = '.'.charCodeAt(0);
19
19
  function isAbsolutePath(path) {
20
20
  return path.charCodeAt(0) === Slash;
21
21
  }
@@ -30,29 +30,69 @@
30
30
  return uri.substr(lastIndexOfSlash + 1);
31
31
  }
32
32
  exports.basename = basename;
33
+ function extname(uri) {
34
+ for (var i = uri.length - 1; i >= 0; i--) {
35
+ var ch = uri.charCodeAt(i);
36
+ if (ch === Dot) {
37
+ if (i > 0 && uri.charCodeAt(i - 1) !== Slash) {
38
+ return uri.substr(i);
39
+ }
40
+ else {
41
+ break;
42
+ }
43
+ }
44
+ else if (ch === Slash) {
45
+ break;
46
+ }
47
+ }
48
+ return '';
49
+ }
50
+ exports.extname = extname;
51
+ function resolvePath(uriString, path) {
52
+ if (isAbsolutePath(path)) {
53
+ var uri = vscode_uri_1.URI.parse(uriString);
54
+ var parts = path.split('/');
55
+ return uri.with({ path: normalizePath(parts) }).toString();
56
+ }
57
+ return joinPath(uriString, path);
58
+ }
59
+ exports.resolvePath = resolvePath;
60
+ function normalizePath(parts) {
61
+ var newParts = [];
62
+ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
63
+ var part = parts_1[_i];
64
+ if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) {
65
+ // ignore
66
+ }
67
+ else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) {
68
+ newParts.pop();
69
+ }
70
+ else {
71
+ newParts.push(part);
72
+ }
73
+ }
74
+ if (parts.length > 1 && parts[parts.length - 1].length === 0) {
75
+ newParts.push('');
76
+ }
77
+ var res = newParts.join('/');
78
+ if (parts[0].length === 0) {
79
+ res = '/' + res;
80
+ }
81
+ return res;
82
+ }
83
+ exports.normalizePath = normalizePath;
33
84
  function joinPath(uriString) {
34
85
  var paths = [];
35
86
  for (var _i = 1; _i < arguments.length; _i++) {
36
87
  paths[_i - 1] = arguments[_i];
37
88
  }
38
89
  var uri = vscode_uri_1.URI.parse(uriString);
39
- var uriPath = uri.path;
90
+ var parts = uri.path.split('/');
40
91
  for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
41
92
  var path = paths_1[_a];
42
- if (!strings_1.endsWith(uriPath, '/') && !strings_1.startsWith(path, '/')) {
43
- uriPath += '/';
44
- }
45
- uriPath += path;
93
+ parts.push.apply(parts, path.split('/'));
46
94
  }
47
- return uri.with({ path: uriPath }).toString();
95
+ return uri.with({ path: normalizePath(parts) }).toString();
48
96
  }
49
97
  exports.joinPath = joinPath;
50
- function resolvePath(uriString, path) {
51
- if (isAbsolutePath(path)) {
52
- var uri = vscode_uri_1.URI.parse(uriString);
53
- return uri.with({ path: path }).toString();
54
- }
55
- return joinPath(uriString, path);
56
- }
57
- exports.resolvePath = resolvePath;
58
98
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-css-languageservice",
3
- "version": "4.3.0-next.0",
3
+ "version": "4.3.0",
4
4
  "description": "Language service for CSS, LESS and SCSS",
5
5
  "main": "./lib/umd/cssLanguageService.js",
6
6
  "typings": "./lib/umd/cssLanguageService",
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "vscode-languageserver-textdocument": "^1.0.1",
32
- "vscode-languageserver-types": "^3.15.1",
32
+ "vscode-languageserver-types": "3.16.0-next.2",
33
33
  "vscode-nls": "^4.1.2",
34
- "vscode-uri": "^2.1.1"
34
+ "vscode-uri": "^2.1.2"
35
35
  },
36
36
  "scripts": {
37
37
  "prepublishOnly": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs",