mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
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:
@@ -157,6 +157,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
const extHostTreeViews = rpcProtocol.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(rpcProtocol.getProxy(MainContext.MainThreadTreeViews), extHostCommands, extHostLogService));
|
||||
const extHostEditorInsets = rpcProtocol.set(ExtHostContext.ExtHostEditorInsets, new ExtHostEditorInsets(rpcProtocol.getProxy(MainContext.MainThreadEditorInsets), extHostEditors, initData));
|
||||
const extHostDiagnostics = rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, new ExtHostDiagnostics(rpcProtocol, extHostLogService, extHostFileSystemInfo));
|
||||
const extHostLanguages = rpcProtocol.set(ExtHostContext.ExtHostLanguages, new ExtHostLanguages(rpcProtocol, extHostDocuments, extHostCommands.converter));
|
||||
const extHostLanguageFeatures = rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, new ExtHostLanguageFeatures(rpcProtocol, uriTransformer, extHostDocuments, extHostCommands, extHostDiagnostics, extHostLogService, extHostApiDeprecation));
|
||||
const extHostFileSystem = rpcProtocol.set(ExtHostContext.ExtHostFileSystem, new ExtHostFileSystem(rpcProtocol, extHostLanguageFeatures));
|
||||
const extHostFileSystemEvent = rpcProtocol.set(ExtHostContext.ExtHostFileSystemEventService, new ExtHostFileSystemEventService(rpcProtocol, extHostLogService, extHostDocumentsAndEditors));
|
||||
@@ -186,7 +187,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
const extHostMessageService = new ExtHostMessageService(rpcProtocol, extHostLogService);
|
||||
const extHostDialogs = new ExtHostDialogs(rpcProtocol);
|
||||
const extHostStatusBar = new ExtHostStatusBar(rpcProtocol, extHostCommands.converter);
|
||||
const extHostLanguages = new ExtHostLanguages(rpcProtocol, extHostDocuments, extHostCommands.converter);
|
||||
|
||||
// Register API-ish commands
|
||||
ExtHostApiCommands.register(extHostCommands);
|
||||
|
||||
@@ -423,7 +423,6 @@ export interface MainThreadLanguageFeaturesShape extends IDisposable {
|
||||
}
|
||||
|
||||
export interface MainThreadLanguagesShape extends IDisposable {
|
||||
$getLanguages(): Promise<string[]>;
|
||||
$changeLanguage(resource: UriComponents, languageId: string): Promise<void>;
|
||||
$tokensAtPosition(resource: UriComponents, position: IPosition): Promise<undefined | { type: modes.StandardTokenType, range: IRange }>;
|
||||
$setLanguageStatus(handle: number, status: ILanguageStatus): void;
|
||||
@@ -1374,6 +1373,10 @@ export interface ExtHostFileSystemEventServiceShape {
|
||||
$onDidRunFileOperation(operation: files.FileOperation, files: readonly SourceTargetPair[]): void;
|
||||
}
|
||||
|
||||
export interface ExtHostLanguagesShape {
|
||||
$acceptLanguageIds(ids: string[]): void;
|
||||
}
|
||||
|
||||
export interface ObjectIdentifier {
|
||||
$ident?: number;
|
||||
}
|
||||
@@ -2252,6 +2255,7 @@ export const ExtHostContext = {
|
||||
ExtHostFileSystem: createExtId<ExtHostFileSystemShape>('ExtHostFileSystem'),
|
||||
ExtHostFileSystemInfo: createExtId<ExtHostFileSystemInfoShape>('ExtHostFileSystemInfo'),
|
||||
ExtHostFileSystemEventService: createExtId<ExtHostFileSystemEventServiceShape>('ExtHostFileSystemEventService'),
|
||||
ExtHostLanguages: createExtId<ExtHostLanguagesShape>('ExtHostLanguages'),
|
||||
ExtHostLanguageFeatures: createExtId<ExtHostLanguageFeaturesShape>('ExtHostLanguageFeatures'),
|
||||
ExtHostQuickOpen: createExtId<ExtHostQuickOpenShape>('ExtHostQuickOpen'),
|
||||
ExtHostExtensionService: createExtId<ExtHostExtensionServiceShape>('ExtHostExtensionService'),
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user