mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:04:14 +08:00
* New drop and paste providers that create a url function snippet * added url pasting feature * added url pasting feature * added url pasting feature * Target just dropping/pasting resources for now * Move files * Remove unused strings * Removing more unused logic for now * Remove tsconfig change * Remove doc file * Capitalize * Remove old proposal names --------- Co-authored-by: Meghan Kulkarni <kulkarni.meg@gmail.com> Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { ExtensionContext, Uri, l10n } from 'vscode';
|
|
import { BaseLanguageClient, LanguageClientOptions } from 'vscode-languageclient';
|
|
import { startClient, LanguageClientConstructor } from '../cssClient';
|
|
import { LanguageClient } from 'vscode-languageclient/browser';
|
|
import { registerDropOrPasteResourceSupport } from '../dropOrPaste/dropOrPasteResource';
|
|
|
|
let client: BaseLanguageClient | undefined;
|
|
|
|
// this method is called when vs code is activated
|
|
export async function activate(context: ExtensionContext) {
|
|
const serverMain = Uri.joinPath(context.extensionUri, 'server/dist/browser/cssServerMain.js');
|
|
try {
|
|
const worker = new Worker(serverMain.toString());
|
|
worker.postMessage({ i10lLocation: l10n.uri?.toString(false) ?? '' });
|
|
|
|
const newLanguageClient: LanguageClientConstructor = (id: string, name: string, clientOptions: LanguageClientOptions) => {
|
|
return new LanguageClient(id, name, worker, clientOptions);
|
|
};
|
|
|
|
client = await startClient(context, newLanguageClient, { TextDecoder });
|
|
|
|
context.subscriptions.push(registerDropOrPasteResourceSupport({ language: 'css', scheme: '*' }));
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
}
|
|
|
|
export async function deactivate(): Promise<void> {
|
|
if (client) {
|
|
await client.stop();
|
|
client = undefined;
|
|
}
|
|
}
|
|
|