debt - change the implementation of vscode.languages.getLanguages to not send an IPC message but to read from a sync'd state which gets pushed into the exthost

This commit is contained in:
Johannes Rieken
2021-08-31 16:46:09 +02:00
parent 85a81276e8
commit db5aab03b6
4 changed files with 29 additions and 13 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { MainContext, MainThreadLanguagesShape, IMainContext } from './extHost.protocol';
import { MainContext, MainThreadLanguagesShape, IMainContext, ExtHostLanguagesShape } from './extHost.protocol';
import type * as vscode from 'vscode';
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
import * as typeConvert from 'vs/workbench/api/common/extHostTypeConverters';
@@ -14,10 +14,12 @@ import { DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { CommandsConverter } from 'vs/workbench/api/common/extHostCommands';
export class ExtHostLanguages {
export class ExtHostLanguages implements ExtHostLanguagesShape {
private readonly _proxy: MainThreadLanguagesShape;
private _languageIds: string[] = [];
constructor(
mainContext: IMainContext,
private readonly _documents: ExtHostDocuments,
@@ -26,8 +28,12 @@ export class ExtHostLanguages {
this._proxy = mainContext.getProxy(MainContext.MainThreadLanguages);
}
getLanguages(): Promise<string[]> {
return this._proxy.$getLanguages();
$acceptLanguageIds(ids: string[]): void {
this._languageIds = ids;
}
async getLanguages(): Promise<string[]> {
return this._languageIds.slice(0);
}
async changeLanguage(uri: vscode.Uri, languageId: string): Promise<vscode.TextDocument> {