mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
Merge from vscode e3c4990c67c40213af168300d1cfeb71d680f877 (#16569)
This commit is contained in:
@@ -1,30 +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 { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { Extensions as ILanguageAssociationExtensions, ILanguageAssociationRegistry } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
|
||||
const languageRegistry = Registry.as<ILanguageAssociationRegistry>(ILanguageAssociationExtensions.LanguageAssociations);
|
||||
|
||||
export function doHandleUpgrade(editor?: EditorInput): EditorInput | undefined {
|
||||
if (editor instanceof UntitledTextEditorInput || editor instanceof FileEditorInput) {
|
||||
let language: string | undefined;
|
||||
if (editor instanceof UntitledTextEditorInput) {
|
||||
language = editor.getMode();
|
||||
} else {
|
||||
language = editor.getPreferredMode();
|
||||
}
|
||||
if (language) {
|
||||
const association = languageRegistry.getAssociationForLanguage(language);
|
||||
if (association && association.syncConvertinput) {
|
||||
return association.syncConvertinput(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IEditorInput, EditorInput } from 'vs/workbench/common/editor';
|
||||
import { IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
||||
import { ServicesAccessor, IInstantiationService, BrandedService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
@@ -13,11 +14,7 @@ export type BaseInputCreator = (activeEditor: IEditorInput) => IEditorInput;
|
||||
|
||||
export interface ILanguageAssociation {
|
||||
convertInput(activeEditor: IEditorInput): Promise<EditorInput | undefined> | EditorInput | undefined;
|
||||
/**
|
||||
* Used for scenarios when we need to synchrounly create inputs, currently only for handling upgrades
|
||||
* and planned to be removed eventually
|
||||
*/
|
||||
syncConvertinput?(activeEditor: IEditorInput): EditorInput | undefined;
|
||||
syncConvertInput?(activeEditor: IEditorInput): EditorInput | undefined;
|
||||
createBase(activeEditor: IEditorInput): IEditorInput;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user