File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1+ import { BaseLanguageClient } from 'vscode-languageclient' ;
2+
3+ export interface ClangdApiV1 {
4+ languageClient : BaseLanguageClient
5+ }
6+
7+ export interface ClangdExtension {
8+ getApi ( version : 1 ) : ClangdApiV1 ;
9+ }
10+
11+ export class ClangdExtensionImpl implements ClangdExtension {
12+ constructor (
13+ private readonly client : BaseLanguageClient
14+ ) { }
15+
16+ public getApi ( version : 1 ) : ClangdApiV1 ;
17+ public getApi ( version : number ) : unknown {
18+ if ( version === 1 ) {
19+ return {
20+ languageClient : this . client
21+ } ;
22+ }
23+
24+ throw new Error ( `No API version ${ version } found` ) ;
25+ }
26+ }
Original file line number Diff line number Diff line change 11import * as vscode from 'vscode' ;
2- import type { BaseLanguageClient } from 'vscode-languageclient' ;
32import { ClangdContext } from './clangd-context' ;
3+ import { ClangdExtension , ClangdExtensionImpl } from './api' ;
44
55/**
66 * This method is called when the extension is activated. The extension is
77 * activated the very first time a command is executed.
88 */
9- export async function activate ( context : vscode . ExtensionContext ) : Promise < BaseLanguageClient > {
9+ export async function activate ( context : vscode . ExtensionContext ) : Promise < ClangdExtension > {
1010 const outputChannel = vscode . window . createOutputChannel ( 'clangd' ) ;
1111 context . subscriptions . push ( outputChannel ) ;
1212
@@ -68,5 +68,5 @@ export async function activate(context: vscode.ExtensionContext): Promise<BaseLa
6868 } , 5000 ) ;
6969 }
7070
71- return clangdContext . client ;
71+ return new ClangdExtensionImpl ( clangdContext . client ) ;
7272}
You can’t perform that action at this time.
0 commit comments