volar-service-css
Advanced tools
Comparing version 0.0.52 to 0.0.53
import type { Disposable, DocumentSelector, FormattingOptions, ProviderResult, LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service'; | ||
import * as css from 'vscode-css-languageservice'; | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
import { URI } from 'vscode-uri'; | ||
export interface Provide { | ||
@@ -8,2 +9,3 @@ 'css/stylesheet': (document: TextDocument, ls: css.LanguageService) => css.Stylesheet; | ||
} | ||
export declare function resolveReference(ref: string, baseUri: URI, workspaceFolders: URI[]): string; | ||
export declare function create({ cssDocumentSelector, scssDocumentSelector, lessDocumentSelector, useDefaultDataProvider, getDocumentContext, isFormattingEnabled, getFormattingOptions, getLanguageSettings, getCustomData, onDidChangeCustomData, }?: { | ||
@@ -10,0 +12,0 @@ cssDocumentSelector?: DocumentSelector; |
40
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveReference = resolveReference; | ||
exports.create = create; | ||
@@ -7,2 +8,27 @@ const css = require("vscode-css-languageservice"); | ||
const vscode_uri_1 = require("vscode-uri"); | ||
function resolveReference(ref, baseUri, workspaceFolders) { | ||
if (ref.match(/^\w[\w\d+.-]*:/)) { | ||
// starts with a schema | ||
return ref; | ||
} | ||
if (ref[0] === '/') { // resolve absolute path against the current workspace folder | ||
const folderUri = getRootFolder(); | ||
if (folderUri) { | ||
return folderUri + ref.substr(1); | ||
} | ||
} | ||
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : vscode_uri_1.Utils.dirname(baseUri); | ||
return vscode_uri_1.Utils.resolvePath(baseUriDir, ref).toString(true); | ||
function getRootFolder() { | ||
for (const folder of workspaceFolders) { | ||
let folderURI = folder.toString(); | ||
if (!folderURI.endsWith('/')) { | ||
folderURI = folderURI + '/'; | ||
} | ||
if (baseUri.toString().startsWith(folderURI)) { | ||
return folderURI; | ||
} | ||
} | ||
} | ||
} | ||
function create({ cssDocumentSelector = ['css'], scssDocumentSelector = ['scss'], lessDocumentSelector = ['less'], useDefaultDataProvider = true, getDocumentContext = context => { | ||
@@ -16,15 +42,3 @@ return { | ||
} | ||
if (ref.match(/^\w[\w\d+.-]*:/)) { | ||
// starts with a schema | ||
return ref; | ||
} | ||
if (ref[0] === '/' && context.env.workspaceFolders.length) { // resolve absolute path against the current workspace folder | ||
let folderUri = context.env.workspaceFolders[0].toString(); | ||
if (!folderUri.endsWith('/')) { | ||
folderUri += '/'; | ||
} | ||
return folderUri + ref.substring(1); | ||
} | ||
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : vscode_uri_1.Utils.dirname(baseUri); | ||
return vscode_uri_1.Utils.resolvePath(baseUriDir, ref).toString(true); | ||
return resolveReference(ref, baseUri, context.env.workspaceFolders); | ||
}, | ||
@@ -31,0 +45,0 @@ }; |
{ | ||
"name": "volar-service-css", | ||
"version": "0.0.52", | ||
"version": "0.0.53", | ||
"description": "Integrate vscode-css-languageservice into Volar", | ||
@@ -42,3 +42,3 @@ "homepage": "https://github.com/volarjs/services/tree/master/packages/css", | ||
}, | ||
"gitHead": "0038413c252e98b7d6b4e57eabdcb337d272d771" | ||
"gitHead": "8c61d6a8acc354e68c726727f72be7d318c583da" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22571
392