From 9b1410c94c170f1b942e5872804c3185cde460d1 Mon Sep 17 00:00:00 2001 From: Sanjula Ganepola Date: Fri, 30 Jan 2026 19:27:03 -0500 Subject: [PATCH] Add search button to visual explain views Signed-off-by: Sanjula Ganepola --- package.json | 44 +- src/views/results/explain/contributes.json | 556 +++++++++++---------- src/views/results/index.ts | 64 ++- 3 files changed, 367 insertions(+), 297 deletions(-) diff --git a/package.json b/package.json index 6514194b..24a2adb3 100644 --- a/package.json +++ b/package.json @@ -715,10 +715,10 @@ "icon": "$(lightbulb)" }, { - "command": "vscode-db2i.dove.editSettings", - "title": "Settings", + "command": "vscode-db2i.dove.searchVisualExplain", + "title": "Search", "category": "Db2 for i", - "icon": "$(gear)" + "icon": "$(search)" }, { "command": "vscode-db2i.dove.export", @@ -726,6 +726,18 @@ "category": "Db2 for i", "icon": "$(file)" }, + { + "command": "vscode-db2i.dove.editSettings", + "title": "Settings", + "category": "Db2 for i", + "icon": "$(gear)" + }, + { + "command": "vscode-db2i.dove.node.searchVisualExplainDetails", + "title": "Search", + "category": "Db2 for i", + "icon": "$(search)" + }, { "command": "vscode-db2i.dove.node.copy", "title": "Copy value", @@ -1069,13 +1081,21 @@ "when": "vscode-db2i:explaining == true" }, { - "command": "vscode-db2i.dove.editSettings", - "when": "vscode-db2i:explaining == true" + "command": "vscode-db2i.dove.searchVisualExplain", + "when": "never" }, { "command": "vscode-db2i.dove.export", "when": "vscode-db2i:explaining == true" }, + { + "command": "vscode-db2i.dove.editSettings", + "when": "vscode-db2i:explaining == true" + }, + { + "command": "vscode-db2i.dove.node.searchVisualExplainDetails", + "when": "never" + }, { "command": "vscode-db2i.dove.node.copy", "when": "never" @@ -1197,7 +1217,7 @@ "when": "view == vscode-db2i.dove.nodes" }, { - "command": "vscode-db2i.dove.editSettings", + "command": "vscode-db2i.dove.searchVisualExplain", "group": "navigation@1", "when": "view == vscode-db2i.dove.nodes" }, @@ -1207,10 +1227,20 @@ "when": "view == vscode-db2i.dove.nodes" }, { - "command": "vscode-db2i.dove.close", + "command": "vscode-db2i.dove.editSettings", "group": "navigation@3", "when": "view == vscode-db2i.dove.nodes" }, + { + "command": "vscode-db2i.dove.close", + "group": "navigation@4", + "when": "view == vscode-db2i.dove.nodes" + }, + { + "command": "vscode-db2i.dove.node.searchVisualExplainDetails", + "group": "navigation@0", + "when": "view == vscode-db2i.dove.node" + }, { "command": "vscode-db2i.dove.generateSqlForAdvisedIndexes", "group": "navigation@0", diff --git a/src/views/results/explain/contributes.json b/src/views/results/explain/contributes.json index 69383210..c3d084af 100644 --- a/src/views/results/explain/contributes.json +++ b/src/views/results/explain/contributes.json @@ -1,264 +1,294 @@ -{ - "contributes": { - "configuration": [ - { - "id": "vscode-db2i.visualExplain", - "title": "Visual Explain", - "properties": { - "vscode-db2i.visualExplain.highlighting": { - "type": "object", - "properties": { - "Index Advised": { - "type": "boolean", - "default": true - }, - "Actual Number of Rows": { - "type": "boolean", - "default": true - }, - "Actual Processing Time": { - "type": "boolean", - "default": true - }, - "Estimated Number of Rows": { - "type": "boolean", - "default": true - }, - "Estimated Processing Time": { - "type": "boolean", - "default": true - }, - "Lookahead Predicate Generation (LPG)": { - "type": "boolean", - "default": true - }, - "Materialized Query Table (MQT)": { - "type": "boolean", - "default": true - } - }, - "default": { - "Index Advised": true, - "Actual Number of Rows": true, - "Actual Processing Time": true, - "Estimated Number of Rows": true, - "Estimated Processing Time": true, - "Lookahead Predicate Generation (LPG)": true, - "Materialized Query Table (MQT)": true - }, - "additionalProperties": false, - "description": "Highlight expensive operations in the graph to aid in identifying potential problems with the query." - } - } - } - ], - "views": { - "ibmi-panel": [ - { - "type": "tree", - "id": "vscode-db2i.dove.nodes", - "name": "Visual Explain", - "when": "code-for-ibmi:connected && vscode-db2i:explaining == true", - "contextualTitle": "DB2 for i" - }, - { - "type": "tree", - "id": "vscode-db2i.dove.node", - "name": "Visual Explain Details", - "when": "code-for-ibmi:connected && vscode-db2i:explainingNode == true" - } - ] - }, - "commands": [ - { - "command": "vscode-db2i.dove.close", - "title": "Close", - "category": "Db2 for i", - "icon": "$(close)" - }, - { - "command": "vscode-db2i.dove.displayDetails", - "title": "Display details", - "category": "Db2 for i", - "icon": "$(info)" - }, - { - "command": "vscode-db2i.dove.generateSqlForAdvisedIndexes", - "title": "Generate SQL for Advised Indexes", - "category": "Db2 for i", - "icon": "$(go-to-file)" - }, - { - "command": "vscode-db2i.dove.closeDetails", - "title": "Close", - "category": "Db2 for i", - "icon": "$(close)" - }, - { - "command": "vscode-db2i.dove.advisedIndexesAndStatistics", - "title": "Advised Indexes and Statistics", - "category": "Db2 for i", - "icon": "$(lightbulb)" - }, - { - "command": "vscode-db2i.dove.editSettings", - "title": "Settings", - "category": "Db2 for i", - "icon": "$(gear)" - }, - { - "command": "vscode-db2i.dove.export", - "title": "Export current VE data", - "category": "Db2 for i", - "icon": "$(file)" - }, - { - "command": "vscode-db2i.dove.node.copy", - "title": "Copy value", - "category": "Db2 for i", - "icon": "$(pencil)" - } - ], - "menus": { - "commandPalette": [ - { - "command": "vscode-db2i.dove.displayDetails", - "when": "never" - }, - { - "command": "vscode-db2i.dove.advisedIndexesAndStatistics", - "when": "vscode-db2i:explaining == true" - }, - { - "command": "vscode-db2i.dove.editSettings", - "when": "vscode-db2i:explaining == true" - }, - { - "command": "vscode-db2i.dove.export", - "when": "vscode-db2i:explaining == true" - }, - { - "command": "vscode-db2i.dove.node.copy", - "when": "never" - } - ], - "view/title": [ - { - "command": "vscode-db2i.dove.advisedIndexesAndStatistics", - "group": "navigation@0", - "when": "view == vscode-db2i.dove.nodes" - }, - { - "command": "vscode-db2i.dove.editSettings", - "group": "navigation@1", - "when": "view == vscode-db2i.dove.nodes" - }, - { - "command": "vscode-db2i.dove.export", - "group": "navigation@2", - "when": "view == vscode-db2i.dove.nodes" - }, - { - "command": "vscode-db2i.dove.close", - "group": "navigation@3", - "when": "view == vscode-db2i.dove.nodes" - }, - { - "command": "vscode-db2i.dove.generateSqlForAdvisedIndexes", - "group": "navigation@0", - "when": "view == vscode-db2i.dove.node && vscode-db2i:viewingAdvisedIndexes" - }, - { - "command": "vscode-db2i.dove.closeDetails", - "group": "navigation@1", - "when": "view == vscode-db2i.dove.node" - } - ], - "view/item/context": [ - { - "command": "vscode-db2i.dove.displayDetails", - "when": "view == vscode-db2i.dove.nodes && viewItem == explainTreeItem", - "group": "inline" - }, - { - "command": "vscode-db2i.dove.node.copy", - "when": "view == vscode-db2i.dove.node && viewItem == propertyNode" - } - ] - }, - "colors": [ - { - "id": "db2i.dove.resultsView.HighlightIndexAdvised", - "description": "Highlight color for index advised", - "defaults": { - "dark": "#8c8cbd", - "light": "#8c8cbd" - } - }, - { - "id": "db2i.dove.resultsView.HighlightActualExpensiveRows", - "description": "Highlight color for actual expensive rows", - "defaults": { - "dark": "#cc9933", - "light": "#cc9933" - } - }, - { - "id": "db2i.dove.resultsView.HighlightEstimatedExpensiveRows", - "description": "Highlight color for estimated expensive rows", - "defaults": { - "dark": "#dbdb01", - "light": "#a0a001" - } - }, - { - "id": "db2i.dove.resultsView.HighlightActualExpensiveTime", - "description": "Highlight color for actual expensive time", - "defaults": { - "dark": "#bc0f0f", - "light": "#bc0f0f" - } - }, - { - "id": "db2i.dove.resultsView.HighlightEstimatedExpensiveTime", - "description": "Highlight color for estimated expensive time", - "defaults": { - "dark": "#f2bdbd", - "light": "#f2bdbd" - } - }, - { - "id": "db2i.dove.resultsView.HighlightLookaheadPredicateGeneration", - "description": "Highlight color for Lookahead Predicate Generation", - "defaults": { - "dark": "#00ff00", - "light": "#00ff00" - } - }, - { - "id": "db2i.dove.resultsView.HighlightMaterializedQueryTable", - "description": "Highlight color for Materialized Query Table", - "defaults": { - "dark": "#ff8400", - "light": "#ff8400" - } - }, - { - "id": "db2i.dove.resultsView.HighlightRefreshedNode", - "description": "Highlight color for refreshed node", - "defaults": { - "dark": "#00ffff", - "light": "#00ffff" - } - }, - { - "id": "db2i.dove.nodeView.AttributeSectionHeading", - "description": "Color for attributes section heading", - "defaults": { - "dark": "#bd8c8c", - "light": "#5976df" - } - } - ] - } +{ + "contributes": { + "configuration": [ + { + "id": "vscode-db2i.visualExplain", + "title": "Visual Explain", + "properties": { + "vscode-db2i.visualExplain.highlighting": { + "type": "object", + "properties": { + "Index Advised": { + "type": "boolean", + "default": true + }, + "Actual Number of Rows": { + "type": "boolean", + "default": true + }, + "Actual Processing Time": { + "type": "boolean", + "default": true + }, + "Estimated Number of Rows": { + "type": "boolean", + "default": true + }, + "Estimated Processing Time": { + "type": "boolean", + "default": true + }, + "Lookahead Predicate Generation (LPG)": { + "type": "boolean", + "default": true + }, + "Materialized Query Table (MQT)": { + "type": "boolean", + "default": true + } + }, + "default": { + "Index Advised": true, + "Actual Number of Rows": true, + "Actual Processing Time": true, + "Estimated Number of Rows": true, + "Estimated Processing Time": true, + "Lookahead Predicate Generation (LPG)": true, + "Materialized Query Table (MQT)": true + }, + "additionalProperties": false, + "description": "Highlight expensive operations in the graph to aid in identifying potential problems with the query." + } + } + } + ], + "views": { + "ibmi-panel": [ + { + "type": "tree", + "id": "vscode-db2i.dove.nodes", + "name": "Visual Explain", + "when": "code-for-ibmi:connected && vscode-db2i:explaining == true", + "contextualTitle": "DB2 for i" + }, + { + "type": "tree", + "id": "vscode-db2i.dove.node", + "name": "Visual Explain Details", + "when": "code-for-ibmi:connected && vscode-db2i:explainingNode == true" + } + ] + }, + "commands": [ + { + "command": "vscode-db2i.dove.close", + "title": "Close", + "category": "Db2 for i", + "icon": "$(close)" + }, + { + "command": "vscode-db2i.dove.displayDetails", + "title": "Display details", + "category": "Db2 for i", + "icon": "$(info)" + }, + { + "command": "vscode-db2i.dove.generateSqlForAdvisedIndexes", + "title": "Generate SQL for Advised Indexes", + "category": "Db2 for i", + "icon": "$(go-to-file)" + }, + { + "command": "vscode-db2i.dove.closeDetails", + "title": "Close", + "category": "Db2 for i", + "icon": "$(close)" + }, + { + "command": "vscode-db2i.dove.advisedIndexesAndStatistics", + "title": "Advised Indexes and Statistics", + "category": "Db2 for i", + "icon": "$(lightbulb)" + }, + { + "command": "vscode-db2i.dove.searchVisualExplain", + "title": "Search", + "category": "Db2 for i", + "icon": "$(search)" + }, + { + "command": "vscode-db2i.dove.export", + "title": "Export current VE data", + "category": "Db2 for i", + "icon": "$(file)" + }, + { + "command": "vscode-db2i.dove.editSettings", + "title": "Settings", + "category": "Db2 for i", + "icon": "$(gear)" + }, + { + "command": "vscode-db2i.dove.node.searchVisualExplainDetails", + "title": "Search", + "category": "Db2 for i", + "icon": "$(search)" + }, + { + "command": "vscode-db2i.dove.node.copy", + "title": "Copy value", + "category": "Db2 for i", + "icon": "$(pencil)" + } + ], + "menus": { + "commandPalette": [ + { + "command": "vscode-db2i.dove.displayDetails", + "when": "never" + }, + { + "command": "vscode-db2i.dove.advisedIndexesAndStatistics", + "when": "vscode-db2i:explaining == true" + }, + { + "command": "vscode-db2i.dove.searchVisualExplain", + "when": "never" + }, + { + "command": "vscode-db2i.dove.export", + "when": "vscode-db2i:explaining == true" + }, + { + "command": "vscode-db2i.dove.editSettings", + "when": "vscode-db2i:explaining == true" + }, + { + "command": "vscode-db2i.dove.node.searchVisualExplainDetails", + "when": "never" + }, + { + "command": "vscode-db2i.dove.node.copy", + "when": "never" + } + ], + "view/title": [ + { + "command": "vscode-db2i.dove.advisedIndexesAndStatistics", + "group": "navigation@0", + "when": "view == vscode-db2i.dove.nodes" + }, + { + "command": "vscode-db2i.dove.searchVisualExplain", + "group": "navigation@1", + "when": "view == vscode-db2i.dove.nodes" + }, + { + "command": "vscode-db2i.dove.export", + "group": "navigation@2", + "when": "view == vscode-db2i.dove.nodes" + }, + { + "command": "vscode-db2i.dove.editSettings", + "group": "navigation@3", + "when": "view == vscode-db2i.dove.nodes" + }, + { + "command": "vscode-db2i.dove.close", + "group": "navigation@4", + "when": "view == vscode-db2i.dove.nodes" + }, + { + "command": "vscode-db2i.dove.node.searchVisualExplainDetails", + "group": "navigation@0", + "when": "view == vscode-db2i.dove.node" + }, + { + "command": "vscode-db2i.dove.generateSqlForAdvisedIndexes", + "group": "navigation@0", + "when": "view == vscode-db2i.dove.node && vscode-db2i:viewingAdvisedIndexes" + }, + { + "command": "vscode-db2i.dove.closeDetails", + "group": "navigation@1", + "when": "view == vscode-db2i.dove.node" + } + ], + "view/item/context": [ + { + "command": "vscode-db2i.dove.displayDetails", + "when": "view == vscode-db2i.dove.nodes && viewItem == explainTreeItem", + "group": "inline" + }, + { + "command": "vscode-db2i.dove.node.copy", + "when": "view == vscode-db2i.dove.node && viewItem == propertyNode" + } + ] + }, + "colors": [ + { + "id": "db2i.dove.resultsView.HighlightIndexAdvised", + "description": "Highlight color for index advised", + "defaults": { + "dark": "#8c8cbd", + "light": "#8c8cbd" + } + }, + { + "id": "db2i.dove.resultsView.HighlightActualExpensiveRows", + "description": "Highlight color for actual expensive rows", + "defaults": { + "dark": "#cc9933", + "light": "#cc9933" + } + }, + { + "id": "db2i.dove.resultsView.HighlightEstimatedExpensiveRows", + "description": "Highlight color for estimated expensive rows", + "defaults": { + "dark": "#dbdb01", + "light": "#a0a001" + } + }, + { + "id": "db2i.dove.resultsView.HighlightActualExpensiveTime", + "description": "Highlight color for actual expensive time", + "defaults": { + "dark": "#bc0f0f", + "light": "#bc0f0f" + } + }, + { + "id": "db2i.dove.resultsView.HighlightEstimatedExpensiveTime", + "description": "Highlight color for estimated expensive time", + "defaults": { + "dark": "#f2bdbd", + "light": "#f2bdbd" + } + }, + { + "id": "db2i.dove.resultsView.HighlightLookaheadPredicateGeneration", + "description": "Highlight color for Lookahead Predicate Generation", + "defaults": { + "dark": "#00ff00", + "light": "#00ff00" + } + }, + { + "id": "db2i.dove.resultsView.HighlightMaterializedQueryTable", + "description": "Highlight color for Materialized Query Table", + "defaults": { + "dark": "#ff8400", + "light": "#ff8400" + } + }, + { + "id": "db2i.dove.resultsView.HighlightRefreshedNode", + "description": "Highlight color for refreshed node", + "defaults": { + "dark": "#00ffff", + "light": "#00ffff" + } + }, + { + "id": "db2i.dove.nodeView.AttributeSectionHeading", + "description": "Color for attributes section heading", + "defaults": { + "dark": "#bd8c8c", + "light": "#5976df" + } + } + ] + } } \ No newline at end of file diff --git a/src/views/results/index.ts b/src/views/results/index.ts index c5577291..da8bc56b 100644 --- a/src/views/results/index.ts +++ b/src/views/results/index.ts @@ -73,14 +73,14 @@ export function initialise(context: vscode.ExtensionContext) { vscode.commands.registerCommand(`vscode-db2i.statement.cancel`, async (jobName?: string) => { const selected = typeof jobName === `string` ? JobManager.getJob(jobName) : JobManager.getSelection(); if (selected) { - updateStatusBar({canceling: true}); + updateStatusBar({ canceling: true }); const cancelled = await selected.job.requestCancel(); if (cancelled) { resultSetProvider.setError(`Statement canceled.`); setCancelButtonVisibility(false); updateStatusBar(); } else { - updateStatusBar({jobIsBusy: true}); + updateStatusBar({ jobIsBusy: true }); setTimeout(() => updateStatusBar(), 2000); } } @@ -124,6 +124,16 @@ export function initialise(context: vscode.ExtensionContext) { explainTree.showAdvisedIndexesAndStatistics(doveNodeView); }), + vscode.commands.registerCommand(`vscode-db2i.dove.searchVisualExplain`, () => { + vscode.commands.executeCommand('vscode-db2i.dove.nodes.focus'); + vscode.commands.executeCommand('list.find'); + }), + + vscode.commands.registerCommand(`vscode-db2i.dove.node.searchVisualExplainDetails`, () => { + vscode.commands.executeCommand('vscode-db2i.dove.node.focus'); + vscode.commands.executeCommand('list.find'); + }), + vscode.commands.registerCommand(`vscode-db2i.dove.editSettings`, () => { vscode.commands.executeCommand('workbench.action.openSettings', 'vscode-db2i.visualExplain'); }), @@ -169,7 +179,7 @@ function isStop(statement: Statement) { return (statement.type === StatementType.Unknown && statement.tokens.length === 1 && statement.tokens[0].value.toUpperCase() === `STOP`); } -async function runMultipleHandler(mode: `all`|`selected`|`from`) { +async function runMultipleHandler(mode: `all` | `selected` | `from`) { const editor = vscode.window.activeTextEditor; if (editor && editor.document.languageId === `sql`) { const selection = editor.selection; @@ -185,12 +195,12 @@ async function runMultipleHandler(mode: `all`|`selected`|`from`) { const groupStart = group.statements[0].tokens[0].range.start; const groupEnd = group.statements[group.statements.length - 1].tokens[group.statements[group.statements.length - 1].tokens.length - 1].range.end; - return (startPos >= groupStart && startPos <= groupEnd) || (endPos >= groupStart && endPos <= groupEnd) || - (groupStart >= startPos && groupStart <= endPos) || (groupEnd >= startPos && groupEnd <= endPos); + return (startPos >= groupStart && startPos <= groupEnd) || (endPos >= groupStart && endPos <= groupEnd) || + (groupStart >= startPos && groupStart <= endPos) || (groupEnd >= startPos && groupEnd <= endPos); } switch (mode) { - case `selected`: + case `selected`: statementsToRun = statementGroups.filter(group => isInRange(group) || isInRange(group)) break; case `from`: statementsToRun = statementGroups.filter(group => (startPos <= group.range.end)); break; @@ -220,7 +230,7 @@ async function runMultipleHandler(mode: `all`|`selected`|`from`) { ); return; } - + statementInfos.push({ content: sqlDocument.content.substring( group.range.start, group.range.end @@ -267,7 +277,7 @@ async function runHandler(options?: StatementInfo) { let chosenView = resultSetProvider; const useWindow = (title: string, column?: ViewColumn) => { - const webview = window.createWebviewPanel(`sqlResultSet`, title, column || ViewColumn.Two, {retainContextWhenHidden: true, enableScripts: true, enableFindWidget: true}); + const webview = window.createWebviewPanel(`sqlResultSet`, title, column || ViewColumn.Two, { retainContextWhenHidden: true, enableScripts: true, enableFindWidget: true }); chosenView = new ResultSetPanelProvider(); chosenView.resolveWebviewView(webview); } @@ -325,7 +335,7 @@ async function runHandler(options?: StatementInfo) { chosenView.setLoadingText(`Running CL command... (${command})`, false); // CL does not throw - const result = await JobManager.runSQLVerbose<{SUMMARY: string}>(statementDetail.content, {isClCommand: true}); + const result = await JobManager.runSQLVerbose<{ SUMMARY: string }>(statementDetail.content, { isClCommand: true }); if (!result.success) { throw new Error(result.data && result.data[0] ? result.data[0].SUMMARY : `CL command ${command} executed successfully.`); } @@ -355,7 +365,7 @@ async function runHandler(options?: StatementInfo) { } vscode.commands.executeCommand(`vscode-db2i.queryHistory.prepend`, runStatement.statement, `bind: ${statementDetail.content}`); - + // Overwrite to run the prior statement statementDetail.content = runStatement.statement; } @@ -365,7 +375,7 @@ async function runHandler(options?: StatementInfo) { if (statementDetail.noUi) { setCancelButtonVisibility(true); chosenView.setLoadingText(`Running SQL statement... (${possibleTitle})`, false); - await JobManager.runSQL(statementDetail.content, {parameters}, 1); + await JobManager.runSQL(statementDetail.content, { parameters }, 1); } else { if (inWindow) { @@ -399,9 +409,9 @@ async function runHandler(options?: StatementInfo) { chosenView.setLoadingText(onlyExplain ? `Explaining without running...` : `Explaining...`); const explainType: ExplainType = onlyExplain ? ExplainType.DO_NOT_RUN : ExplainType.RUN; - setCancelButtonVisibility(true); - const explained = await selectedJob.job.explain(statementDetail.content, explainType); // Can throw - setCancelButtonVisibility(false); + setCancelButtonVisibility(true); + const explained = await selectedJob.job.explain(statementDetail.content, explainType); // Can throw + setCancelButtonVisibility(false); if (onlyExplain) { chosenView.setLoadingText(`Explained.`, false); @@ -427,35 +437,35 @@ async function runHandler(options?: StatementInfo) { } else { chosenView.setLoadingText(`Executing SQL statement...`, false); setCancelButtonVisibility(true); - updateStatusBar({executing: true}); + updateStatusBar({ executing: true }); const result = await JobManager.runSQLVerbose(statementDetail.content, undefined, 1); setCancelButtonVisibility(false); - updateStatusBar({executing: false}); + updateStatusBar({ executing: false }); let content = `**free\n\n` + `// statement:\n` - + `// ${statementDetail.content.replace(/(\r\n|\r|\n)/g, '\n// ') }\n\n` + + `// ${statementDetail.content.replace(/(\r\n|\r|\n)/g, '\n// ')}\n\n` + `// Row data structure\n` + queryResultToRpgDs(result, Configuration.get(`codegen.rpgSymbolicNameSource`)); const textDoc = await vscode.workspace.openTextDocument({ language: 'rpgle', content }); await vscode.window.showTextDocument(textDoc); chosenView.setLoadingText(`RPG data structure generated.`, false); } - + } else if (statementDetail.qualifier === `udtf`) { if (statementDetail.statement.type !== StatementType.Select) { vscode.window.showErrorMessage('UDTF qualifier only supported for select statements'); } else { chosenView.setLoadingText(`Executing SQL statement...`, false); setCancelButtonVisibility(true); - updateStatusBar({executing: true}); + updateStatusBar({ executing: true }); const result = await JobManager.runSQLVerbose(statementDetail.content, undefined, 1); setCancelButtonVisibility(false); - updateStatusBar({executing: false}); + updateStatusBar({ executing: false }); let content = `-- statement:\n` - + `-- ${statementDetail.content.replace(/(\r\n|\r|\n)/g, '\n-- ') }\n\n` + + `-- ${statementDetail.content.replace(/(\r\n|\r|\n)/g, '\n-- ')}\n\n` + `-- User-defined table function\n` + queryResultToUdtf(result, statementDetail.content, statementDetail.statement.tokens); - + const textDoc = await vscode.workspace.openTextDocument({ language: 'sql', content }); await vscode.window.showTextDocument(textDoc); chosenView.setLoadingText(`User-defined table function generated.`, false); @@ -466,7 +476,7 @@ async function runHandler(options?: StatementInfo) { chosenView.setLoadingText(`Executing SQL statement...`, false); setCancelButtonVisibility(true); - updateStatusBar({executing: true}); + updateStatusBar({ executing: true }); const data = await JobManager.runSQL(statementDetail.content); setCancelButtonVisibility(false); @@ -478,13 +488,13 @@ async function runHandler(options?: StatementInfo) { case `sql`: let content = ``; switch (statementDetail.qualifier) { - case `csv`: + case `csv`: content = csv.stringify(data, { header: true, quoted_string: true, delimiter: DelimValue[Configuration.get(`codegen.csvColumnDelimiter`) || `Comma`] - }); - break; + }); + break; case `json`: content = JSON.stringify(data, null, 2); break; case `sql`: @@ -629,7 +639,7 @@ export function parseStatement(editor?: vscode.TextEditor, existingInfo?: Statem if (sqlDocument) { if (![`cl`, `bind`].includes(statementInfo.qualifier)) { - statementInfo.embeddedInfo = sqlDocument.removeEmbeddedAreas(statementInfo.statement, {replacement: `snippet`}); + statementInfo.embeddedInfo = sqlDocument.removeEmbeddedAreas(statementInfo.statement, { replacement: `snippet` }); } }