editorReplacer -> editorOverride (#16041)

* editorReplacer -> editorOverride

* Update lifecycle phsae

* add back input factories

* Add comment

* add back tests

* comments

* fix log

* comments
This commit is contained in:
Charles Gagnon
2021-07-09 08:46:50 -07:00
committed by GitHub
parent 7ba0e49673
commit 8f202d91b6
19 changed files with 253 additions and 509 deletions

View File

@@ -25,6 +25,10 @@ type ILanguageAssociationSignature<Services extends BrandedService[]> = new (...
export interface ILanguageAssociationRegistry {
registerLanguageAssociation<Services extends BrandedService[]>(languages: string[], contribution: ILanguageAssociationSignature<Services>, isDefault?: boolean): IDisposable;
/**
* Gets the registered association for a language if one is registered
* @param language The case-insensitive language ID to get the association for
*/
getAssociationForLanguage(language: string): ILanguageAssociation | undefined;
readonly defaultAssociation: [string, ILanguageAssociation] | undefined;
@@ -54,6 +58,7 @@ const languageAssociationRegistry = new class implements ILanguageAssociationReg
}
registerLanguageAssociation(languages: string[], contribution: ILanguageAssociationSignature<BrandedService[]>, isDefault?: boolean): IDisposable {
languages = languages.map(lang => lang.toLowerCase());
for (const language of languages) {
this.associationContructors.set(language, contribution);
}
@@ -71,7 +76,7 @@ const languageAssociationRegistry = new class implements ILanguageAssociationReg
}
getAssociationForLanguage(language: string): ILanguageAssociation | undefined {
return this.associationsInstances.get(language);
return this.associationsInstances.get(language.toLowerCase());
}
get defaultAssociation(): [string, ILanguageAssociation] | undefined {

View File

@@ -5,7 +5,7 @@
import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResultsInput';
import { EditDataInput } from 'sql/workbench/browser/editData/editDataInput';
import { IConnectableInput, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { ConnectionType, IConnectableInput, IConnectionCompletionOptions, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { IQueryEditorService, INewSqlEditorOptions } from 'sql/workbench/services/queryEditor/common/queryEditorService';
import { UntitledQueryEditorInput } from 'sql/workbench/common/editor/query/untitledQueryEditorInput';
@@ -20,7 +20,10 @@ import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/u
import { UntitledTextEditorModel } from 'vs/workbench/services/untitled/common/untitledTextEditorModel';
import { mixin } from 'vs/base/common/objects';
import { IQueryEditorConfiguration } from 'sql/platform/query/common/query';
import { getCurrentGlobalConnection } from 'sql/workbench/browser/taskUtilities';
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
import { onUnexpectedError } from 'vs/base/common/errors';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
const defaults: INewSqlEditorOptions = {
open: true
};
@@ -37,7 +40,8 @@ export class QueryEditorService implements IQueryEditorService {
@IInstantiationService private _instantiationService: IInstantiationService,
@IEditorService private _editorService: IEditorService,
@IConfigurationService private _configurationService: IConfigurationService,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService
) {
}
@@ -63,10 +67,25 @@ export class QueryEditorService implements IQueryEditorService {
const queryResultsInput: QueryResultsInput = this._instantiationService.createInstance(QueryResultsInput, docUri.toString());
let queryInput = this._instantiationService.createInstance(UntitledQueryEditorInput, options.description, fileInput, queryResultsInput);
let profile: IConnectionProfile | undefined = undefined;
// If we're told to connect then get the connection before opening the editor since it will try to get the connection for the current
// active editor and so we need to get this before opening a new one.
if (options.connectWithGlobal) {
profile = getCurrentGlobalConnection(this._objectExplorerService, this._connectionManagementService, this._editorService);
}
if (options.open) {
await this._editorService.openEditor(queryInput, { pinned: true });
}
if (profile) {
const options: IConnectionCompletionOptions = {
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: undefined, input: queryInput },
saveTheConnection: false,
showDashboard: false,
showConnectionDialogOnError: true,
showFirewallRuleOnError: true
};
this._connectionManagementService.connect(profile, queryInput.uri, options).catch(err => onUnexpectedError(err));
}
return queryInput;
}

View File

@@ -32,6 +32,11 @@ export interface INewSqlEditorOptions {
* use an existing resource, if this matches a resource already open that resource will be opened instead
*/
resource?: URI
/**
* Whether to connect the editor using the current global connection
*/
connectWithGlobal?: boolean
}
export interface IQueryEditorService {