mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
contributes.css.customData for #66414
This commit is contained in:
@@ -11,7 +11,7 @@ const localize = nls.loadMessageBundle();
|
|||||||
|
|
||||||
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString, workspace } from 'vscode';
|
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString, workspace } from 'vscode';
|
||||||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Disposable } from 'vscode-languageclient';
|
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Disposable } from 'vscode-languageclient';
|
||||||
import { getCustomDataPathsInAllWorkspaces } from './customData';
|
import { getCustomDataPathsInAllWorkspaces, getCustomDataPathsFromAllExtensions } from './customData';
|
||||||
|
|
||||||
// this method is called when vs code is activated
|
// this method is called when vs code is activated
|
||||||
export function activate(context: ExtensionContext) {
|
export function activate(context: ExtensionContext) {
|
||||||
@@ -31,7 +31,10 @@ export function activate(context: ExtensionContext) {
|
|||||||
|
|
||||||
let documentSelector = ['css', 'scss', 'less'];
|
let documentSelector = ['css', 'scss', 'less'];
|
||||||
|
|
||||||
let dataPaths = getCustomDataPathsInAllWorkspaces(workspace.workspaceFolders);
|
let dataPaths = [
|
||||||
|
...getCustomDataPathsInAllWorkspaces(workspace.workspaceFolders),
|
||||||
|
...getCustomDataPathsFromAllExtensions()
|
||||||
|
];
|
||||||
|
|
||||||
// Options to control the language client
|
// Options to control the language client
|
||||||
let clientOptions: LanguageClientOptions = {
|
let clientOptions: LanguageClientOptions = {
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { workspace, WorkspaceFolder } from 'vscode';
|
import { workspace, WorkspaceFolder, extensions } from 'vscode';
|
||||||
|
|
||||||
interface ExperimentalConfig {
|
interface ExperimentalConfig {
|
||||||
experimental?: {
|
experimental?: {
|
||||||
customData?: string[]
|
customData?: string[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,6 @@ export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFol
|
|||||||
wfCSSConfig.workspaceFolderValue.experimental &&
|
wfCSSConfig.workspaceFolderValue.experimental &&
|
||||||
wfCSSConfig.workspaceFolderValue.experimental.customData
|
wfCSSConfig.workspaceFolderValue.experimental.customData
|
||||||
) {
|
) {
|
||||||
|
|
||||||
wfCSSConfig.workspaceFolderValue.experimental.customData.forEach(p => [
|
wfCSSConfig.workspaceFolderValue.experimental.customData.forEach(p => [
|
||||||
dataPaths.push(path.resolve(wf.uri.fsPath, p))
|
dataPaths.push(path.resolve(wf.uri.fsPath, p))
|
||||||
]);
|
]);
|
||||||
@@ -37,3 +36,20 @@ export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFol
|
|||||||
|
|
||||||
return dataPaths;
|
return dataPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCustomDataPathsFromAllExtensions(): string[] {
|
||||||
|
const dataPaths: string[] = [];
|
||||||
|
|
||||||
|
for (const extension of extensions.all) {
|
||||||
|
const contributes = extension.packageJSON && extension.packageJSON.contributes;
|
||||||
|
|
||||||
|
if (contributes && contributes.css && contributes.css.customData && Array.isArray(contributes.css.customData)) {
|
||||||
|
const relativePaths: string[] = contributes.css.customData;
|
||||||
|
relativePaths.forEach(rp => {
|
||||||
|
dataPaths.push(path.resolve(extension.extensionPath, rp));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataPaths;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user