mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
update parse query action (#22577)
* update parse query action * revert export notebook change * comment
This commit is contained in:
@@ -143,3 +143,15 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.carbon-taskbar .monaco-action-bar .action-item .codicon.action-label[class*='codicon-'] {
|
||||||
|
font-size: 11px;
|
||||||
|
padding-left: 0px;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.carbon-taskbar .monaco-action-bar .action-item .codicon.action-label[class*='codicon-']:before {
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: 'codicon';
|
||||||
|
padding-right: 2px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -521,8 +521,6 @@ export class RunQueryShortcutAction extends Action {
|
|||||||
* Action class that parses the query string in the current SQL text document.
|
* Action class that parses the query string in the current SQL text document.
|
||||||
*/
|
*/
|
||||||
export class ParseSyntaxAction extends Action {
|
export class ParseSyntaxAction extends Action {
|
||||||
|
|
||||||
public static ID = 'parseQueryAction';
|
|
||||||
public static LABEL = nls.localize('parseSyntaxLabel', "Parse Query");
|
public static LABEL = nls.localize('parseSyntaxLabel', "Parse Query");
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -537,7 +535,7 @@ export class ParseSyntaxAction extends Action {
|
|||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override run(): Promise<void> {
|
public override async run(): Promise<void> {
|
||||||
const editor = this.editorService.activeEditorPane;
|
const editor = this.editorService.activeEditorPane;
|
||||||
if (editor instanceof QueryEditor) {
|
if (editor instanceof QueryEditor) {
|
||||||
if (!editor.isSelectionEmpty()) {
|
if (!editor.isSelectionEmpty()) {
|
||||||
@@ -546,29 +544,25 @@ export class ParseSyntaxAction extends Action {
|
|||||||
if (text === '') {
|
if (text === '') {
|
||||||
text = editor.getAllText();
|
text = editor.getAllText();
|
||||||
}
|
}
|
||||||
this.queryManagementService.parseSyntax(editor.input.uri, text).then(result => {
|
const result = await this.queryManagementService.parseSyntax(editor.input.uri, text);
|
||||||
if (result && result.parseable) {
|
if (result && result.parseable) {
|
||||||
this.notificationService.notify({
|
this.notificationService.notify({
|
||||||
severity: Severity.Info,
|
severity: Severity.Info,
|
||||||
message: nls.localize('queryActions.parseSyntaxSuccess', "Commands completed successfully")
|
message: nls.localize('queryActions.parseSyntaxSuccess', "Successfully parsed the query.")
|
||||||
});
|
});
|
||||||
} else if (result && result.errors.length > 0) {
|
} else if (result && result.errors.length > 0) {
|
||||||
let errorMessage = nls.localize('queryActions.parseSyntaxFailure', "Command failed: ");
|
this.notificationService.error(
|
||||||
this.notificationService.error(`${errorMessage}${result.errors[0]}`);
|
nls.localize('queryActions.parseSyntaxFailure', "Failed to parse the query: {0}",
|
||||||
|
result.errors.map((err, idx) => `${idx + 1}. ${err} `).join(' ')));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.notificationService.notify({
|
this.notificationService.notify({
|
||||||
severity: Severity.Error,
|
severity: Severity.Error,
|
||||||
message: nls.localize('queryActions.notConnected', "Please connect to a server")
|
message: nls.localize('queryActions.notConnected', "Please connect to a server before running this action.")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import { FileQueryEditorInput } from 'sql/workbench/contrib/query/browser/fileQu
|
|||||||
import { FileQueryEditorSerializer, QueryEditorLanguageAssociation, UntitledQueryEditorSerializer } from 'sql/workbench/contrib/query/browser/queryEditorFactory';
|
import { FileQueryEditorSerializer, QueryEditorLanguageAssociation, UntitledQueryEditorSerializer } from 'sql/workbench/contrib/query/browser/queryEditorFactory';
|
||||||
import { UntitledQueryEditorInput } from 'sql/base/query/browser/untitledQueryEditorInput';
|
import { UntitledQueryEditorInput } from 'sql/base/query/browser/untitledQueryEditorInput';
|
||||||
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||||
import { NewQueryTask, OE_NEW_QUERY_ACTION_ID, DE_NEW_QUERY_COMMAND_ID, CATEGORIES } from 'sql/workbench/contrib/query/browser/queryActions';
|
import { NewQueryTask, OE_NEW_QUERY_ACTION_ID, DE_NEW_QUERY_COMMAND_ID, CATEGORIES, ParseSyntaxCommandId } from 'sql/workbench/contrib/query/browser/queryActions';
|
||||||
import { TreeNodeContextKey } from 'sql/workbench/services/objectExplorer/common/treeNodeContextKey';
|
import { TreeNodeContextKey } from 'sql/workbench/services/objectExplorer/common/treeNodeContextKey';
|
||||||
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
|
||||||
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
|
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
|
||||||
@@ -199,8 +199,9 @@ actionRegistry.registerWorkbenchAction(
|
|||||||
actionRegistry.registerWorkbenchAction(
|
actionRegistry.registerWorkbenchAction(
|
||||||
SyncActionDescriptor.create(
|
SyncActionDescriptor.create(
|
||||||
ParseSyntaxAction,
|
ParseSyntaxAction,
|
||||||
ParseSyntaxAction.ID,
|
ParseSyntaxCommandId,
|
||||||
ParseSyntaxAction.LABEL
|
ParseSyntaxAction.LABEL,
|
||||||
|
{ primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KeyP }
|
||||||
),
|
),
|
||||||
ParseSyntaxAction.LABEL
|
ParseSyntaxAction.LABEL
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
|
|||||||
import { gen3Version, sqlDataWarehouse } from 'sql/platform/connection/common/constants';
|
import { gen3Version, sqlDataWarehouse } from 'sql/platform/connection/common/constants';
|
||||||
import { Dropdown } from 'sql/base/browser/ui/editableDropdown/browser/dropdown';
|
import { Dropdown } from 'sql/base/browser/ui/editableDropdown/browser/dropdown';
|
||||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||||
|
import { Codicon } from 'vs/base/common/codicons';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action class that query-based Actions will extend. This base class automatically handles activating and
|
* Action class that query-based Actions will extend. This base class automatically handles activating and
|
||||||
@@ -916,8 +917,7 @@ export class ExportAsNotebookAction extends QueryTaskbarAction {
|
|||||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||||
@ICommandService private _commandService: ICommandService
|
@ICommandService private _commandService: ICommandService
|
||||||
) {
|
) {
|
||||||
super(connectionManagementService, editor, ConnectDatabaseAction.ID, ExportAsNotebookAction.IconClass);
|
super(connectionManagementService, editor, ExportAsNotebookAction.ID, ExportAsNotebookAction.IconClass);
|
||||||
|
|
||||||
this.label = nls.localize('queryEditor.exportSqlAsNotebook', "Export as Notebook");
|
this.label = nls.localize('queryEditor.exportSqlAsNotebook', "Export as Notebook");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -929,3 +929,17 @@ export class ExportAsNotebookAction extends QueryTaskbarAction {
|
|||||||
export const CATEGORIES = {
|
export const CATEGORIES = {
|
||||||
ExecutionPlan: { value: nls.localize('ExecutionPlan', 'Execution Plan'), original: 'Execution Plan' }
|
ExecutionPlan: { value: nls.localize('ExecutionPlan', 'Execution Plan'), original: 'Execution Plan' }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// A wrapper for the ParseSyntaxAction.
|
||||||
|
// We are not able to reference the ParseSyntaxAction directly in QueryEditor.ts because there is a circular dependency issue.
|
||||||
|
// The command id is also defined here to avoid duplication.
|
||||||
|
export const ParseSyntaxCommandId = 'parseQueryAction';
|
||||||
|
export class ParseSyntaxTaskbarAction extends Action {
|
||||||
|
constructor(@ICommandService private _commandService: ICommandService) {
|
||||||
|
super(ParseSyntaxCommandId, nls.localize('queryEditor.parse', "Parse"), Codicon.check.classNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async run(): Promise<void> {
|
||||||
|
this._commandService.executeCommand(ParseSyntaxCommandId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ export class QueryEditor extends EditorPane {
|
|||||||
private _toggleSqlcmdMode: actions.ToggleSqlCmdModeAction;
|
private _toggleSqlcmdMode: actions.ToggleSqlCmdModeAction;
|
||||||
private _toggleActualExecutionPlanMode: actions.ToggleActualExecutionPlanModeAction;
|
private _toggleActualExecutionPlanMode: actions.ToggleActualExecutionPlanModeAction;
|
||||||
private _exportAsNotebookAction: actions.ExportAsNotebookAction;
|
private _exportAsNotebookAction: actions.ExportAsNotebookAction;
|
||||||
|
private _parseQueryAction: actions.ParseSyntaxTaskbarAction;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ITelemetryService telemetryService: ITelemetryService,
|
@ITelemetryService telemetryService: ITelemetryService,
|
||||||
@@ -211,6 +212,7 @@ export class QueryEditor extends EditorPane {
|
|||||||
this._toggleSqlcmdMode = this.instantiationService.createInstance(actions.ToggleSqlCmdModeAction, this, false);
|
this._toggleSqlcmdMode = this.instantiationService.createInstance(actions.ToggleSqlCmdModeAction, this, false);
|
||||||
this._toggleActualExecutionPlanMode = this.instantiationService.createInstance(actions.ToggleActualExecutionPlanModeAction, this, false);
|
this._toggleActualExecutionPlanMode = this.instantiationService.createInstance(actions.ToggleActualExecutionPlanModeAction, this, false);
|
||||||
this._exportAsNotebookAction = this.instantiationService.createInstance(actions.ExportAsNotebookAction, this);
|
this._exportAsNotebookAction = this.instantiationService.createInstance(actions.ExportAsNotebookAction, this);
|
||||||
|
this._parseQueryAction = this.instantiationService.createInstance(actions.ParseSyntaxTaskbarAction);
|
||||||
this.setTaskbarContent();
|
this.setTaskbarContent();
|
||||||
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
||||||
if (e.affectsConfiguration(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES)) {
|
if (e.affectsConfiguration(CONFIG_WORKBENCH_ENABLEPREVIEWFEATURES)) {
|
||||||
@@ -269,6 +271,8 @@ export class QueryEditor extends EditorPane {
|
|||||||
this.removeResultsEditor();
|
this.removeResultsEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._parseQueryAction.enabled = this.input.state.connected && !this.input.state.executing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -332,6 +336,7 @@ export class QueryEditor extends EditorPane {
|
|||||||
{ element: Taskbar.createTaskbarSeparator() },
|
{ element: Taskbar.createTaskbarSeparator() },
|
||||||
{ action: this._estimatedQueryPlanAction },
|
{ action: this._estimatedQueryPlanAction },
|
||||||
{ action: this._toggleActualExecutionPlanMode },
|
{ action: this._toggleActualExecutionPlanMode },
|
||||||
|
{ action: this._parseQueryAction }
|
||||||
);
|
);
|
||||||
if (previewFeaturesEnabled) {
|
if (previewFeaturesEnabled) {
|
||||||
content.push(
|
content.push(
|
||||||
|
|||||||
Reference in New Issue
Block a user