mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Extract api to own file
This commit is contained in:
29
extensions/typescript-language-features/src/api.ts
Normal file
29
extensions/typescript-language-features/src/api.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
interface ApiV0 {
|
||||
readonly onCompletionAccepted: vscode.Event<vscode.CompletionItem>;
|
||||
}
|
||||
|
||||
export interface Api {
|
||||
getAPI(version: 0): ApiV0 | undefined;
|
||||
}
|
||||
|
||||
export function getExtensionApi(
|
||||
onCompletionAccepted: vscode.Event<vscode.CompletionItem>
|
||||
): Api {
|
||||
return {
|
||||
getAPI(version) {
|
||||
if (version === 0) {
|
||||
return {
|
||||
onCompletionAccepted: onCompletionAccepted
|
||||
} as ApiV0;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { Api, getExtensionApi } from './api';
|
||||
import { registerCommands } from './commands/index';
|
||||
import { LanguageConfigurationManager } from './features/languageConfiguration';
|
||||
import TypeScriptTaskProviderManager from './features/task';
|
||||
@@ -19,17 +20,6 @@ import { PluginManager } from './utils/plugins';
|
||||
import * as ProjectStatus from './utils/projectStatus';
|
||||
import { Surveyor } from './utils/surveyor';
|
||||
|
||||
|
||||
interface ApiV0 {
|
||||
readonly onCompletionAccepted: vscode.Event<vscode.CompletionItem>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
interface Api {
|
||||
getAPI(version: 0): ApiV0 | undefined;
|
||||
}
|
||||
|
||||
export function activate(
|
||||
context: vscode.ExtensionContext
|
||||
): Api {
|
||||
@@ -38,7 +28,7 @@ export function activate(
|
||||
const commandManager = new CommandManager();
|
||||
context.subscriptions.push(commandManager);
|
||||
|
||||
const onCompletionAccepted = new vscode.EventEmitter();
|
||||
const onCompletionAccepted = new vscode.EventEmitter<vscode.CompletionItem>();
|
||||
context.subscriptions.push(onCompletionAccepted);
|
||||
|
||||
const lazyClientHost = createLazyClientHost(context, pluginManager, commandManager, item => {
|
||||
@@ -78,16 +68,7 @@ export function activate(
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
getAPI(version) {
|
||||
if (version === 0) {
|
||||
return {
|
||||
onCompletionAccepted: onCompletionAccepted.event
|
||||
} as ApiV0;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
} as Api;
|
||||
return getExtensionApi(onCompletionAccepted.event);
|
||||
}
|
||||
|
||||
function createLazyClientHost(
|
||||
|
||||
Reference in New Issue
Block a user