mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 11:38:36 -05:00
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { MainContext, MainThreadLanguagesShape, IMainContext } from './extHost.protocol';
|
|
import type * as vscode from 'vscode';
|
|
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
|
|
|
export class ExtHostLanguages {
|
|
|
|
private readonly _proxy: MainThreadLanguagesShape;
|
|
private readonly _documents: ExtHostDocuments;
|
|
|
|
constructor(
|
|
mainContext: IMainContext,
|
|
documents: ExtHostDocuments
|
|
) {
|
|
this._proxy = mainContext.getProxy(MainContext.MainThreadLanguages);
|
|
this._documents = documents;
|
|
}
|
|
|
|
getLanguages(): Promise<string[]> {
|
|
return this._proxy.$getLanguages();
|
|
}
|
|
|
|
async changeLanguage(uri: vscode.Uri, languageId: string): Promise<vscode.TextDocument> {
|
|
await this._proxy.$changeLanguage(uri, languageId);
|
|
const data = this._documents.getDocumentData(uri);
|
|
if (!data) {
|
|
throw new Error(`document '${uri.toString}' NOT found`);
|
|
}
|
|
return data.document;
|
|
}
|
|
}
|