Skip to content

Commit c86da3d

Browse files
Jonathan ZakJonathan Zak
authored andcommitted
Add context provider
1 parent 23d2a62 commit c86da3d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/contextProvider.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { ExtensionContext } from "vscode";
2+
3+
export class ContextProvider {
4+
private static ctx: ExtensionContext | undefined;
5+
6+
public static setContext(context: ExtensionContext) {
7+
ContextProvider.ctx = context;
8+
}
9+
10+
public static getContext(): ExtensionContext {
11+
if (!ContextProvider.ctx) {
12+
throw new Error("Context is not set yet");
13+
}
14+
return ContextProvider.ctx;
15+
}
16+
}

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { queryHistory } from "./views/queryHistoryView";
2626
import { registerCopilotProvider } from "./aiProviders/copilot";
2727
import { registerDb2iTablesProvider } from "./aiProviders/continue/listTablesContextProvider";
2828
import { setCheckerAvailableContext } from "./language/providers/problemProvider";
29+
import { ContextProvider } from "./contextProvider";
2930

3031
export interface Db2i {
3132
sqlJobManager: SQLJobManager,
@@ -42,6 +43,7 @@ export function activate(context: vscode.ExtensionContext): Db2i {
4243
console.log(`Congratulations, your extension "vscode-db2i" is now active!`);
4344

4445
loadBase(context);
46+
ContextProvider.setContext(context);
4547

4648
const exampleBrowser = new ExampleBrowser(context);
4749
const selfCodesView = new selfCodesResultsView(context);

0 commit comments

Comments
 (0)