vscode-css-languageservice
Advanced tools
Comparing version 4.3.0-next.2 to 4.3.0-next.3
@@ -1,28 +0,30 @@ | ||
4.3.0 - 2020-05-25 | ||
4.3.0 - | ||
=================== | ||
- module resolving in urls (`~foo/hello.html`) when using `LanguageService.findDocumentLinks2` and if `fileSystemProvider` is provided. | ||
- new API `LanguageService.doComplete2`. Support path completion if `fileSystemProvider.readDirectory` is provided. | ||
* module resolving in urls (`~foo/hello.html`) when using `LanguageService.findDocumentLinks2` and if `fileSystemProvider` is provided. | ||
* new API `LanguageService.doComplete2`. Support path completion if `fileSystemProvider.readDirectory` is provided. | ||
* `DocumentContext.resolveReference` can also return undefined (if the ref is invalid) | ||
4.2.0 - 2020-05-14 | ||
=================== | ||
* new API `LanguageServiceOptions.useDefaultDataProvider` to control whether the default data provider is used. Defaults to true | ||
* new API `LanguageService.setDataProviders` to update the data providers. | ||
* new API `LanguageServiceOptions.useDefaultDataProvider` to control whether the default data provider is used. Defaults to true | ||
* new API `LanguageService.setDataProviders` to update the data providers. | ||
4.1.0 - 2020-02-23 | ||
=================== | ||
* markdown descriptions in completions and hover | ||
* new API `LanguageServiceOptions.clientCapabilities` with `ClientCapabilities` for completion documentationFormat and hover content | ||
* extended format of CustomData (version 1.1) with MarkupContent contents and reference links | ||
* dynamically resolved links for scss include statements | ||
* new API `LanguageService.findDocumentLinks2`: Also returns dynamically resolved links if `fileSystemProvider` is provided | ||
* new API `LanguageServiceOptions.fileSystemProvider` with `FileSystemProvider` to query the file system (currently used to resolve the location of included files) | ||
* new API `CompletionSettings.completePropertyWithSemicolon` | ||
* new API `ICompletionParticipant.onCssMixinReference` | ||
* Switch to `TextDocument` from `vscode-languageserver-textdocument` (reexported from the main module) | ||
* markdown descriptions in completions and hover | ||
* new API `LanguageServiceOptions.clientCapabilities` with `ClientCapabilities` for completion documentationFormat and hover content | ||
* extended format of CustomData (version 1.1) with MarkupContent contents and reference links | ||
* dynamically resolved links for scss include statements | ||
* new API `LanguageService.findDocumentLinks2`: Also returns dynamically resolved links if `fileSystemProvider` is provided | ||
* new API `LanguageServiceOptions.fileSystemProvider` with `FileSystemProvider` to query the file system (currently used to resolve the location of included files) | ||
* new API `CompletionSettings.completePropertyWithSemicolon` | ||
* new API `ICompletionParticipant.onCssMixinReference` | ||
* Switch to `TextDocument` from `vscode-languageserver-textdocument` (reexported from the main module) | ||
4.0.0 / 2019-06-12 | ||
=================== | ||
* `LanguageServiceOptions.customDataProviders` allows you to use custom datasets for properties, at-properties, pseudo-classes and pseudo-elements. | ||
* New API `LanguageService.getSelectionRanges` | ||
* `LanguageServiceOptions.customDataProviders` allows you to use custom datasets for properties, at-properties, pseudo-classes and pseudo-elements. | ||
* New API `LanguageService.getSelectionRanges` | ||
@@ -29,0 +31,0 @@ 3.0.12 / 2018-10-29 |
@@ -6,2 +6,7 @@ # Custom Data for CSS Language Service | ||
1. With setting `css.customData` | ||
```json | ||
"css.customData": [ | ||
"./foo.css-data.json" | ||
] | ||
``` | ||
2. With an extension that contributes `contributes.css.customData` | ||
@@ -41,2 +46,3 @@ | ||
{ | ||
"version": 1.1, | ||
"properties": [ | ||
@@ -43,0 +49,0 @@ { "name": "foo", "description": "Foo property" } |
@@ -47,3 +47,3 @@ import { Range, Position, DocumentUri, MarkupContent, MarkupKind } from 'vscode-languageserver-types'; | ||
export interface DocumentContext { | ||
resolveReference(ref: string, base?: string): string; | ||
resolveReference(ref: string, baseUrl: string): string | undefined; | ||
} | ||
@@ -50,0 +50,0 @@ /** |
@@ -45,2 +45,5 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
export function textToMarkedString(text) { | ||
return text.replace(/[\\`*_{}[\]()#+\-.!<>]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash | ||
} | ||
function getEntryStringDescription(entry) { | ||
@@ -81,14 +84,10 @@ if (!entry.description || entry.description === '') { | ||
} | ||
if (typeof entry.description === 'string') { | ||
result += entry.description; | ||
} | ||
else { | ||
result = entry.description.value; | ||
} | ||
var description = typeof entry.description === 'string' ? entry.description : entry.description.value; | ||
result += textToMarkedString(description); | ||
var browserLabel = getBrowserLabel(entry.browsers); | ||
if (browserLabel) { | ||
result += '\n\n(' + browserLabel + ')'; | ||
result += '\n\n(' + textToMarkedString(browserLabel) + ')'; | ||
} | ||
if ('syntax' in entry) { | ||
result += "\n\nSyntax: " + entry.syntax; | ||
if ('syntax' in entry && entry.syntax) { | ||
result += "\n\nSyntax: " + textToMarkedString(entry.syntax); | ||
} | ||
@@ -95,0 +94,0 @@ if (entry.references && entry.references.length > 0) { |
@@ -121,3 +121,6 @@ /*--------------------------------------------------------------------------------------------- | ||
if (target && !(/^\w+:\/\//g.test(target))) { | ||
links[i].target = documentContext.resolveReference(target, document.uri); | ||
var resolved = documentContext.resolveReference(target, document.uri); | ||
if (resolved) { | ||
links[i].target = resolved; | ||
} | ||
} | ||
@@ -129,22 +132,30 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var links, i, target, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var links, resolvedLinks, _i, links_1, link, target, resolvedTarget; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
links = this.findUnresolvedLinks(document, stylesheet); | ||
i = 0; | ||
_b.label = 1; | ||
resolvedLinks = []; | ||
_i = 0, links_1 = links; | ||
_a.label = 1; | ||
case 1: | ||
if (!(i < links.length)) return [3 /*break*/, 4]; | ||
target = links[i].target; | ||
if (!(_i < links_1.length)) return [3 /*break*/, 5]; | ||
link = links_1[_i]; | ||
target = link.target; | ||
if (!(target && !(/^\w+:\/\//g.test(target)))) return [3 /*break*/, 3]; | ||
_a = links[i]; | ||
return [4 /*yield*/, this.resolveRelativeReference(target, document.uri, documentContext)]; | ||
case 2: | ||
_a.target = _b.sent(); | ||
_b.label = 3; | ||
resolvedTarget = _a.sent(); | ||
if (resolvedTarget !== undefined) { | ||
link.target = resolvedTarget; | ||
resolvedLinks.push(link); | ||
} | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
i++; | ||
resolvedLinks.push(link); | ||
_a.label = 4; | ||
case 4: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [2 /*return*/, links]; | ||
case 5: return [2 /*return*/, resolvedLinks]; | ||
} | ||
@@ -151,0 +162,0 @@ }); |
@@ -139,2 +139,3 @@ /*--------------------------------------------------------------------------------------------- | ||
parentDir = documentContext.resolveReference(valueBeforeLastSlash || '.', currentDocUri); | ||
if (!parentDir) return [3 /*break*/, 4]; | ||
_b.label = 1; | ||
@@ -157,4 +158,4 @@ case 1: | ||
e_1 = _b.sent(); | ||
return [2 /*return*/, []]; | ||
case 4: return [2 /*return*/]; | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/, []]; | ||
} | ||
@@ -161,0 +162,0 @@ }); |
@@ -19,13 +19,2 @@ /*--------------------------------------------------------------------------------------------- | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -70,2 +59,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
import { URI } from 'vscode-uri'; | ||
import { startsWith } from '../utils/strings'; | ||
import { extname } from '../utils/resources'; | ||
var SCSSNavigation = /** @class */ (function (_super) { | ||
@@ -81,3 +72,3 @@ __extends(SCSSNavigation, _super); | ||
}; | ||
SCSSNavigation.prototype.findDocumentLinks2 = function (document, stylesheet, documentContext) { | ||
SCSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -124,59 +115,37 @@ function toPathVariations(uri) { | ||
} | ||
var links, fsProvider, validLinks, i, target, parsedUri, pathVariations, j; | ||
var target, parsedUri, pathVariations, j, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
links = this.findDocumentLinks(document, stylesheet, documentContext); | ||
fsProvider = this.fileSystemProvider; | ||
validLinks = []; | ||
if (!fsProvider) return [3 /*break*/, 9]; | ||
i = 0; | ||
_a.label = 1; | ||
if (startsWith(ref, 'sass:')) { | ||
return [2 /*return*/, undefined]; // sass library | ||
} | ||
return [4 /*yield*/, _super.prototype.resolveRelativeReference.call(this, ref, documentUri, documentContext)]; | ||
case 1: | ||
if (!(i < links.length)) return [3 /*break*/, 8]; | ||
target = links[i].target; | ||
if (!target) { | ||
return [3 /*break*/, 7]; | ||
} | ||
parsedUri = null; | ||
try { | ||
parsedUri = URI.parse(target); | ||
} | ||
catch (e) { | ||
if (e instanceof URIError) { | ||
return [3 /*break*/, 7]; | ||
} | ||
throw e; | ||
} | ||
target = _a.sent(); | ||
if (!(this.fileSystemProvider && target && extname(target).length === 0)) return [3 /*break*/, 8]; | ||
_a.label = 2; | ||
case 2: | ||
_a.trys.push([2, 7, , 8]); | ||
parsedUri = URI.parse(target); | ||
pathVariations = toPathVariations(parsedUri); | ||
if (!!pathVariations) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, this.fileExists(target)]; | ||
case 2: | ||
if (_a.sent()) { | ||
validLinks.push(links[i]); | ||
} | ||
return [3 /*break*/, 7]; | ||
if (!pathVariations) return [3 /*break*/, 6]; | ||
j = 0; | ||
_a.label = 3; | ||
case 3: | ||
j = 0; | ||
_a.label = 4; | ||
if (!(j < pathVariations.length)) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, this.fileExists(pathVariations[j])]; | ||
case 4: | ||
if (!(j < pathVariations.length)) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, this.fileExists(pathVariations[j])]; | ||
case 5: | ||
if (_a.sent()) { | ||
validLinks.push(__assign(__assign({}, links[i]), { target: pathVariations[j] })); | ||
return [3 /*break*/, 7]; | ||
return [2 /*return*/, pathVariations[j]]; | ||
} | ||
_a.label = 6; | ||
case 6: | ||
_a.label = 5; | ||
case 5: | ||
j++; | ||
return [3 /*break*/, 4]; | ||
return [3 /*break*/, 3]; | ||
case 6: return [2 /*return*/, undefined]; | ||
case 7: | ||
i++; | ||
return [3 /*break*/, 1]; | ||
case 8: return [3 /*break*/, 10]; | ||
case 9: | ||
validLinks.push.apply(validLinks, links); | ||
_a.label = 10; | ||
case 10: return [2 /*return*/, validLinks]; | ||
e_1 = _a.sent(); | ||
return [3 /*break*/, 8]; | ||
case 8: return [2 /*return*/, target]; | ||
} | ||
@@ -183,0 +152,0 @@ }); |
@@ -6,4 +6,4 @@ /*--------------------------------------------------------------------------------------------- | ||
import { URI } from "vscode-uri"; | ||
import { endsWith, startsWith } from "./strings"; | ||
var Slash = '/'.charCodeAt(0); | ||
var Dot = '.'.charCodeAt(0); | ||
export function isAbsolutePath(path) { | ||
@@ -20,2 +20,50 @@ return path.charCodeAt(0) === Slash; | ||
} | ||
export function extname(uri) { | ||
for (var i = uri.length - 1; i >= 0; i--) { | ||
var ch = uri.charCodeAt(i); | ||
if (ch === Dot) { | ||
if (i > 0 && uri.charCodeAt(i - 1) !== Slash) { | ||
return uri.substr(i); | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
else if (ch === Slash) { | ||
break; | ||
} | ||
} | ||
return ''; | ||
} | ||
export function resolvePath(uriString, path) { | ||
if (isAbsolutePath(path)) { | ||
var uri = URI.parse(uriString); | ||
var parts = path.split('/'); | ||
return uri.with({ path: normalizePath(parts) }).toString(); | ||
} | ||
return joinPath(uriString, path); | ||
} | ||
export function normalizePath(parts) { | ||
var newParts = []; | ||
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
var part = parts_1[_i]; | ||
if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) { | ||
// ignore | ||
} | ||
else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) { | ||
newParts.pop(); | ||
} | ||
else { | ||
newParts.push(part); | ||
} | ||
} | ||
if (parts.length > 1 && parts[parts.length - 1].length === 0) { | ||
newParts.push(''); | ||
} | ||
var res = newParts.join('/'); | ||
if (parts[0].length === 0) { | ||
res = '/' + res; | ||
} | ||
return res; | ||
} | ||
export function joinPath(uriString) { | ||
@@ -27,18 +75,8 @@ var paths = []; | ||
var uri = URI.parse(uriString); | ||
var uriPath = uri.path; | ||
var parts = uri.path.split('/'); | ||
for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { | ||
var path = paths_1[_a]; | ||
if (!endsWith(uriPath, '/') && !startsWith(path, '/')) { | ||
uriPath += '/'; | ||
} | ||
uriPath += path; | ||
parts.push.apply(parts, path.split('/')); | ||
} | ||
return uri.with({ path: uriPath }).toString(); | ||
return uri.with({ path: normalizePath(parts) }).toString(); | ||
} | ||
export function resolvePath(uriString, path) { | ||
if (isAbsolutePath(path)) { | ||
var uri = URI.parse(uriString); | ||
return uri.with({ path: path }).toString(); | ||
} | ||
return joinPath(uriString, path); | ||
} |
@@ -47,3 +47,3 @@ import { Range, Position, DocumentUri, MarkupContent, MarkupKind } from 'vscode-languageserver-types'; | ||
export interface DocumentContext { | ||
resolveReference(ref: string, base?: string): string; | ||
resolveReference(ref: string, baseUrl: string): string | undefined; | ||
} | ||
@@ -50,0 +50,0 @@ /** |
@@ -56,2 +56,6 @@ (function (factory) { | ||
exports.getEntryDescription = getEntryDescription; | ||
function textToMarkedString(text) { | ||
return text.replace(/[\\`*_{}[\]()#+\-.!<>]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash | ||
} | ||
exports.textToMarkedString = textToMarkedString; | ||
function getEntryStringDescription(entry) { | ||
@@ -92,14 +96,10 @@ if (!entry.description || entry.description === '') { | ||
} | ||
if (typeof entry.description === 'string') { | ||
result += entry.description; | ||
} | ||
else { | ||
result = entry.description.value; | ||
} | ||
var description = typeof entry.description === 'string' ? entry.description : entry.description.value; | ||
result += textToMarkedString(description); | ||
var browserLabel = getBrowserLabel(entry.browsers); | ||
if (browserLabel) { | ||
result += '\n\n(' + browserLabel + ')'; | ||
result += '\n\n(' + textToMarkedString(browserLabel) + ')'; | ||
} | ||
if ('syntax' in entry) { | ||
result += "\n\nSyntax: " + entry.syntax; | ||
if ('syntax' in entry && entry.syntax) { | ||
result += "\n\nSyntax: " + textToMarkedString(entry.syntax); | ||
} | ||
@@ -106,0 +106,0 @@ if (entry.references && entry.references.length > 0) { |
@@ -131,3 +131,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (target && !(/^\w+:\/\//g.test(target))) { | ||
links[i].target = documentContext.resolveReference(target, document.uri); | ||
var resolved = documentContext.resolveReference(target, document.uri); | ||
if (resolved) { | ||
links[i].target = resolved; | ||
} | ||
} | ||
@@ -139,22 +142,30 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var links, i, target, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var links, resolvedLinks, _i, links_1, link, target, resolvedTarget; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
links = this.findUnresolvedLinks(document, stylesheet); | ||
i = 0; | ||
_b.label = 1; | ||
resolvedLinks = []; | ||
_i = 0, links_1 = links; | ||
_a.label = 1; | ||
case 1: | ||
if (!(i < links.length)) return [3 /*break*/, 4]; | ||
target = links[i].target; | ||
if (!(_i < links_1.length)) return [3 /*break*/, 5]; | ||
link = links_1[_i]; | ||
target = link.target; | ||
if (!(target && !(/^\w+:\/\//g.test(target)))) return [3 /*break*/, 3]; | ||
_a = links[i]; | ||
return [4 /*yield*/, this.resolveRelativeReference(target, document.uri, documentContext)]; | ||
case 2: | ||
_a.target = _b.sent(); | ||
_b.label = 3; | ||
resolvedTarget = _a.sent(); | ||
if (resolvedTarget !== undefined) { | ||
link.target = resolvedTarget; | ||
resolvedLinks.push(link); | ||
} | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
i++; | ||
resolvedLinks.push(link); | ||
_a.label = 4; | ||
case 4: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [2 /*return*/, links]; | ||
case 5: return [2 /*return*/, resolvedLinks]; | ||
} | ||
@@ -161,0 +172,0 @@ }); |
@@ -150,2 +150,3 @@ /*--------------------------------------------------------------------------------------------- | ||
parentDir = documentContext.resolveReference(valueBeforeLastSlash || '.', currentDocUri); | ||
if (!parentDir) return [3 /*break*/, 4]; | ||
_b.label = 1; | ||
@@ -168,4 +169,4 @@ case 1: | ||
e_1 = _b.sent(); | ||
return [2 /*return*/, []]; | ||
case 4: return [2 /*return*/]; | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/, []]; | ||
} | ||
@@ -172,0 +173,0 @@ }); |
@@ -14,13 +14,2 @@ var __extends = (this && this.__extends) || (function () { | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -68,3 +57,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./cssNavigation", "../parser/cssNodes", "vscode-uri"], factory); | ||
define(["require", "exports", "./cssNavigation", "../parser/cssNodes", "vscode-uri", "../utils/strings", "../utils/resources"], factory); | ||
} | ||
@@ -81,2 +70,4 @@ })(function (require, exports) { | ||
var vscode_uri_1 = require("vscode-uri"); | ||
var strings_1 = require("../utils/strings"); | ||
var resources_1 = require("../utils/resources"); | ||
var SCSSNavigation = /** @class */ (function (_super) { | ||
@@ -92,3 +83,3 @@ __extends(SCSSNavigation, _super); | ||
}; | ||
SCSSNavigation.prototype.findDocumentLinks2 = function (document, stylesheet, documentContext) { | ||
SCSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -135,59 +126,37 @@ function toPathVariations(uri) { | ||
} | ||
var links, fsProvider, validLinks, i, target, parsedUri, pathVariations, j; | ||
var target, parsedUri, pathVariations, j, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
links = this.findDocumentLinks(document, stylesheet, documentContext); | ||
fsProvider = this.fileSystemProvider; | ||
validLinks = []; | ||
if (!fsProvider) return [3 /*break*/, 9]; | ||
i = 0; | ||
_a.label = 1; | ||
if (strings_1.startsWith(ref, 'sass:')) { | ||
return [2 /*return*/, undefined]; // sass library | ||
} | ||
return [4 /*yield*/, _super.prototype.resolveRelativeReference.call(this, ref, documentUri, documentContext)]; | ||
case 1: | ||
if (!(i < links.length)) return [3 /*break*/, 8]; | ||
target = links[i].target; | ||
if (!target) { | ||
return [3 /*break*/, 7]; | ||
} | ||
parsedUri = null; | ||
try { | ||
parsedUri = vscode_uri_1.URI.parse(target); | ||
} | ||
catch (e) { | ||
if (e instanceof URIError) { | ||
return [3 /*break*/, 7]; | ||
} | ||
throw e; | ||
} | ||
target = _a.sent(); | ||
if (!(this.fileSystemProvider && target && resources_1.extname(target).length === 0)) return [3 /*break*/, 8]; | ||
_a.label = 2; | ||
case 2: | ||
_a.trys.push([2, 7, , 8]); | ||
parsedUri = vscode_uri_1.URI.parse(target); | ||
pathVariations = toPathVariations(parsedUri); | ||
if (!!pathVariations) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, this.fileExists(target)]; | ||
case 2: | ||
if (_a.sent()) { | ||
validLinks.push(links[i]); | ||
} | ||
return [3 /*break*/, 7]; | ||
if (!pathVariations) return [3 /*break*/, 6]; | ||
j = 0; | ||
_a.label = 3; | ||
case 3: | ||
j = 0; | ||
_a.label = 4; | ||
if (!(j < pathVariations.length)) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, this.fileExists(pathVariations[j])]; | ||
case 4: | ||
if (!(j < pathVariations.length)) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, this.fileExists(pathVariations[j])]; | ||
case 5: | ||
if (_a.sent()) { | ||
validLinks.push(__assign(__assign({}, links[i]), { target: pathVariations[j] })); | ||
return [3 /*break*/, 7]; | ||
return [2 /*return*/, pathVariations[j]]; | ||
} | ||
_a.label = 6; | ||
case 6: | ||
_a.label = 5; | ||
case 5: | ||
j++; | ||
return [3 /*break*/, 4]; | ||
return [3 /*break*/, 3]; | ||
case 6: return [2 /*return*/, undefined]; | ||
case 7: | ||
i++; | ||
return [3 /*break*/, 1]; | ||
case 8: return [3 /*break*/, 10]; | ||
case 9: | ||
validLinks.push.apply(validLinks, links); | ||
_a.label = 10; | ||
case 10: return [2 /*return*/, validLinks]; | ||
e_1 = _a.sent(); | ||
return [3 /*break*/, 8]; | ||
case 8: return [2 /*return*/, target]; | ||
} | ||
@@ -194,0 +163,0 @@ }); |
@@ -11,3 +11,3 @@ /*--------------------------------------------------------------------------------------------- | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "vscode-uri", "./strings"], factory); | ||
define(["require", "exports", "vscode-uri"], factory); | ||
} | ||
@@ -18,4 +18,4 @@ })(function (require, exports) { | ||
var vscode_uri_1 = require("vscode-uri"); | ||
var strings_1 = require("./strings"); | ||
var Slash = '/'.charCodeAt(0); | ||
var Dot = '.'.charCodeAt(0); | ||
function isAbsolutePath(path) { | ||
@@ -35,2 +35,53 @@ return path.charCodeAt(0) === Slash; | ||
exports.basename = basename; | ||
function extname(uri) { | ||
for (var i = uri.length - 1; i >= 0; i--) { | ||
var ch = uri.charCodeAt(i); | ||
if (ch === Dot) { | ||
if (i > 0 && uri.charCodeAt(i - 1) !== Slash) { | ||
return uri.substr(i); | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
else if (ch === Slash) { | ||
break; | ||
} | ||
} | ||
return ''; | ||
} | ||
exports.extname = extname; | ||
function resolvePath(uriString, path) { | ||
if (isAbsolutePath(path)) { | ||
var uri = vscode_uri_1.URI.parse(uriString); | ||
var parts = path.split('/'); | ||
return uri.with({ path: normalizePath(parts) }).toString(); | ||
} | ||
return joinPath(uriString, path); | ||
} | ||
exports.resolvePath = resolvePath; | ||
function normalizePath(parts) { | ||
var newParts = []; | ||
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
var part = parts_1[_i]; | ||
if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) { | ||
// ignore | ||
} | ||
else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) { | ||
newParts.pop(); | ||
} | ||
else { | ||
newParts.push(part); | ||
} | ||
} | ||
if (parts.length > 1 && parts[parts.length - 1].length === 0) { | ||
newParts.push(''); | ||
} | ||
var res = newParts.join('/'); | ||
if (parts[0].length === 0) { | ||
res = '/' + res; | ||
} | ||
return res; | ||
} | ||
exports.normalizePath = normalizePath; | ||
function joinPath(uriString) { | ||
@@ -42,21 +93,10 @@ var paths = []; | ||
var uri = vscode_uri_1.URI.parse(uriString); | ||
var uriPath = uri.path; | ||
var parts = uri.path.split('/'); | ||
for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { | ||
var path = paths_1[_a]; | ||
if (!strings_1.endsWith(uriPath, '/') && !strings_1.startsWith(path, '/')) { | ||
uriPath += '/'; | ||
} | ||
uriPath += path; | ||
parts.push.apply(parts, path.split('/')); | ||
} | ||
return uri.with({ path: uriPath }).toString(); | ||
return uri.with({ path: normalizePath(parts) }).toString(); | ||
} | ||
exports.joinPath = joinPath; | ||
function resolvePath(uriString, path) { | ||
if (isAbsolutePath(path)) { | ||
var uri = vscode_uri_1.URI.parse(uriString); | ||
return uri.with({ path: path }).toString(); | ||
} | ||
return joinPath(uriString, path); | ||
} | ||
exports.resolvePath = resolvePath; | ||
}); |
{ | ||
"name": "vscode-css-languageservice", | ||
"version": "4.3.0-next.2", | ||
"version": "4.3.0-next.3", | ||
"description": "Language service for CSS, LESS and SCSS", | ||
@@ -5,0 +5,0 @@ "main": "./lib/umd/cssLanguageService.js", |
2835535
66466