MCPcopy Index your code
hub / github.com/microsoft/SandDance / activate

Function activate

extensions/azdata-sanddance/src/extension.ts:14–77  ·  view source on GitHub ↗
(context: vscode.ExtensionContext)

Source from the content-addressed store, hash-verified

12let current: WebViewWithUri | undefined = undefined;
13
14export function activate(context: vscode.ExtensionContext) {
15 context.subscriptions.push(
16 vscode.commands.registerCommand('sanddance.view', (commandContext: vscode.Uri | azdata.ObjectExplorerContext) => {
17 if (!commandContext) {
18 vscode.window.showErrorMessage('No file was specified for the View in SandDance command');
19 return;
20 }
21 if (commandContext instanceof vscode.Uri) {
22 viewFileUriInSandDance(<vscode.Uri>commandContext, context);
23 } else if (commandContext.nodeInfo) {
24 // This is a call from the object explorer right-click.
25 downloadAndViewInSandDance(commandContext, context);
26 }
27 },
28 ),
29 );
30
31 //make the visualizer icon visible
32 vscode.commands.executeCommand('setContext', 'showVisualizer', true);
33
34 // Ideally would unregister listener on deactivate, but this is currently a void function.
35 // Issue #6374 created in ADS repository to track this ask
36 azdata.queryeditor.registerQueryEventListener({
37 async onQueryEvent(type: azdata.queryeditor.QueryEvent, document: azdata.queryeditor.QueryDocument, args: any) {
38 if (type === 'visualize') {
39 const providerid = document.providerId;
40 const provider: azdata.QueryProvider = azdata.dataprotocol.getProvider(providerid, azdata.DataProviderType.QueryProvider);
41 const data = await provider.getQueryRows({
42 ownerUri: document.uri,
43 batchIndex: args.batchId,
44 resultSetIndex: args.id,
45 rowsStartIndex: 0,
46 rowsCount: args.rowCount,
47 });
48
49 const rows = data.resultSubset.rows;
50 const columns = args.columnInfo;
51 const rowsCount = args.rowCount;
52
53 // Create Json
54 const jsonArray: jsonType[] = [];
55
56 interface jsonType {
57 [key: string]: any
58 }
59
60 for (let row = 0; row < rowsCount; row++) {
61 const jsonObject: jsonType = {};
62 for (let col = 0; col < columns.length; col++) {
63 if (!rows[row][col].isNull) {
64 jsonObject[columns[col].columnName] = rows[row][col].displayValue;
65 }
66 // If display value is null, don't do anything for now
67 }
68 jsonArray.push(jsonObject);
69 }
70
71 viewInSandDance(() => {

Callers

nothing calls this directly

Calls 2

viewFileUriInSandDanceFunction · 0.85

Tested by

no test coverage detected