-
Notifications
You must be signed in to change notification settings - Fork 29.3k
/
api.ts
36 lines (31 loc) · 1.09 KB
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*---------------------------------------------------------------------------------------------
* 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';
import { PluginManager } from './tsServer/plugins';
class ApiV0 {
public constructor(
public readonly onCompletionAccepted: vscode.Event<vscode.CompletionItem & { metadata?: any }>,
private readonly _pluginManager: PluginManager,
) { }
configurePlugin(pluginId: string, configuration: {}): void {
this._pluginManager.setConfiguration(pluginId, configuration);
}
}
export interface Api {
getAPI(version: 0): ApiV0 | undefined;
}
export function getExtensionApi(
onCompletionAccepted: vscode.Event<vscode.CompletionItem>,
pluginManager: PluginManager,
): Api {
return {
getAPI(version) {
if (version === 0) {
return new ApiV0(onCompletionAccepted, pluginManager);
}
return undefined;
}
};
}