|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import * as vscode from 'vscode'; |
| 7 | +import { noopLogDirectoryProvider } from './tsServer/logDirectoryProvider'; |
| 8 | +import { Api, getExtensionApi } from './api'; |
| 9 | +import { registerCommands } from './commands/index'; |
| 10 | +import { LanguageConfigurationManager } from './features/languageConfiguration'; |
| 11 | +import { createLazyClientHost, lazilyActivateClient } from './lazyClientHost'; |
| 12 | +import { CommandManager } from './utils/commandManager'; |
| 13 | +import { PluginManager } from './utils/plugins'; |
| 14 | +import { noopRequestCanceller } from './tsServer/cancellation'; |
| 15 | + |
| 16 | +export function activate( |
| 17 | + context: vscode.ExtensionContext |
| 18 | +): Api { |
| 19 | + const pluginManager = new PluginManager(); |
| 20 | + context.subscriptions.push(pluginManager); |
| 21 | + |
| 22 | + const commandManager = new CommandManager(); |
| 23 | + context.subscriptions.push(commandManager); |
| 24 | + |
| 25 | + const onCompletionAccepted = new vscode.EventEmitter<vscode.CompletionItem>(); |
| 26 | + context.subscriptions.push(onCompletionAccepted); |
| 27 | + |
| 28 | + const lazyClientHost = createLazyClientHost(context, pluginManager, commandManager, noopLogDirectoryProvider, { |
| 29 | + create: () => noopRequestCanceller |
| 30 | + |
| 31 | + }, item => { |
| 32 | + onCompletionAccepted.fire(item); |
| 33 | + }); |
| 34 | + |
| 35 | + registerCommands(commandManager, lazyClientHost, pluginManager); |
| 36 | + // context.subscriptions.push(task.register(lazyClientHost.map(x => x.serviceClient))); |
| 37 | + context.subscriptions.push(new LanguageConfigurationManager()); |
| 38 | + |
| 39 | + import('./features/tsconfig').then(module => { |
| 40 | + context.subscriptions.push(module.register()); |
| 41 | + }); |
| 42 | + |
| 43 | + context.subscriptions.push(lazilyActivateClient(lazyClientHost, pluginManager)); |
| 44 | + |
| 45 | + return getExtensionApi(onCompletionAccepted.event, pluginManager); |
| 46 | +} |
| 47 | + |
0 commit comments