More Layering (#9139)

* move handling generated files to the serilization classes

* remove unneeded methods

* add more folders to strictire compile, add more strict compile options

* update ci

* wip

* add more layering and fix issues

* add more strictness

* remove unnecessary assertion

* add missing checks

* fix indentation

* wip

* remove jsdoc

* fix layering

* fix compile

* fix compile errors

* wip

* wip

* finish layering

* fix css

* more layering

* rip

* reworking results serializer

* move some files around

* move capabilities to platform wip

* implement capabilities register provider

* fix capabilities service

* fix usage of the regist4ry

* add contribution

* wip

* wip

* wip

* remove no longer good parts

* fix strict-nulls

* fix issues with startup

* another try

* fix startup

* fix imports

* fix tests

* fix tests

* fix more tests

* fix tests

* fix more tests

* fix broken test

* fix tabbing

* fix naming

* wip

* finished layering

* fix imports

* fix valid layers

* fix layers
This commit is contained in:
Anthony Dresser
2020-02-15 01:54:23 -06:00
committed by GitHub
parent 873c6a39fe
commit 506c6a5e5f
338 changed files with 815 additions and 724 deletions

View File

@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import { EditDataEditor } from 'sql/workbench/contrib/editData/browser/editDataEditor';
import { EditDataInput } from 'sql/workbench/contrib/editData/browser/editDataInput';
import { EditDataInput } from 'sql/workbench/browser/editData/editDataInput';
import { EditDataResultsEditor } from 'sql/workbench/contrib/editData/browser/editDataResultsEditor';
import { EditDataResultsInput } from 'sql/workbench/contrib/editData/browser/editDataResultsInput';
import { EditDataResultsInput } from 'sql/workbench/browser/editData/editDataResultsInput';
import { EditorDescriptor, IEditorRegistry, Extensions } from 'vs/workbench/browser/editor';
import { Registry } from 'vs/platform/registry/common/platform';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';

View File

@@ -14,7 +14,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { EditDataInput } from 'sql/workbench/contrib/editData/browser/editDataInput';
import { EditDataInput } from 'sql/workbench/browser/editData/editDataInput';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import * as queryContext from 'sql/workbench/contrib/query/common/queryContext';
@@ -32,7 +32,7 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
import { IFlexibleSash, HorizontalFlexibleSash } from 'sql/workbench/contrib/query/browser/flexibleSash';
import { EditDataResultsEditor } from 'sql/workbench/contrib/editData/browser/editDataResultsEditor';
import { EditDataResultsInput } from 'sql/workbench/contrib/editData/browser/editDataResultsInput';
import { EditDataResultsInput } from 'sql/workbench/browser/editData/editDataResultsInput';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
@@ -274,7 +274,7 @@ export class EditDataEditor extends BaseEditor {
if (!input.results.container) {
this._resultsEditorContainer = DOM.append(parentElement, DOM.$('.editDataContainer-horizontal'));
input.results.container = this._resultsEditorContainer;
input.results.setContainer(this._resultsEditorContainer);
} else {
this._resultsEditorContainer = DOM.append(parentElement, input.results.container);
}

View File

@@ -1,235 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { EditorInput, EncodingMode, IEditorInput } from 'vs/workbench/common/editor';
import { IConnectionManagementService, IConnectableInput, INewConnectionParams } from 'sql/platform/connection/common/connectionManagement';
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
import { Event, Emitter } from 'vs/base/common/event';
import { EditSessionReadyParams } from 'azdata';
import { URI } from 'vs/base/common/uri';
import * as nls from 'vs/nls';
import { INotificationService } from 'vs/platform/notification/common/notification';
import Severity from 'vs/base/common/severity';
import { EditDataResultsInput } from 'sql/workbench/contrib/editData/browser/editDataResultsInput';
import { IEditorViewState } from 'vs/editor/common/editorCommon';
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
import { IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
import { IUntitledTextEditorModel, UntitledTextEditorModel } from 'vs/workbench/services/untitled/common/untitledTextEditorModel';
/**
* Input for the EditDataEditor.
*/
export class EditDataInput extends EditorInput implements IConnectableInput {
public static ID: string = 'workbench.editorinputs.editDataInput';
private _hasBootstrapped: boolean;
private _editorContainer: HTMLElement;
private _updateTaskbar: Emitter<EditDataInput>;
private _editorInitializing: Emitter<boolean>;
private _showResultsEditor: Emitter<EditDataInput>;
private _refreshButtonEnabled: boolean;
private _stopButtonEnabled: boolean;
private _setup: boolean;
private _rowLimit: number;
private _objectType: string;
private _css: HTMLStyleElement;
private _useQueryFilter: boolean;
public savedViewState: IEditorViewState;
constructor(
private _uri: URI,
private _schemaName: string,
private _tableName: string,
private _sql: UntitledTextEditorInput,
private _queryString: string,
private _results: EditDataResultsInput,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
@IQueryModelService private _queryModelService: IQueryModelService,
@INotificationService private notificationService: INotificationService
) {
super();
this._hasBootstrapped = false;
this._updateTaskbar = new Emitter<EditDataInput>();
this._showResultsEditor = new Emitter<EditDataInput>();
this._editorInitializing = new Emitter<boolean>();
this._setup = false;
this._stopButtonEnabled = false;
this._refreshButtonEnabled = false;
this._useQueryFilter = false;
// re-emit sql editor events through this editor if it exists.
// also set dirty status to false to prevent rerendering.
if (this._sql) {
this._register(this._sql.onDidChangeDirty(async () => {
const model = await this._sql.resolve() as UntitledTextEditorModel;
model.setDirty(false);
this._onDidChangeDirty.fire();
}));
}
//TODO determine is this is a table or a view
this._objectType = 'TABLE';
// Attach to event callbacks
if (this._queryModelService) {
let self = this;
// Register callbacks for the Actions
this._register(
this._queryModelService.onRunQueryStart(uri => {
if (self.uri === uri) {
self.initEditStart();
}
})
);
this._register(
this._queryModelService.onEditSessionReady((result) => {
if (self.uri === result.ownerUri) {
self.initEditEnd(result);
}
})
);
}
}
// Getters/Setters
public get tableName(): string { return this._tableName; }
public get schemaName(): string { return this._schemaName; }
public get uri(): string { return unescape(this._uri.toString()); }
public get sql(): UntitledTextEditorInput { return this._sql; }
public get results(): EditDataResultsInput { return this._results; }
public getResultsInputResource(): string { return this._results.uri; }
public get updateTaskbarEvent(): Event<EditDataInput> { return this._updateTaskbar.event; }
public get editorInitializingEvent(): Event<boolean> { return this._editorInitializing.event; }
public get showResultsEditorEvent(): Event<EditDataInput> { return this._showResultsEditor.event; }
public get stopButtonEnabled(): boolean { return this._stopButtonEnabled; }
public get refreshButtonEnabled(): boolean { return this._refreshButtonEnabled; }
public get container(): HTMLElement { return this._editorContainer; }
public get hasBootstrapped(): boolean { return this._hasBootstrapped; }
public get setup(): boolean { return this._setup; }
public get rowLimit(): number { return this._rowLimit; }
public get objectType(): string { return this._objectType; }
public showResultsEditor(): void { this._showResultsEditor.fire(undefined); }
public isDirty(): boolean { return false; }
public save(): Promise<IEditorInput | undefined> { return Promise.resolve(undefined); }
public getTypeId(): string { return EditDataInput.ID; }
public setBootstrappedTrue(): void { this._hasBootstrapped = true; }
public getResource(): URI { return this._uri; }
public supportsSplitEditor(): boolean { return false; }
public setupComplete() { this._setup = true; }
public get queryString(): string {
return this._queryString;
}
public set queryString(queryString: string) {
this._queryString = queryString;
}
public get css(): HTMLStyleElement {
return this._css;
}
public set css(css: HTMLStyleElement) {
this._css = css;
}
public get queryPaneEnabled(): boolean {
return this._useQueryFilter;
}
public set queryPaneEnabled(useQueryFilter: boolean) {
this._useQueryFilter = useQueryFilter;
}
// State Update Callbacks
public initEditStart(): void {
this._editorInitializing.fire(true);
this._refreshButtonEnabled = false;
this._stopButtonEnabled = true;
this._updateTaskbar.fire(this);
}
public initEditEnd(result: EditSessionReadyParams): void {
this._refreshButtonEnabled = true;
this._stopButtonEnabled = false;
if (!result.success) {
this.notificationService.notify({
severity: Severity.Error,
message: result.message
});
}
this._editorInitializing.fire(false);
this._updateTaskbar.fire(this);
}
public onConnectStart(): void {
// TODO: Indicate connection started
}
public onConnectReject(error?: string): void {
if (error) {
this.notificationService.notify({
severity: Severity.Error,
message: nls.localize('connectionFailure', "Edit Data Session Failed To Connect")
});
}
}
public onConnectCanceled(): void {
}
public onConnectSuccess(params?: INewConnectionParams): void {
let rowLimit: number = undefined;
let queryString: string = undefined;
if (this._useQueryFilter) {
queryString = this._queryString;
} else {
rowLimit = this._rowLimit;
}
this._queryModelService.initializeEdit(this.uri, this.schemaName, this.tableName, this._objectType, rowLimit, queryString);
this.showResultsEditor();
this._onDidChangeLabel.fire();
}
public onDisconnect(): void {
// TODO: deal with disconnections
}
public onRowDropDownSet(rows: number) {
this._rowLimit = rows;
}
// Boiler Plate Functions
public matches(otherInput: any): boolean {
if (otherInput instanceof EditDataInput) {
return this._sql.matches(otherInput.sql);
}
return this._sql.matches(otherInput);
}
public dispose(): void {
// Dispose our edit session then disconnect our input
this._queryModelService.disposeEdit(this.uri).then(() => {
return this._connectionManagementService.disconnectEditor(this, true);
});
this._queryModelService.disposeQuery(this.uri);
this._sql.dispose();
this._results.dispose();
super.dispose();
}
public get tabColor(): string {
return this._connectionManagementService.getTabColorForUri(this.uri);
}
public resolve(refresh?: boolean): Promise<IUntitledTextEditorModel & IResolvedTextEditorModel> { return this._sql.resolve(); }
public getEncoding(): string { return this._sql.getEncoding(); }
public getName(): string { return this._sql.getName(); }
public get hasAssociatedFilePath(): boolean { return this._sql.model.hasAssociatedFilePath; }
public setEncoding(encoding: string, mode: EncodingMode /* ignored, we only have Encode */): void {
this._sql.setEncoding(encoding, mode);
}
}

View File

@@ -17,7 +17,7 @@ import * as types from 'vs/base/common/types';
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
import { BareResultsGridInfo, getBareResultsGridInfoStyles } from 'sql/workbench/contrib/query/browser/queryResultsEditor';
import { EditDataGridPanel } from 'sql/workbench/contrib/editData/browser/editDataGridPanel';
import { EditDataResultsInput } from 'sql/workbench/contrib/editData/browser/editDataResultsInput';
import { EditDataResultsInput } from 'sql/workbench/browser/editData/editDataResultsInput';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IStorageService } from 'vs/platform/storage/common/storage';

View File

@@ -1,105 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { EditorInput } from 'vs/workbench/common/editor';
import { Emitter } from 'vs/base/common/event';
/**
* Input for the EditDataResultsEditor. This input helps with logic for the viewing and editing of
* data in the results grid.
*/
export class EditDataResultsInput extends EditorInput {
// Tracks if the editor that holds this input should be visible (i.e. true if a query has been run)
private _visible: boolean;
// Tracks if the editor has holds this input has has bootstrapped angular yet
private _hasBootstrapped: boolean;
// Holds the HTML content for the editor when the editor discards this input and loads another
private _editorContainer: HTMLElement;
public css: HTMLStyleElement;
public readonly onRestoreViewStateEmitter = new Emitter<void>();
public readonly onSaveViewStateEmitter = new Emitter<void>();
constructor(private _uri: string) {
super();
this._visible = false;
this._hasBootstrapped = false;
}
getTypeId(): string {
return EditDataResultsInput.ID;
}
matches(other: any): boolean {
if (other instanceof EditDataResultsInput) {
return (other._uri === this._uri);
}
return false;
}
resolve(refresh?: boolean): Promise<any> {
return Promise.resolve(null);
}
supportsSplitEditor(): boolean {
return false;
}
public setBootstrappedTrue(): void {
this._hasBootstrapped = true;
}
public dispose(): void {
this._disposeContainer();
super.dispose();
}
private _disposeContainer() {
if (!this._editorContainer) {
return;
}
let parentContainer = this._editorContainer.parentNode;
if (parentContainer) {
parentContainer.removeChild(this._editorContainer);
this._editorContainer = null;
}
}
//// Properties
static get ID() {
return 'workbench.editorinputs.editDataResultsInput';
}
set container(container: HTMLElement) {
this._disposeContainer();
this._editorContainer = container;
}
get container(): HTMLElement {
return this._editorContainer;
}
get hasBootstrapped(): boolean {
return this._hasBootstrapped;
}
get visible(): boolean {
return this._visible;
}
set visible(visible: boolean) {
this._visible = visible;
}
get uri(): string {
return unescape(this._uri);
}
}