Merge from vscode e3c4990c67c40213af168300d1cfeb71d680f877 (#16569)

This commit is contained in:
Cory Rivera
2021-08-25 16:28:29 -07:00
committed by GitHub
parent ab1112bfb3
commit cb7b7da0a4
1752 changed files with 59525 additions and 33878 deletions

View File

@@ -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;
}

View File

@@ -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;
}