Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -7,4 +7,6 @@ export const copyIncludeHeaders = 'copyIncludeHeaders';
export const configSaveAsCsv = 'saveAsCsv';
export const configCopyRemoveNewLine = 'copyRemoveNewLine';
export const configShowBatchTime = 'showBatchTime';
export const querySection = 'query';
export const shortcutStart = 'shortcut';

View File

@@ -3,6 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/css!sql/parts/query/common/media/flavorStatus';
import { $, append, show, hide } from 'vs/base/browser/dom';
import { IDisposable, combinedDisposable } from 'vs/base/common/lifecycle';
import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { localize } from 'vs/nls';
// localizable strings
@@ -12,19 +12,10 @@ export const runQueryBatchStartLine = localize('runQueryBatchStartLine', 'Line {
export const msgCancelQueryFailed = localize('msgCancelQueryFailed', 'Canceling the query failed: {0}');
export const filepathPrompt = localize('filepathPrompt', 'File path');
export const filepathPlaceholder = localize('filepathPlaceholder', 'File name');
export const filepathMessage = localize('filepathMessage', 'File name');
export const overwritePrompt = localize('overwritePrompt', 'A file with this name already exists. Do you want to replace the existing file?');
export const overwritePlaceholder = localize('overwritePlaceholder', 'A file with this name already exists');
export const msgSaveResultInProgress = localize('msgSaveResultInProgress', 'A save request is already executing. Please wait for its completion.');
export const msgCannotOpenContent = localize('msgCannotOpenContent', 'Error occurred opening content in editor.');
export const msgSaveStarted = localize('msgSaveStarted', 'Started saving results to ');
export const msgSaveFailed = localize('msgSaveFailed', 'Failed to save results. ');
export const msgSaveSucceeded = localize('msgSaveSucceeded', 'Successfully saved results to ');
export const msgStatusRunQueryInProgress = localize('msgStatusRunQueryInProgress', 'Executing query...');
// /** Results Pane Labels */
@@ -34,9 +25,8 @@ export const saveCSVLabel = localize('saveCSVLabel', 'Save as CSV');
export const saveJSONLabel = localize('saveJSONLabel', 'Save as JSON');
export const saveExcelLabel = localize('saveExcelLabel', 'Save as Excel');
export const viewChartLabel = localize('viewChartLabel', 'View as Chart');
export const resultPaneLabel = localize('resultPaneLabel', 'Results');
export const selectAll = localize('selectAll', 'Select all');
export const copyLabel = localize('copyLabel', 'Copy');
export const executeQueryLabel = localize('executeQueryLabel', 'Executing query ');
/** Messages Pane Labels */

View File

@@ -0,0 +1,8 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.monaco-workbench .query-statusbar-group > .editor-status-selection {
padding: 0 5px 0 5px;
}

View File

@@ -6,15 +6,15 @@
'use strict';
import { Registry } from 'vs/platform/registry/common/platform';
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actionRegistry';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { KeyMod, KeyCode, KeyChord } from 'vs/base/common/keyCodes';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { QueryEditor } from 'sql/parts/query/editor/queryEditor';
import { QueryResultsEditor } from 'sql/parts/query/editor/queryResultsEditor';
@@ -23,7 +23,10 @@ import * as queryContext from 'sql/parts/query/common/queryContext';
import { QueryInput } from 'sql/parts/query/common/queryInput';
import { EditDataEditor } from 'sql/parts/editData/editor/editDataEditor';
import { EditDataInput } from 'sql/parts/editData/common/editDataInput';
import { RunQueryKeyboardAction, RunCurrentQueryKeyboardAction, CancelQueryKeyboardAction, RefreshIntellisenseKeyboardAction } from 'sql/parts/query/execution/keyboardQueryActions';
import {
RunQueryKeyboardAction, RunCurrentQueryKeyboardAction, CancelQueryKeyboardAction, RefreshIntellisenseKeyboardAction, ToggleQueryResultsKeyboardAction,
RunQueryShortcutAction, RunCurrentQueryWithActualPlanKeyboardAction
} from 'sql/parts/query/execution/keyboardQueryActions';
import * as gridActions from 'sql/parts/grid/views/gridActions';
import * as gridCommands from 'sql/parts/grid/views/gridCommands';
import { QueryPlanEditor } from 'sql/parts/queryPlan/queryPlanEditor';
@@ -38,10 +41,9 @@ export const ResultsMessagesFocusCondition = ContextKeyExpr.and(ContextKeyExpr.h
// Editor
const queryResultsEditorDescriptor = new EditorDescriptor(
QueryResultsEditor,
QueryResultsEditor.ID,
'QueryResults',
'sql/parts/query/editor/queryResultsEditor',
'QueryResultsEditor'
'QueryResults'
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
@@ -49,10 +51,9 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors)
// Editor
const queryEditorDescriptor = new EditorDescriptor(
QueryEditor,
QueryEditor.ID,
'Query',
'sql/parts/query/editor/queryEditor',
'QueryEditor'
'Query'
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
@@ -60,22 +61,20 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors)
// Query Plan editor registration
const createLoginEditorDescriptor = new EditorDescriptor(
const queryPlanEditorDescriptor = new EditorDescriptor(
QueryPlanEditor,
QueryPlanEditor.ID,
'QueryPlan',
'sql/parts/queryPlan/queryPlanEditor',
'QueryPlanEditor'
'QueryPlan'
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditor(createLoginEditorDescriptor, [new SyncDescriptor(QueryPlanInput)]);
.registerEditor(queryPlanEditorDescriptor, [new SyncDescriptor(QueryPlanInput)]);
// Editor
const editDataEditorDescriptor = new EditorDescriptor(
EditDataEditor,
EditDataEditor.ID,
'EditData',
'sql/parts/editData/editor/editDataEditor',
'EditDataEditor'
'EditData'
);
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
@@ -104,6 +103,15 @@ actionRegistry.registerWorkbenchAction(
RunCurrentQueryKeyboardAction.LABEL
);
actionRegistry.registerWorkbenchAction(
new SyncActionDescriptor(
RunCurrentQueryWithActualPlanKeyboardAction,
RunCurrentQueryWithActualPlanKeyboardAction.ID,
RunCurrentQueryWithActualPlanKeyboardAction.LABEL
),
RunCurrentQueryWithActualPlanKeyboardAction.LABEL
);
actionRegistry.registerWorkbenchAction(
new SyncActionDescriptor(
CancelQueryKeyboardAction,
@@ -123,6 +131,14 @@ actionRegistry.registerWorkbenchAction(
RefreshIntellisenseKeyboardAction.LABEL
);
actionRegistry.registerWorkbenchAction(
new SyncActionDescriptor(
ToggleQueryResultsKeyboardAction,
ToggleQueryResultsKeyboardAction.ID,
ToggleQueryResultsKeyboardAction.LABEL
),
ToggleQueryResultsKeyboardAction.LABEL
);
// Grid actions
KeybindingsRegistry.registerCommandAndKeybindingRule({
@@ -198,64 +214,98 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
});
// Intellisense and other configuration options
let registryProperties = {
'sql.messagesDefaultOpen': {
'type': 'boolean',
'description': localize('sql.messagesDefaultOpen', 'True for the messages pane to be open by default; false for closed'),
'default': true
},
'sql.saveAsCsv.includeHeaders': {
'type': 'boolean',
'description': localize('sql.saveAsCsv.includeHeaders', '[Optional] When true, column headers are included when saving results as CSV'),
'default': true
},
'sql.copyIncludeHeaders': {
'type': 'boolean',
'description': localize('sql.copyIncludeHeaders', '[Optional] Configuration options for copying results from the Results View'),
'default': false
},
'sql.copyRemoveNewLine': {
'type': 'boolean',
'description': localize('sql.copyRemoveNewLine', '[Optional] Configuration options for copying multi-line results from the Results View'),
'default': true
},
'sql.showBatchTime': {
'type': 'boolean',
'description': localize('sql.showBatchTime', '[Optional] Should execution time be shown for individual batches'),
'default': false
},
'sql.intelliSense.enableIntelliSense': {
'type': 'boolean',
'default': true,
'description': localize('sql.intelliSense.enableIntelliSense', 'Should IntelliSense be enabled')
},
'sql.intelliSense.enableErrorChecking': {
'type': 'boolean',
'default': true,
'description': localize('sql.intelliSense.enableErrorChecking', 'Should IntelliSense error checking be enabled')
},
'sql.intelliSense.enableSuggestions': {
'type': 'boolean',
'default': true,
'description': localize('sql.intelliSense.enableSuggestions', 'Should IntelliSense suggestions be enabled')
},
'sql.intelliSense.enableQuickInfo': {
'type': 'boolean',
'default': true,
'description': localize('sql.intelliSense.enableQuickInfo', 'Should IntelliSense quick info be enabled')
},
'sql.intelliSense.lowerCaseSuggestions': {
'type': 'boolean',
'default': false,
'description': localize('sql.intelliSense.lowerCaseSuggestions', 'Should IntelliSense suggestions be lowercase')
}
};
// Setup keybindings
let initialShortcuts = [
{ name: 'sp_help', primary: KeyMod.Alt + KeyCode.F2 },
// Note: using Ctrl+Shift+N since Ctrl+N is used for "open editor at index" by default. This means it's different from SSMS
{ name: 'sp_who', primary: KeyMod.WinCtrl + KeyMod.Shift + KeyCode.KEY_1 },
{ name: 'sp_lock', primary: KeyMod.WinCtrl + KeyMod.Shift + KeyCode.KEY_2 }
];
for (let i = 0; i < 9; i++) {
const queryIndex = i + 1;
let settingKey = `sql.query.shortcut${queryIndex}`;
let defaultVal = i < initialShortcuts.length ? initialShortcuts[i].name : '';
let defaultPrimary = i < initialShortcuts.length ? initialShortcuts[i].primary : null;
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: `workbench.action.query.shortcut${queryIndex}`,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: QueryEditorVisibleCondition,
primary: defaultPrimary,
handler: accessor => {
accessor.get(IInstantiationService).createInstance(RunQueryShortcutAction).run(queryIndex);
}
});
registryProperties[settingKey] = {
'type': 'string',
'default': defaultVal,
'description': localize('queryShortcutDescription',
'Set keybinding workbench.action.query.shortcut{0} to run the shortcut text as a procedure call. Any selected text in the query editor will be passed as a parameter',
queryIndex)
};
}
// Register the query-related configuration options
let configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigExtensions.Configuration);
configurationRegistry.registerConfiguration({
'id': 'sqlEditor',
'title': 'SQL Editor',
'type': 'object',
'properties': {
'sql.messagesDefaultOpen': {
'type': 'boolean',
'description': localize('sql.messagesDefaultOpen', 'True for the messages pane to be open by default; false for closed'),
'default': true
},
'sql.saveAsCsv.includeHeaders': {
'type': 'boolean',
'description': localize('sql.saveAsCsv.includeHeaders', '[Optional] When true, column headers are included when saving results as CSV'),
'default': true
},
'sql.copyIncludeHeaders': {
'type': 'boolean',
'description': localize('sql.copyIncludeHeaders', '[Optional] Configuration options for copying results from the Results View'),
'default': false
},
'sql.copyRemoveNewLine': {
'type': 'boolean',
'description': localize('sql.copyRemoveNewLine', '[Optional] Configuration options for copying multi-line results from the Results View'),
'default': true
},
'sql.showBatchTime': {
'type': 'boolean',
'description': localize('sql.showBatchTime', '[Optional] Should execution time be shown for individual batches'),
'default': false
},
'sql.intelliSense.enableIntelliSense': {
'type': 'boolean',
'default': true,
'description': localize('sql.intelliSense.enableIntelliSense', 'Should IntelliSense be enabled')
},
'sql.intelliSense.enableErrorChecking': {
'type': 'boolean',
'default': true,
'description': localize('sql.intelliSense.enableErrorChecking', 'Should IntelliSense error checking be enabled')
},
'sql.intelliSense.enableSuggestions': {
'type': 'boolean',
'default': true,
'description': localize('sql.intelliSense.enableSuggestions', 'Should IntelliSense suggestions be enabled')
},
'sql.intelliSense.enableQuickInfo': {
'type': 'boolean',
'default': true,
'description': localize('sql.intelliSense.enableQuickInfo', 'Should IntelliSense quick info be enabled')
},
'sql.intelliSense.lowerCaseSuggestions': {
'type': 'boolean',
'default': false,
'description': localize('sql.intelliSense.lowerCaseSuggestions', 'Should IntelliSense suggestions be lowercase')
}
}
'properties': registryProperties
});

View File

@@ -8,6 +8,8 @@ import { IConnectableInput } from 'sql/parts/connection/common/connectionManagem
import { IEditorOptions } from 'vs/platform/editor/common/editor';
import { QueryEditorService } from 'sql/parts/query/services/queryEditorService';
import URI from 'vs/base/common/uri';
export interface IQueryEditorOptions extends IEditorOptions {
// Tells IQueryEditorService.queryEditorCheck to not open this input in the QueryEditor.
@@ -32,4 +34,13 @@ export interface IQueryEditorService {
// Clears any QueryEditor data for the given URI held by this service
onQueryInputClosed(uri: string): void;
/**
* Handles updating of SQL files on a save as event. These need special consideration
* due to query results and other information being tied to the URI of the file
* @param {URI} oldResource URI of the file before the save as was completed
* @param {URI} newResource URI of the file after the save as operation was completed
* @memberof IQueryEditorService
*/
onSaveAsCompleted(oldResource: URI, newResource: URI): void;
}

View File

@@ -141,7 +141,7 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
public getEncoding(): string { return this._sql.getEncoding(); }
public suggestFileName(): string { return this._sql.suggestFileName(); }
public getName(): string { return this._sql.getName(); }
public hasAssociatedFilePath(): boolean { return this._sql.hasAssociatedFilePath; }
public get hasAssociatedFilePath(): boolean { return this._sql.hasAssociatedFilePath; }
public setEncoding(encoding: string, mode: EncodingMode /* ignored, we only have Encode */): void {
this._sql.setEncoding(encoding, mode);
@@ -158,6 +158,11 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
this.showQueryResultsEditor();
}
public runQueryString(text: string): void {
this._queryModelService.runQueryString(this.uri, text, this.uri, this);
this.showQueryResultsEditor();
}
public onConnectStart(): void {
this._runQueryEnabled = false;
this._cancelQueryEnabled = false;
@@ -189,6 +194,8 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
this.runQuery(selection);
} else if (params.runQueryOnCompletion === RunQueryOnConnectionMode.estimatedQueryPlan) {
this.runQuery(selection, { displayEstimatedQueryPlan: true });
} else if (params.runQueryOnCompletion === RunQueryOnConnectionMode.actualQueryPlan) {
this.runQuery(selection, { displayActualQueryPlan: true });
}
}
this._updateTaskbar.fire();
@@ -232,7 +239,6 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
this._sql.close();
this._results.close();
super.close();
}
/**

View File

@@ -20,7 +20,7 @@ export const IQueryManagementService = createDecorator<IQueryManagementService>(
export interface IQueryManagementService {
_serviceBrand: any;
addQueryRequestHandler(queryType: string, runner: QueryRequestHandler): IDisposable;
addQueryRequestHandler(queryType: string, runner: IQueryRequestHandler): IDisposable;
registerRunner(runner: QueryRunner, uri: string): void;
cancelQuery(ownerUri: string): Thenable<data.QueryCancelResult>;
@@ -57,7 +57,7 @@ export interface IQueryManagementService {
/*
* An object that can handle basic request-response actions related to queries
*/
export interface QueryRequestHandler {
export interface IQueryRequestHandler {
cancelQuery(ownerUri: string): Thenable<data.QueryCancelResult>;
runQuery(ownerUri: string, selection: data.ISelectionData, runOptions?: data.ExecutionPlanOptions): Thenable<void>;
runQueryStatement(ownerUri: string, line: number, column: number): Thenable<void>;
@@ -83,7 +83,7 @@ export class QueryManagementService implements IQueryManagementService {
public static readonly DefaultQueryType = 'MSSQL';
public _serviceBrand: any;
private _requestHandlers = new Map<string, QueryRequestHandler>();
private _requestHandlers = new Map<string, IQueryRequestHandler>();
// public for testing only
public _queryRunners = new Map<string, QueryRunner>();
@@ -132,7 +132,7 @@ export class QueryManagementService implements IQueryManagementService {
this.enqueueOrRun(sendNotification, runner);
}
public addQueryRequestHandler(queryType: string, handler: QueryRequestHandler): IDisposable {
public addQueryRequestHandler(queryType: string, handler: IQueryRequestHandler): IDisposable {
this._requestHandlers.set(queryType, handler);
return {
@@ -155,7 +155,7 @@ export class QueryManagementService implements IQueryManagementService {
TelemetryUtils.addTelemetry(this._telemetryService, eventName, data);
}
private _runAction<T>(uri: string, action: (handler: QueryRequestHandler) => Thenable<T>): Thenable<T> {
private _runAction<T>(uri: string, action: (handler: IQueryRequestHandler) => Thenable<T>): Thenable<T> {
let providerId: string = this._connectionService.getProviderIdFromUri(uri);
if (!providerId) {

View File

@@ -54,10 +54,6 @@ export class QueryResultsInput extends EditorInput {
return false;
}
public setVisibleTrue(): void {
this._visible = true;
}
public setBootstrappedTrue(): void {
this._hasBootstrapped = true;
}
@@ -102,6 +98,10 @@ export class QueryResultsInput extends EditorInput {
return this._visible;
}
set visible(visible: boolean) {
this._visible = visible;
}
get uri(): string {
return this._uri;
}