-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.ts
More file actions
123 lines (98 loc) · 4.22 KB
/
extension.ts
File metadata and controls
123 lines (98 loc) · 4.22 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"use strict";
import * as vscode from "vscode";
import * as serverManager from "@intersystems-community/intersystems-servermanager";
import { setupHistoryExplorerController } from "./historyExplorer";
import { setupServerTestsController } from "./serverTests";
import { replaceLocalRootItems, setupLocalTestsController } from "./localTests";
import { DebugTrackerFactory } from "./debugTrackerFactory";
export const extensionId = "intersystems-community.testingmanager";
export let localTestController: vscode.TestController;
export let loadedTestController: vscode.TestController;
export let historyBrowserController: vscode.TestController;
export let osAPI: any;
export let smAPI: serverManager.ServerManagerAPI | undefined;
export interface OurTestRun extends vscode.TestRun {
debugSession?: vscode.DebugSession;
}
export interface OurTestItem extends vscode.TestItem {
ourUri?: vscode.Uri;
supportsCoverage?: boolean;
}
export const allTestRuns: (OurTestRun | undefined)[] = [];
// Array indexed by workspaceFolder index, each element holding a map from classname ('P1.P2.C') to TestItem
export let workspaceFolderTestClasses: Map<string, OurTestItem>[] = [];
async function getServerManagerAPI(): Promise<serverManager.ServerManagerAPI | undefined> {
const targetExtension = vscode.extensions.getExtension("intersystems-community.servermanager");
if (!targetExtension) {
return undefined;
}
if (!targetExtension.isActive) {
await targetExtension.activate();
}
const api = targetExtension.exports;
if (!api) {
return undefined;
}
return api;
}
async function getObjectScriptAPI(): Promise<any> {
const targetExtension = vscode.extensions.getExtension("intersystems-community.vscode-objectscript");
if (!targetExtension) {
return undefined;
}
if (!targetExtension.isActive) {
await targetExtension.activate();
}
const api = targetExtension.exports;
if (!api) {
return undefined;
}
return api;
}
export async function activate(context: vscode.ExtensionContext) {
osAPI = await getObjectScriptAPI();
smAPI = await getServerManagerAPI();
// TODO notify user if either of these returned undefined (extensionDependencies setting should prevent that, but better to be safe)
const initWorkspaceFolderTestClasses = () => {
workspaceFolderTestClasses = [];
vscode.workspace.workspaceFolders?.forEach(() => {
// Initialize the map for this workspace folder's test class items
workspaceFolderTestClasses.push(new Map<string, OurTestItem>());
});
}
initWorkspaceFolderTestClasses();
context.subscriptions.push(vscode.workspace.onDidChangeWorkspaceFolders(async (e) => {
initWorkspaceFolderTestClasses();
await replaceLocalRootItems(localTestController);
}));
// Other parts of this extension will use the test controllers we create here
localTestController = vscode.tests.createTestController(`${extensionId}-Local`, '$(folder-library) Local Tests');
context.subscriptions.push(localTestController);
context.subscriptions.push(await setupLocalTestsController());
loadedTestController = vscode.tests.createTestController(`${extensionId}-Loaded`, '$(server-environment) Server Tests');
context.subscriptions.push(loadedTestController);
await setupServerTestsController();
historyBrowserController = vscode.tests.createTestController(`${extensionId}-History`, 'Recent History');
context.subscriptions.push(historyBrowserController);
await setupHistoryExplorerController();
context.subscriptions.push(
vscode.debug.registerDebugAdapterTrackerFactory('objectscript', new DebugTrackerFactory())
);
// Register the commands
context.subscriptions.push(
//DUMMY example (remember to add entries to `contributes.commands` in package.json)
//vscode.commands.registerCommand(`${extensionId}.templateCommand`, () => {}),
);
// Listen for relevant configuration changes
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration((e) => {
// TODO
}));
// Expose our API (if any)
const api = {
};
// 'export' our public api-surface
return api;
}
export function deactivate() {
//
}