mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
strict null check contrib/editorReplace and services/queryEditor (#12166)
This commit is contained in:
@@ -50,7 +50,7 @@ export class EditDataInput extends EditorInput implements IConnectableInput {
|
|||||||
super();
|
super();
|
||||||
this._hasBootstrapped = false;
|
this._hasBootstrapped = false;
|
||||||
this._updateTaskbar = new Emitter<EditDataInput>();
|
this._updateTaskbar = new Emitter<EditDataInput>();
|
||||||
this._showResultsEditor = new Emitter<EditDataInput>();
|
this._showResultsEditor = new Emitter<EditDataInput | undefined>();
|
||||||
this._editorInitializing = new Emitter<boolean>();
|
this._editorInitializing = new Emitter<boolean>();
|
||||||
this._setup = false;
|
this._setup = false;
|
||||||
this._stopButtonEnabled = false;
|
this._stopButtonEnabled = false;
|
||||||
@@ -86,7 +86,7 @@ export class EditDataInput extends EditorInput implements IConnectableInput {
|
|||||||
this._register(
|
this._register(
|
||||||
this._queryModelService.onEditSessionReady((result) => {
|
this._queryModelService.onEditSessionReady((result) => {
|
||||||
if (this.uri === result.ownerUri) {
|
if (this.uri === result.ownerUri) {
|
||||||
this._results.editDataGridPanel.onRefreshComplete.then(() => {
|
this._results.editDataGridPanel!.onRefreshComplete.then(() => {
|
||||||
this.initEditEnd(result);
|
this.initEditEnd(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ export class EditDataInput extends EditorInput implements IConnectableInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public resolve(refresh?: boolean): Promise<IUntitledTextEditorModel & IResolvedTextEditorModel> { return this._sql.resolve(); }
|
public resolve(refresh?: boolean): Promise<IUntitledTextEditorModel & IResolvedTextEditorModel> { return this._sql.resolve(); }
|
||||||
public getEncoding(): string { return this._sql.getEncoding(); }
|
public getEncoding(): string | undefined { return this._sql.getEncoding(); }
|
||||||
public getName(): string { return this._sql.getName(); }
|
public getName(): string { return this._sql.getName(); }
|
||||||
public get hasAssociatedFilePath(): boolean { return this._sql.model.hasAssociatedFilePath; }
|
public get hasAssociatedFilePath(): boolean { return this._sql.model.hasAssociatedFilePath; }
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export class EditDataResultsInput extends EditorInput {
|
|||||||
|
|
||||||
public readonly onRestoreViewStateEmitter = new Emitter<void>();
|
public readonly onRestoreViewStateEmitter = new Emitter<void>();
|
||||||
public readonly onSaveViewStateEmitter = new Emitter<void>();
|
public readonly onSaveViewStateEmitter = new Emitter<void>();
|
||||||
private _editDataGridPanel: IGridPanel;
|
private _editDataGridPanel?: IGridPanel;
|
||||||
|
|
||||||
constructor(private _uri: string) {
|
constructor(private _uri: string) {
|
||||||
super();
|
super();
|
||||||
@@ -37,11 +37,11 @@ export class EditDataResultsInput extends EditorInput {
|
|||||||
this._hasBootstrapped = false;
|
this._hasBootstrapped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get editDataGridPanel(): IGridPanel {
|
get editDataGridPanel(): IGridPanel | undefined {
|
||||||
return this._editDataGridPanel;
|
return this._editDataGridPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
set editDataGridPanel(gridPanel: IGridPanel) {
|
set editDataGridPanel(gridPanel: IGridPanel | undefined) {
|
||||||
this._editDataGridPanel = gridPanel;
|
this._editDataGridPanel = gridPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export abstract class QueryEditorInput extends EditorInput implements IConnectab
|
|||||||
public get state(): QueryEditorState { return this._state; }
|
public get state(): QueryEditorState { return this._state; }
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _description: string,
|
private _description: string | undefined,
|
||||||
protected _text: AbstractTextResourceEditorInput,
|
protected _text: AbstractTextResourceEditorInput,
|
||||||
protected _results: QueryResultsInput,
|
protected _results: QueryResultsInput,
|
||||||
@IConnectionManagementService private readonly connectionManagementService: IConnectionManagementService,
|
@IConnectionManagementService private readonly connectionManagementService: IConnectionManagementService,
|
||||||
@@ -173,7 +173,7 @@ export abstract class QueryEditorInput extends EditorInput implements IConnectab
|
|||||||
public get text(): AbstractTextResourceEditorInput { return this._text; }
|
public get text(): AbstractTextResourceEditorInput { return this._text; }
|
||||||
public get results(): QueryResultsInput { return this._results; }
|
public get results(): QueryResultsInput { return this._results; }
|
||||||
// Description is shown beside the tab name in the combobox of open editors
|
// Description is shown beside the tab name in the combobox of open editors
|
||||||
public getDescription(): string { return this._description; }
|
public getDescription(): string | undefined { return this._description; }
|
||||||
public supportsSplitEditor(): boolean { return false; }
|
public supportsSplitEditor(): boolean { return false; }
|
||||||
public revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {
|
public revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {
|
||||||
return this._text.revert(group, options);
|
return this._text.revert(group, options);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class UntitledQueryEditorInput extends QueryEditorInput implements IEncod
|
|||||||
public static readonly ID = 'workbench.editorInput.untitledQueryInput';
|
public static readonly ID = 'workbench.editorInput.untitledQueryInput';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
description: string,
|
description: string | undefined,
|
||||||
text: UntitledTextEditorInput,
|
text: UntitledTextEditorInput,
|
||||||
results: QueryResultsInput,
|
results: QueryResultsInput,
|
||||||
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import * as path from 'vs/base/common/path';
|
|||||||
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 { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||||
import { isThenable } from 'vs/base/common/async';
|
import { isThenable } from 'vs/base/common/async';
|
||||||
|
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||||
|
|
||||||
const languageAssociationRegistry = Registry.as<ILanguageAssociationRegistry>(LanguageAssociationExtensions.LanguageAssociations);
|
const languageAssociationRegistry = Registry.as<ILanguageAssociationRegistry>(LanguageAssociationExtensions.LanguageAssociations);
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ export class EditorReplacementContribution implements IWorkbenchContribution {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
let language: string;
|
let language: string | undefined;
|
||||||
if (editor instanceof FileEditorInput) {
|
if (editor instanceof FileEditorInput) {
|
||||||
language = editor.getPreferredMode();
|
language = editor.getPreferredMode();
|
||||||
} else if (editor instanceof UntitledTextEditorInput) {
|
} else if (editor instanceof UntitledTextEditorInput) {
|
||||||
@@ -52,7 +53,7 @@ export class EditorReplacementContribution implements IWorkbenchContribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!language) { // in the case the input doesn't have a preferred mode set we will attempt to guess the mode from the file path
|
if (!language) { // in the case the input doesn't have a preferred mode set we will attempt to guess the mode from the file path
|
||||||
language = this.modeService.getModeIdByFilepathOrFirstLine(editor.resource);
|
language = withNullAsUndefined(this.modeService.getModeIdByFilepathOrFirstLine(editor.resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!language) {
|
if (!language) {
|
||||||
@@ -66,7 +67,7 @@ export class EditorReplacementContribution implements IWorkbenchContribution {
|
|||||||
editor.setMode(defaultInputCreator[0]);
|
editor.setMode(defaultInputCreator[0]);
|
||||||
const newInput = defaultInputCreator[1].convertInput(editor);
|
const newInput = defaultInputCreator[1].convertInput(editor);
|
||||||
if (newInput) {
|
if (newInput) {
|
||||||
return { override: isThenable(newInput) ? newInput.then(input => this.editorService.openEditor(input, options, group)) : this.editorService.openEditor(newInput, options, group) };
|
return { override: isThenable(newInput) ? newInput.then(input => this.editorService.openEditor(input ?? editor, options, group)) : this.editorService.openEditor(newInput, options, group) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -74,7 +75,7 @@ export class EditorReplacementContribution implements IWorkbenchContribution {
|
|||||||
if (inputCreator) {
|
if (inputCreator) {
|
||||||
const newInput = inputCreator.convertInput(editor);
|
const newInput = inputCreator.convertInput(editor);
|
||||||
if (newInput) {
|
if (newInput) {
|
||||||
return { override: isThenable(newInput) ? newInput.then(input => this.editorService.openEditor(input, options, group)) : this.editorService.openEditor(newInput, options, group) };
|
return { override: isThenable(newInput) ? newInput.then(input => this.editorService.openEditor(input ?? editor, options, group)) : this.editorService.openEditor(newInput, options, group) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
|||||||
export interface IEditorDescriptorService {
|
export interface IEditorDescriptorService {
|
||||||
_serviceBrand: undefined;
|
_serviceBrand: undefined;
|
||||||
|
|
||||||
getEditor(input: EditorInput): IEditorDescriptor;
|
getEditor(input: EditorInput): IEditorDescriptor | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class EditorDescriptorService implements IEditorDescriptorService {
|
export class EditorDescriptorService implements IEditorDescriptorService {
|
||||||
@@ -21,7 +21,7 @@ export class EditorDescriptorService implements IEditorDescriptorService {
|
|||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getEditor(input: EditorInput): IEditorDescriptor {
|
public getEditor(input: EditorInput): IEditorDescriptor | undefined {
|
||||||
return Registry.as<IEditorRegistry>(Extensions.Editors).getEditor(input);
|
return Registry.as<IEditorRegistry>(Extensions.Editors).getEditor(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ export class QueryEditorService implements IQueryEditorService {
|
|||||||
|
|
||||||
// Create a sql document pane with accoutrements
|
// Create a sql document pane with accoutrements
|
||||||
const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: this._connectionManagementService.getProviderLanguageMode(connectionProviderName) }) as UntitledTextEditorInput;
|
const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: this._connectionManagementService.getProviderLanguageMode(connectionProviderName) }) as UntitledTextEditorInput;
|
||||||
let untitledEditorModel = await fileInput.resolve() as UntitledTextEditorModel;
|
let untitledEditorModel = await fileInput.resolve();
|
||||||
if (options.initalContent) {
|
if (options.initalContent) {
|
||||||
untitledEditorModel.textEditorModel.setValue(options.initalContent);
|
untitledEditorModel.textEditorModel.setValue(options.initalContent);
|
||||||
if (options.dirty === false || (options.dirty === undefined && !this._configurationService.getValue<IQueryEditorConfiguration>('queryEditor').promptToSaveGeneratedFiles)) {
|
if (options.dirty === false || (options.dirty === undefined && !this._configurationService.getValue<IQueryEditorConfiguration>('queryEditor').promptToSaveGeneratedFiles)) {
|
||||||
untitledEditorModel.setDirty(false);
|
(untitledEditorModel as UntitledTextEditorModel).setDirty(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,9 +82,9 @@ export class QueryEditorService implements IQueryEditorService {
|
|||||||
|
|
||||||
// Create a sql document pane with accoutrements
|
// Create a sql document pane with accoutrements
|
||||||
const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: 'sql' }) as UntitledTextEditorInput;
|
const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: 'sql' }) as UntitledTextEditorInput;
|
||||||
const m = await fileInput.resolve() as UntitledTextEditorModel;
|
const m = await fileInput.resolve();
|
||||||
//when associatedResource editor is created it is dirty, this must be set to false to be able to detect changes to the editor.
|
//when associatedResource editor is created it is dirty, this must be set to false to be able to detect changes to the editor.
|
||||||
m.setDirty(false);
|
(m as UntitledTextEditorModel).setDirty(false);
|
||||||
// Create an EditDataInput for editing
|
// Create an EditDataInput for editing
|
||||||
const resultsInput: EditDataResultsInput = this._instantiationService.createInstance(EditDataResultsInput, docUri.toString());
|
const resultsInput: EditDataResultsInput = this._instantiationService.createInstance(EditDataResultsInput, docUri.toString());
|
||||||
let editDataInput: EditDataInput = this._instantiationService.createInstance(EditDataInput, docUri, schemaName, tableName, fileInput, sqlContent, resultsInput);
|
let editDataInput: EditDataInput = this._instantiationService.createInstance(EditDataInput, docUri, schemaName, tableName, fileInput, sqlContent, resultsInput);
|
||||||
@@ -94,7 +94,7 @@ export class QueryEditorService implements IQueryEditorService {
|
|||||||
//Setting the value of the textEditorModel to sqlContent marks editor as dirty, editDataInput handles it.
|
//Setting the value of the textEditorModel to sqlContent marks editor as dirty, editDataInput handles it.
|
||||||
m.textEditorModel.setValue(sqlContent);
|
m.textEditorModel.setValue(sqlContent);
|
||||||
}
|
}
|
||||||
const editor = await this._editorService.openEditor(editDataInput, { pinned: true });
|
const editor = (await this._editorService.openEditor(editDataInput, { pinned: true }))!;
|
||||||
let params = editor.input as EditDataInput;
|
let params = editor.input as EditDataInput;
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,6 @@
|
|||||||
"./sql/workbench/contrib/dashboard/**/*.ts", // 1015 errors
|
"./sql/workbench/contrib/dashboard/**/*.ts", // 1015 errors
|
||||||
"./sql/workbench/contrib/dataExplorer/**/*.ts", // 2667 errors
|
"./sql/workbench/contrib/dataExplorer/**/*.ts", // 2667 errors
|
||||||
"./sql/workbench/contrib/editData/**/*.ts", // 441 errors
|
"./sql/workbench/contrib/editData/**/*.ts", // 441 errors
|
||||||
"./sql/workbench/contrib/editorReplacement/**/*.ts", // 6 errors
|
|
||||||
"./sql/workbench/contrib/editorReplacement/test/**/*.ts",
|
"./sql/workbench/contrib/editorReplacement/test/**/*.ts",
|
||||||
"./sql/workbench/contrib/jobManagement/**/*.ts", // 315 errors
|
"./sql/workbench/contrib/jobManagement/**/*.ts", // 315 errors
|
||||||
"./sql/workbench/contrib/modelView/**/*.ts", // 2646 errors
|
"./sql/workbench/contrib/modelView/**/*.ts", // 2646 errors
|
||||||
@@ -92,7 +91,6 @@
|
|||||||
"./sql/workbench/services/notebook/**/*.ts", // 200 errors
|
"./sql/workbench/services/notebook/**/*.ts", // 200 errors
|
||||||
"./sql/workbench/services/objectExplorer/**/*.ts", // 185 errors
|
"./sql/workbench/services/objectExplorer/**/*.ts", // 185 errors
|
||||||
"./sql/workbench/services/query/test/**/*.ts",
|
"./sql/workbench/services/query/test/**/*.ts",
|
||||||
"./sql/workbench/services/queryEditor/**/*.ts", // 10 errors
|
|
||||||
"./sql/workbench/services/queryEditor/test/**/*.ts",
|
"./sql/workbench/services/queryEditor/test/**/*.ts",
|
||||||
"./sql/workbench/test/**/*.ts", // 2975 errors
|
"./sql/workbench/test/**/*.ts", // 2975 errors
|
||||||
"./sql/workbench/update/**/*.ts", // 2646 errors
|
"./sql/workbench/update/**/*.ts", // 2646 errors
|
||||||
|
|||||||
Reference in New Issue
Block a user