mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
Use native JS Proxy for main <-> ext host proxies
This commit is contained in:
@@ -8,7 +8,7 @@ import {Emitter} from 'vs/base/common/event';
|
||||
import {score} from 'vs/editor/common/modes/languageSelector';
|
||||
import * as Platform from 'vs/base/common/platform';
|
||||
import {regExpLeadsToEndlessLoop} from 'vs/base/common/strings';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import {ExtHostFileSystemEventService} from 'vs/workbench/api/node/extHostFileSystemEventService';
|
||||
import {ExtHostModelService, setWordDefinitionFor} from 'vs/workbench/api/node/extHostDocuments';
|
||||
@@ -32,7 +32,7 @@ import URI from 'vs/base/common/uri';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import {IDisposable} from 'vs/base/common/lifecycle';
|
||||
import EditorCommon = require('vs/editor/common/editorCommon');
|
||||
import {IExtensionService, IExtensionDescription} from 'vs/platform/extensions/common/extensions';
|
||||
import {IExtensionDescription} from 'vs/platform/extensions/common/extensions';
|
||||
import {ExtHostExtensionService} from 'vs/workbench/api/node/nativeExtensionService';
|
||||
import {ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
@@ -43,6 +43,7 @@ import {TextEditorRevealType} from 'vs/workbench/api/node/mainThreadEditors';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import {ITelemetryService, ITelemetryInfo} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {LanguageConfigurationRegistry} from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import {MainContext, ExtHostContext, InstanceCollection} from './extHostProtocol';
|
||||
|
||||
/**
|
||||
* This class implements the API described in vscode.d.ts,
|
||||
@@ -55,7 +56,6 @@ export class ExtHostAPIImplementation {
|
||||
return String(++ExtHostAPIImplementation._LAST_REGISTER_TOKEN);
|
||||
}
|
||||
|
||||
private _threadService: IThreadService;
|
||||
private _proxy: MainProcessVSCodeAPIHelper;
|
||||
|
||||
version: typeof vscode.version;
|
||||
@@ -98,13 +98,45 @@ export class ExtHostAPIImplementation {
|
||||
extensions: typeof vscode.extensions;
|
||||
|
||||
constructor(
|
||||
@IThreadService threadService: IThreadService,
|
||||
@IExtensionService extensionService: IExtensionService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@ITelemetryService telemetryService: ITelemetryService
|
||||
threadService: IThreadService,
|
||||
extensionService: ExtHostExtensionService,
|
||||
contextService: IWorkspaceContextService,
|
||||
telemetryService: ITelemetryService
|
||||
) {
|
||||
this._threadService = threadService;
|
||||
this._proxy = threadService.getRemotable(MainProcessVSCodeAPIHelper);
|
||||
// Addressable instances
|
||||
const col = new InstanceCollection();
|
||||
|
||||
const extHostDocuments = col.define(ExtHostContext.ExtHostModelService).set(new ExtHostModelService(threadService));
|
||||
const extHostEditors = col.define(ExtHostContext.ExtHostEditors).set(new ExtHostEditors(threadService, extHostDocuments));
|
||||
const extHostCommands = col.define(ExtHostContext.ExtHostCommands).set(new ExtHostCommands(threadService, extHostEditors));
|
||||
const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set(new ExtHostConfiguration());
|
||||
const extHostDiagnostics = col.define(ExtHostContext.ExtHostDiagnostics).set(new ExtHostDiagnostics(threadService));
|
||||
const languageFeatures = col.define(ExtHostContext.ExtHostLanguageFeatures).set(new ExtHostLanguageFeatures(threadService, extHostDocuments, extHostCommands, extHostDiagnostics));
|
||||
const extHostFileSystemEvent = col.define(ExtHostContext.ExtHostFileSystemEventService).set(new ExtHostFileSystemEventService());
|
||||
const extHostQuickOpen = col.define(ExtHostContext.ExtHostQuickOpen).set(new ExtHostQuickOpen(threadService));
|
||||
col.define(ExtHostContext.ExtHostExtensionService).set(extensionService);
|
||||
|
||||
col.finish(false, threadService);
|
||||
|
||||
|
||||
// Others
|
||||
this._proxy = threadService.get(MainContext.MainProcessVSCodeAPIHelper);
|
||||
errors.setUnexpectedErrorHandler((err) => {
|
||||
this._proxy.onUnexpectedExtHostError(errors.transformErrorForSerialization(err));
|
||||
});
|
||||
|
||||
const extHostMessageService = new ExtHostMessageService(threadService);
|
||||
const extHostStatusBar = new ExtHostStatusBar(threadService);
|
||||
const extHostOutputService = new ExtHostOutputService(threadService);
|
||||
const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined;
|
||||
const extHostWorkspace = new ExtHostWorkspace(threadService, workspacePath);
|
||||
const languages = new ExtHostLanguages(threadService);
|
||||
|
||||
// the converter might create delegate commands to avoid sending args
|
||||
// around all the time
|
||||
ExtHostTypeConverters.Command.initialize(extHostCommands);
|
||||
registerApiCommands(extHostCommands);
|
||||
|
||||
|
||||
this.version = contextService.getConfiguration().env.version;
|
||||
this.Uri = URI;
|
||||
@@ -139,21 +171,6 @@ export class ExtHostAPIImplementation {
|
||||
this.EndOfLine = extHostTypes.EndOfLine;
|
||||
this.TextEditorCursorStyle = EditorCommon.TextEditorCursorStyle;
|
||||
|
||||
errors.setUnexpectedErrorHandler((err) => {
|
||||
this._proxy.onUnexpectedExtHostError(errors.transformErrorForSerialization(err));
|
||||
});
|
||||
|
||||
const extHostCommands = this._threadService.getRemotable(ExtHostCommands);
|
||||
const extHostEditors = this._threadService.getRemotable(ExtHostEditors);
|
||||
const extHostMessageService = new ExtHostMessageService(this._threadService);
|
||||
const extHostQuickOpen = this._threadService.getRemotable(ExtHostQuickOpen);
|
||||
const extHostStatusBar = new ExtHostStatusBar(this._threadService);
|
||||
const extHostOutputService = new ExtHostOutputService(this._threadService);
|
||||
|
||||
// the converter might create delegate commands to avoid sending args
|
||||
// around all the time
|
||||
ExtHostTypeConverters.Command.initialize(extHostCommands);
|
||||
|
||||
// env namespace
|
||||
let telemetryInfo: ITelemetryInfo;
|
||||
this.env = Object.freeze({
|
||||
@@ -248,11 +265,6 @@ export class ExtHostAPIImplementation {
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined;
|
||||
const extHostFileSystemEvent = threadService.getRemotable(ExtHostFileSystemEventService);
|
||||
const extHostWorkspace = new ExtHostWorkspace(this._threadService, workspacePath);
|
||||
const extHostDocuments = this._threadService.getRemotable(ExtHostModelService);
|
||||
this.workspace = Object.freeze({
|
||||
get rootPath() {
|
||||
return extHostWorkspace.getPath();
|
||||
@@ -318,14 +330,6 @@ export class ExtHostAPIImplementation {
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
registerApiCommands(threadService);
|
||||
|
||||
//
|
||||
const languages = new ExtHostLanguages(this._threadService);
|
||||
const extHostDiagnostics = threadService.getRemotable(ExtHostDiagnostics);
|
||||
const languageFeatures = threadService.getRemotable(ExtHostLanguageFeatures);
|
||||
|
||||
this.languages = {
|
||||
createDiagnosticCollection(name?: string): vscode.DiagnosticCollection {
|
||||
return extHostDiagnostics.createDiagnosticCollection(name);
|
||||
@@ -383,9 +387,6 @@ export class ExtHostAPIImplementation {
|
||||
}
|
||||
};
|
||||
|
||||
var extHostConfiguration = threadService.getRemotable(ExtHostConfiguration);
|
||||
|
||||
//
|
||||
this.extensions = {
|
||||
getExtension(extensionId: string):Extension<any> {
|
||||
let desc = ExtensionsRegistry.getExtensionDescription(extensionId);
|
||||
@@ -397,9 +398,6 @@ export class ExtHostAPIImplementation {
|
||||
return ExtensionsRegistry.getAllExtensionDescriptions().map((desc) => new Extension(<ExtHostExtensionService> extensionService, desc));
|
||||
}
|
||||
};
|
||||
|
||||
// Intentionally calling a function for typechecking purposes
|
||||
defineAPI(this);
|
||||
}
|
||||
|
||||
private _disposableFromToken(disposeToken:string): IDisposable {
|
||||
@@ -466,7 +464,7 @@ class Extension<T> implements vscode.Extension<T> {
|
||||
}
|
||||
}
|
||||
|
||||
function defineAPI(impl: typeof vscode) {
|
||||
export function defineAPI(impl: typeof vscode) {
|
||||
let node_module = <any>require.__$__nodeRequire('module');
|
||||
let original = node_module._load;
|
||||
node_module._load = function load(request, parent, isMain) {
|
||||
@@ -478,7 +476,6 @@ function defineAPI(impl: typeof vscode) {
|
||||
define('vscode', [], impl);
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainProcessVSCodeAPIHelper')
|
||||
export class MainProcessVSCodeAPIHelper {
|
||||
protected _modeService: IModeService;
|
||||
private _token2Dispose: {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import {IWorkbenchContribution} from 'vs/workbench/common/contributions';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
import {IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions} from 'vs/workbench/common/contributions';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IInstantiationService, IConstructorSignature0} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {MainThreadDocuments} from 'vs/workbench/api/node/extHostDocuments';
|
||||
import {MainProcessTextMateSyntax} from 'vs/editor/node/textMate/TMSyntax';
|
||||
@@ -19,7 +19,7 @@ import {MainThreadFileSystemEventService} from 'vs/workbench/api/node/extHostFil
|
||||
import {MainThreadQuickOpen} from 'vs/workbench/api/node/extHostQuickOpen';
|
||||
import {MainThreadStatusBar} from 'vs/workbench/api/node/extHostStatusBar';
|
||||
import {MainThreadCommands} from 'vs/workbench/api/node/extHostCommands';
|
||||
import {RemoteTelemetryServiceHelper} from 'vs/workbench/api/node/extHostTelemetry';
|
||||
import {MainThreadTelemetry} from 'vs/workbench/api/node/extHostTelemetry';
|
||||
import {MainThreadDiagnostics} from 'vs/workbench/api/node/extHostDiagnostics';
|
||||
import {MainThreadOutputService} from 'vs/workbench/api/node/extHostOutputService';
|
||||
import {MainThreadMessageService} from 'vs/workbench/api/node/extHostMessageService';
|
||||
@@ -30,12 +30,15 @@ import {MainThreadConfiguration} from 'vs/workbench/api/node/extHostConfiguratio
|
||||
import {MainThreadLanguageFeatures} from 'vs/workbench/api/node/extHostLanguageFeatures';
|
||||
import {MainThreadStorage} from 'vs/workbench/api/node/extHostStorage';
|
||||
import {MainProcessVSCodeAPIHelper} from 'vs/workbench/api/node/extHost.api.impl';
|
||||
import {MainContext, InstanceCollection} from './extHostProtocol';
|
||||
import {IExtensionService} from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
export class ExtHostContribution implements IWorkbenchContribution {
|
||||
|
||||
constructor(
|
||||
@IThreadService private threadService: IThreadService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IExtensionService private extensionService: IExtensionService
|
||||
) {
|
||||
this.initExtensionSystem();
|
||||
}
|
||||
@@ -45,26 +48,36 @@ export class ExtHostContribution implements IWorkbenchContribution {
|
||||
}
|
||||
|
||||
private initExtensionSystem(): void {
|
||||
this.threadService.getRemotable(MainProcessVSCodeAPIHelper);
|
||||
this.threadService.getRemotable(MainThreadDocuments);
|
||||
this.threadService.getRemotable(RemoteTelemetryServiceHelper);
|
||||
this.instantiationService.createInstance(MainProcessTextMateSyntax);
|
||||
this.instantiationService.createInstance(MainProcessTextMateSnippet);
|
||||
this.instantiationService.createInstance(JSONValidationExtensionPoint);
|
||||
this.instantiationService.createInstance(LanguageConfigurationFileHandler);
|
||||
this.threadService.getRemotable(MainThreadConfiguration);
|
||||
this.threadService.getRemotable(MainThreadQuickOpen);
|
||||
this.threadService.getRemotable(MainThreadStatusBar);
|
||||
this.instantiationService.createInstance(MainThreadFileSystemEventService);
|
||||
this.threadService.getRemotable(MainThreadCommands);
|
||||
this.threadService.getRemotable(MainThreadOutputService);
|
||||
this.threadService.getRemotable(MainThreadDiagnostics);
|
||||
this.threadService.getRemotable(MainThreadMessageService);
|
||||
this.threadService.getRemotable(MainThreadLanguages);
|
||||
this.threadService.getRemotable(MainThreadWorkspace);
|
||||
this.threadService.getRemotable(MainThreadEditors);
|
||||
this.threadService.getRemotable(MainThreadStorage);
|
||||
this.threadService.getRemotable(MainThreadLanguageFeatures);
|
||||
const create = <T>(ctor: IConstructorSignature0<T>): T => {
|
||||
return this.instantiationService.createInstance(ctor);
|
||||
};
|
||||
|
||||
// Addressable instances
|
||||
const col = new InstanceCollection();
|
||||
col.define(MainContext.MainProcessVSCodeAPIHelper).set(create(MainProcessVSCodeAPIHelper));
|
||||
col.define(MainContext.MainThreadCommands).set(create(MainThreadCommands));
|
||||
col.define(MainContext.MainThreadConfiguration).set(create(MainThreadConfiguration));
|
||||
col.define(MainContext.MainThreadDiagnostics).set(create(MainThreadDiagnostics));
|
||||
col.define(MainContext.MainThreadDocuments).set(create(MainThreadDocuments));
|
||||
col.define(MainContext.MainThreadEditors).set(create(MainThreadEditors));
|
||||
col.define(MainContext.MainThreadLanguageFeatures).set(create(MainThreadLanguageFeatures));
|
||||
col.define(MainContext.MainThreadLanguages).set(create(MainThreadLanguages));
|
||||
col.define(MainContext.MainThreadMessageService).set(create(MainThreadMessageService));
|
||||
col.define(MainContext.MainThreadOutputService).set(create(MainThreadOutputService));
|
||||
col.define(MainContext.MainThreadQuickOpen).set(create(MainThreadQuickOpen));
|
||||
col.define(MainContext.MainThreadStatusBar).set(create(MainThreadStatusBar));
|
||||
col.define(MainContext.MainThreadStorage).set(create(MainThreadStorage));
|
||||
col.define(MainContext.MainThreadTelemetry).set(create(MainThreadTelemetry));
|
||||
col.define(MainContext.MainThreadWorkspace).set(create(MainThreadWorkspace));
|
||||
col.define(MainContext.MainProcessExtensionService).set(this.extensionService);
|
||||
col.finish(true, this.threadService);
|
||||
|
||||
// Other interested parties
|
||||
create(MainProcessTextMateSyntax);
|
||||
create(MainProcessTextMateSnippet);
|
||||
create(JSONValidationExtensionPoint);
|
||||
create(LanguageConfigurationFileHandler);
|
||||
create(MainThreadFileSystemEventService);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,8 @@ import {IQuickFix2} from 'vs/editor/contrib/quickFix/common/quickFix';
|
||||
import {IOutline} from 'vs/editor/contrib/quickOpen/common/quickOpen';
|
||||
import {ITypeBearing} from 'vs/workbench/parts/search/common/search';
|
||||
import {ICodeLensData} from 'vs/editor/contrib/codelens/common/codelens';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
|
||||
export function registerApiCommands(threadService: IThreadService) {
|
||||
const commands = threadService.getRemotable(ExtHostCommands);
|
||||
export function registerApiCommands(commands:ExtHostCommands) {
|
||||
new ExtHostApiCommands(commands).registerCommands();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {validateConstraint} from 'vs/base/common/types';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {IKeybindingService, ICommandHandlerDescription} from 'vs/platform/keybinding/common/keybindingService';
|
||||
@@ -13,6 +13,7 @@ import {ExtHostEditors} from 'vs/workbench/api/node/extHostEditors';
|
||||
import * as extHostTypes from 'vs/workbench/api/node/extHostTypes';
|
||||
import * as extHostTypeConverter from 'vs/workbench/api/node/extHostTypeConverters';
|
||||
import {cloneAndChange} from 'vs/base/common/objects';
|
||||
import {MainContext, ExtHostContext} from './extHostProtocol';
|
||||
|
||||
interface CommandHandler {
|
||||
callback: Function;
|
||||
@@ -20,16 +21,18 @@ interface CommandHandler {
|
||||
description: ICommandHandlerDescription;
|
||||
}
|
||||
|
||||
@Remotable.ExtHostContext('ExtHostCommands')
|
||||
export class ExtHostCommands {
|
||||
|
||||
private _commands: { [n: string]: CommandHandler } = Object.create(null);
|
||||
private _proxy: MainThreadCommands;
|
||||
private _extHostEditors: ExtHostEditors;
|
||||
|
||||
constructor(@IThreadService threadService: IThreadService) {
|
||||
this._extHostEditors = threadService.getRemotable(ExtHostEditors);
|
||||
this._proxy = threadService.getRemotable(MainThreadCommands);
|
||||
constructor(
|
||||
threadService: IThreadService,
|
||||
extHostEditors:ExtHostEditors
|
||||
) {
|
||||
this._extHostEditors = extHostEditors;
|
||||
this._proxy = threadService.get(MainContext.MainThreadCommands);
|
||||
}
|
||||
|
||||
registerCommand(id: string, callback: <T>(...args: any[]) => T | Thenable<T>, thisArg?: any, description?: ICommandHandlerDescription): extHostTypes.Disposable {
|
||||
@@ -124,17 +127,19 @@ export class ExtHostCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadCommands')
|
||||
export class MainThreadCommands {
|
||||
|
||||
private _threadService: IThreadService;
|
||||
private _keybindingService: IKeybindingService;
|
||||
private _proxy: ExtHostCommands;
|
||||
|
||||
constructor( @IThreadService threadService: IThreadService, @IKeybindingService keybindingService: IKeybindingService) {
|
||||
constructor(
|
||||
@IThreadService threadService: IThreadService,
|
||||
@IKeybindingService keybindingService: IKeybindingService
|
||||
) {
|
||||
this._threadService = threadService;
|
||||
this._keybindingService = keybindingService;
|
||||
this._proxy = this._threadService.getRemotable(ExtHostCommands);
|
||||
this._proxy = this._threadService.get(ExtHostContext.ExtHostCommands);
|
||||
}
|
||||
|
||||
$registerCommand(id: string): TPromise<any> {
|
||||
@@ -171,7 +176,7 @@ export class MainThreadCommands {
|
||||
KeybindingsRegistry.registerCommandDesc({
|
||||
id: '_generateCommandsDocumentation',
|
||||
handler: function(accessor) {
|
||||
return accessor.get(IThreadService).getRemotable(ExtHostCommands).$getContributedCommandHandlerDescriptions().then(result => {
|
||||
return accessor.get(IThreadService).get(ExtHostContext.ExtHostCommands).$getContributedCommandHandlerDescriptions().then(result => {
|
||||
|
||||
// add local commands
|
||||
const commands = KeybindingsRegistry.getCommands();
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
import {clone} from 'vs/base/common/objects';
|
||||
import {illegalState} from 'vs/base/common/errors';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {IThreadService, Remotable} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
import Event, {Emitter} from 'vs/base/common/event';
|
||||
import {WorkspaceConfiguration} from 'vscode';
|
||||
import {ExtHostContext} from './extHostProtocol';
|
||||
|
||||
@Remotable.ExtHostContext('ExtHostConfiguration')
|
||||
export class ExtHostConfiguration {
|
||||
|
||||
private _config: any;
|
||||
@@ -77,7 +77,6 @@ export class ExtHostConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainProcessConfigurationServiceHelper')
|
||||
export class MainThreadConfiguration {
|
||||
|
||||
private _configurationService: IConfigurationService;
|
||||
@@ -88,7 +87,7 @@ export class MainThreadConfiguration {
|
||||
@IThreadService threadService: IThreadService) {
|
||||
|
||||
this._configurationService = configurationService;
|
||||
this._proxy = threadService.getRemotable(ExtHostConfiguration);
|
||||
this._proxy = threadService.get(ExtHostContext.ExtHostConfiguration);
|
||||
|
||||
this._toDispose = this._configurationService.onDidUpdateConfiguration(event => this._proxy.$acceptConfigurationChanged(event.config));
|
||||
this._proxy.$acceptConfigurationChanged(this._configurationService.getConfiguration());
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IMarkerService, IMarkerData} from 'vs/platform/markers/common/markers';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import * as vscode from 'vscode';
|
||||
import {MainContext} from './extHostProtocol';
|
||||
|
||||
export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
|
||||
@@ -175,7 +176,6 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.ExtHostContext('ExtHostDiagnostics')
|
||||
export class ExtHostDiagnostics {
|
||||
|
||||
private static _idPool: number = 0;
|
||||
@@ -183,8 +183,8 @@ export class ExtHostDiagnostics {
|
||||
private _proxy: MainThreadDiagnostics;
|
||||
private _collections: DiagnosticCollection[];
|
||||
|
||||
constructor(@IThreadService threadService: IThreadService) {
|
||||
this._proxy = threadService.getRemotable(MainThreadDiagnostics);
|
||||
constructor(threadService: IThreadService) {
|
||||
this._proxy = threadService.get(MainContext.MainThreadDiagnostics);
|
||||
this._collections = [];
|
||||
}
|
||||
|
||||
@@ -216,7 +216,6 @@ export class ExtHostDiagnostics {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadDiagnostics')
|
||||
export class MainThreadDiagnostics {
|
||||
|
||||
private _markerService: IMarkerService;
|
||||
|
||||
@@ -9,7 +9,7 @@ import {EmitterEvent} from 'vs/base/common/eventEmitter';
|
||||
import {IModelService} from 'vs/editor/common/services/modelService';
|
||||
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
||||
import {MirrorModel2} from 'vs/editor/common/model/mirrorModel2';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import Event, {Emitter} from 'vs/base/common/event';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
@@ -26,6 +26,7 @@ import {IUntitledEditorService} from 'vs/workbench/services/untitled/common/unti
|
||||
import {ResourceEditorInput} from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import {asWinJsPromise} from 'vs/base/common/async';
|
||||
import {getWordAtText, ensureValidWordDefinition} from 'vs/editor/common/model/wordHelper';
|
||||
import {MainContext, ExtHostContext} from './extHostProtocol';
|
||||
|
||||
export interface IModelAddedData {
|
||||
url: URI;
|
||||
@@ -47,7 +48,6 @@ export function getWordDefinitionFor(modeId: string): RegExp {
|
||||
return _modeId2WordDefinition[modeId];
|
||||
}
|
||||
|
||||
@Remotable.ExtHostContext('ExtHostModelService')
|
||||
export class ExtHostModelService {
|
||||
|
||||
private static _handlePool: number = 0;
|
||||
@@ -70,8 +70,8 @@ export class ExtHostModelService {
|
||||
|
||||
private _proxy: MainThreadDocuments;
|
||||
|
||||
constructor(@IThreadService threadService: IThreadService) {
|
||||
this._proxy = threadService.getRemotable(MainThreadDocuments);
|
||||
constructor(threadService: IThreadService) {
|
||||
this._proxy = threadService.get(MainContext.MainThreadDocuments);
|
||||
|
||||
this._onDidAddDocumentEventEmitter = new Emitter<vscode.TextDocument>();
|
||||
this.onDidAddDocument = this._onDidAddDocumentEventEmitter.event;
|
||||
@@ -437,7 +437,6 @@ export class ExtHostDocumentData extends MirrorModel2 {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadDocuments')
|
||||
export class MainThreadDocuments {
|
||||
private _modelService: IModelService;
|
||||
private _modeService: IModeService;
|
||||
@@ -468,7 +467,7 @@ export class MainThreadDocuments {
|
||||
this._editorService = editorService;
|
||||
this._fileService = fileService;
|
||||
this._untitledEditorService = untitledEditorService;
|
||||
this._proxy = threadService.getRemotable(ExtHostModelService);
|
||||
this._proxy = threadService.get(ExtHostContext.ExtHostModelService);
|
||||
this._modelIsSynced = {};
|
||||
|
||||
this._toDispose = [];
|
||||
|
||||
@@ -10,7 +10,7 @@ import {IdGenerator} from 'vs/base/common/idGenerator';
|
||||
import Event, {Emitter} from 'vs/base/common/event';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {ExtHostModelService, ExtHostDocumentData} from 'vs/workbench/api/node/extHostDocuments';
|
||||
import {Selection, Range, Position, EditorOptions, EndOfLine} from './extHostTypes';
|
||||
import {ISingleEditOperation, ISelection, IRange, IEditor, EditorType, ICommonCodeEditor, ICommonDiffEditor, IDecorationRenderOptions, IDecorationOptions} from 'vs/editor/common/editorCommon';
|
||||
@@ -26,6 +26,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
import {equals as arrayEquals} from 'vs/base/common/arrays';
|
||||
import {equals as objectEquals} from 'vs/base/common/objects';
|
||||
import {MainContext, ExtHostContext} from './extHostProtocol';
|
||||
|
||||
export interface ITextEditorAddData {
|
||||
id: string;
|
||||
@@ -39,7 +40,6 @@ export interface ITextEditorPositionData {
|
||||
[id: string]: EditorPosition;
|
||||
}
|
||||
|
||||
@Remotable.ExtHostContext('ExtHostEditors')
|
||||
export class ExtHostEditors {
|
||||
|
||||
public onDidChangeTextEditorSelection: Event<TextEditorSelectionChangeEvent>;
|
||||
@@ -59,7 +59,8 @@ export class ExtHostEditors {
|
||||
private _visibleEditorIds: string[];
|
||||
|
||||
constructor(
|
||||
@IThreadService threadService: IThreadService
|
||||
threadService: IThreadService,
|
||||
modelService: ExtHostModelService
|
||||
) {
|
||||
this._onDidChangeTextEditorSelection = new Emitter<TextEditorSelectionChangeEvent>();
|
||||
this.onDidChangeTextEditorSelection = this._onDidChangeTextEditorSelection.event;
|
||||
@@ -70,8 +71,8 @@ export class ExtHostEditors {
|
||||
this._onDidChangeTextEditorViewColumn = new Emitter<TextEditorViewColumnChangeEvent>();
|
||||
this.onDidChangeTextEditorViewColumn = this._onDidChangeTextEditorViewColumn.event;
|
||||
|
||||
this._modelService = threadService.getRemotable(ExtHostModelService);
|
||||
this._proxy = threadService.getRemotable(MainThreadEditors);
|
||||
this._modelService = modelService;
|
||||
this._proxy = threadService.get(MainContext.MainThreadEditors);
|
||||
this._onDidChangeActiveTextEditor = new Emitter<vscode.TextEditor>();
|
||||
this._editors = Object.create(null);
|
||||
|
||||
@@ -453,7 +454,6 @@ class ExtHostTextEditor implements vscode.TextEditor {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadEditors')
|
||||
export class MainThreadEditors {
|
||||
|
||||
private _proxy: ExtHostEditors;
|
||||
@@ -476,7 +476,7 @@ export class MainThreadEditors {
|
||||
@IEventService eventService: IEventService,
|
||||
@IModelService modelService: IModelService
|
||||
) {
|
||||
this._proxy = threadService.getRemotable(ExtHostEditors);
|
||||
this._proxy = threadService.get(ExtHostContext.ExtHostEditors);
|
||||
this._workbenchEditorService = workbenchEditorService;
|
||||
this._telemetryService = telemetryService;
|
||||
this._toDispose = [];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import {FileChangesEvent, FileChangeType} from 'vs/platform/files/common/files';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import Event, {Emitter} from 'vs/base/common/event';
|
||||
import {Disposable} from './extHostTypes';
|
||||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
@@ -13,6 +13,7 @@ import {RunOnceScheduler} from 'vs/base/common/async';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import {match} from 'vs/base/common/glob';
|
||||
import {Uri, FileSystemWatcher as _FileSystemWatcher} from 'vscode';
|
||||
import {ExtHostContext} from './extHostProtocol';
|
||||
|
||||
export interface FileSystemEvents {
|
||||
created: URI[];
|
||||
@@ -97,7 +98,6 @@ export class FileSystemWatcher implements _FileSystemWatcher {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.ExtHostContext('ExtHostFileSystemEventService')
|
||||
export class ExtHostFileSystemEventService {
|
||||
|
||||
private _emitter = new Emitter<FileSystemEvents>();
|
||||
@@ -118,7 +118,7 @@ export class MainThreadFileSystemEventService {
|
||||
|
||||
constructor( @IEventService eventService: IEventService, @IThreadService threadService: IThreadService) {
|
||||
|
||||
const proxy = threadService.getRemotable(ExtHostFileSystemEventService);
|
||||
const proxy = threadService.get(ExtHostContext.ExtHostFileSystemEventService);
|
||||
const events: FileSystemEvents = {
|
||||
created: [],
|
||||
changed: [],
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import URI from 'vs/base/common/uri';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import * as vscode from 'vscode';
|
||||
import * as TypeConverters from 'vs/workbench/api/node/extHostTypeConverters';
|
||||
import {Range, Disposable, SignatureHelp, CompletionList} from 'vs/workbench/api/node/extHostTypes';
|
||||
@@ -21,6 +21,7 @@ import {asWinJsPromise, ShallowCancelThenPromise, wireCancellationToken} from 'v
|
||||
import {CancellationToken} from 'vs/base/common/cancellation';
|
||||
import {Position as EditorPosition} from 'vs/editor/common/core/position';
|
||||
import {Range as EditorRange} from 'vs/editor/common/core/range';
|
||||
import {MainContext, ExtHostContext} from './extHostProtocol';
|
||||
|
||||
// --- adapter
|
||||
|
||||
@@ -594,7 +595,6 @@ type Adapter = OutlineAdapter | CodeLensAdapter | DefinitionAdapter | HoverAdapt
|
||||
| RangeFormattingAdapter | OnTypeFormattingAdapter | NavigateTypeAdapter | RenameAdapter
|
||||
| SuggestAdapter | SignatureHelpAdapter;
|
||||
|
||||
@Remotable.ExtHostContext('ExtHostLanguageFeatures')
|
||||
export class ExtHostLanguageFeatures {
|
||||
|
||||
private static _handlePool: number = 0;
|
||||
@@ -605,11 +605,16 @@ export class ExtHostLanguageFeatures {
|
||||
private _diagnostics: ExtHostDiagnostics;
|
||||
private _adapter: { [handle: number]: Adapter } = Object.create(null);
|
||||
|
||||
constructor( @IThreadService threadService: IThreadService) {
|
||||
this._proxy = threadService.getRemotable(MainThreadLanguageFeatures);
|
||||
this._documents = threadService.getRemotable(ExtHostModelService);
|
||||
this._commands = threadService.getRemotable(ExtHostCommands);
|
||||
this._diagnostics = threadService.getRemotable(ExtHostDiagnostics);
|
||||
constructor(
|
||||
threadService: IThreadService,
|
||||
documents: ExtHostModelService,
|
||||
commands: ExtHostCommands,
|
||||
diagnostics: ExtHostDiagnostics
|
||||
) {
|
||||
this._proxy = threadService.get(MainContext.MainThreadLanguageFeatures);
|
||||
this._documents = documents;
|
||||
this._commands = commands;
|
||||
this._diagnostics = diagnostics;
|
||||
}
|
||||
|
||||
private _createDisposable(handle: number): Disposable {
|
||||
@@ -818,14 +823,13 @@ export class ExtHostLanguageFeatures {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadLanguageFeatures')
|
||||
export class MainThreadLanguageFeatures {
|
||||
|
||||
private _proxy: ExtHostLanguageFeatures;
|
||||
private _registrations: { [handle: number]: IDisposable; } = Object.create(null);
|
||||
|
||||
constructor( @IThreadService threadService: IThreadService) {
|
||||
this._proxy = threadService.getRemotable(ExtHostLanguageFeatures);
|
||||
this._proxy = threadService.get(ExtHostContext.ExtHostLanguageFeatures);
|
||||
}
|
||||
|
||||
$unregister(handle: number): TPromise<any> {
|
||||
|
||||
@@ -5,17 +5,18 @@
|
||||
'use strict';
|
||||
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
import {MainContext} from './extHostProtocol';
|
||||
|
||||
export class ExtHostLanguages {
|
||||
|
||||
private _proxy: MainThreadLanguages;
|
||||
|
||||
constructor(
|
||||
@IThreadService threadService: IThreadService
|
||||
threadService: IThreadService
|
||||
) {
|
||||
this._proxy = threadService.getRemotable(MainThreadLanguages);
|
||||
this._proxy = threadService.get(MainContext.MainThreadLanguages);
|
||||
}
|
||||
|
||||
getLanguages(): TPromise<string[]> {
|
||||
@@ -23,7 +24,6 @@ export class ExtHostLanguages {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadLanguages')
|
||||
export class MainThreadLanguages {
|
||||
|
||||
private _modeService: IModeService;
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
'use strict';
|
||||
|
||||
import nls = require('vs/nls');
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import {Action} from 'vs/base/common/actions';
|
||||
import {TPromise as Promise} from 'vs/base/common/winjs.base';
|
||||
import vscode = require('vscode');
|
||||
import {MainContext} from './extHostProtocol';
|
||||
|
||||
export class ExtHostMessageService {
|
||||
|
||||
private _proxy: MainThreadMessageService;
|
||||
|
||||
constructor(@IThreadService threadService: IThreadService) {
|
||||
this._proxy = threadService.getRemotable(MainThreadMessageService);
|
||||
constructor(threadService: IThreadService) {
|
||||
this._proxy = threadService.get(MainContext.MainThreadMessageService);
|
||||
}
|
||||
|
||||
showMessage(severity: Severity, message: string, commands: (string|vscode.MessageItem)[]): Thenable<string|vscode.MessageItem> {
|
||||
@@ -44,7 +45,6 @@ export class ExtHostMessageService {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadMessageService')
|
||||
export class MainThreadMessageService {
|
||||
|
||||
private _messageService: IMessageService;
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
'use strict';
|
||||
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
import {IOutputService, IOutputChannel, OUTPUT_PANEL_ID, Extensions, IOutputChannelRegistry} from 'vs/workbench/parts/output/common/output';
|
||||
import {IPartService} from 'vs/workbench/services/part/common/partService';
|
||||
import {IPanelService} from 'vs/workbench/services/panel/common/panelService';
|
||||
import {MainContext} from './extHostProtocol';
|
||||
|
||||
export class ExtHostOutputChannel implements vscode.OutputChannel {
|
||||
|
||||
@@ -68,7 +69,7 @@ export class ExtHostOutputService {
|
||||
private _proxy: MainThreadOutputService;
|
||||
|
||||
constructor(threadService: IThreadService) {
|
||||
this._proxy = threadService.getRemotable(MainThreadOutputService);
|
||||
this._proxy = threadService.get(MainContext.MainThreadOutputService);
|
||||
}
|
||||
|
||||
createOutputChannel(name: string): vscode.OutputChannel {
|
||||
@@ -81,7 +82,6 @@ export class ExtHostOutputService {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadOutputService')
|
||||
export class MainThreadOutputService {
|
||||
|
||||
private _outputService: IOutputService;
|
||||
|
||||
100
src/vs/workbench/api/node/extHostProtocol.ts
Normal file
100
src/vs/workbench/api/node/extHostProtocol.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
createMainContextProxyIdentifier as createMainId,
|
||||
createExtHostContextProxyIdentifier as createExtId,
|
||||
ProxyIdentifier, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
|
||||
import {MainProcessVSCodeAPIHelper} from './extHost.api.impl';
|
||||
import {ExtHostCommands, MainThreadCommands} from './extHostCommands';
|
||||
import {ExtHostConfiguration, MainThreadConfiguration} from './extHostConfiguration';
|
||||
import {ExtHostDiagnostics, MainThreadDiagnostics} from './extHostDiagnostics';
|
||||
import {ExtHostModelService, MainThreadDocuments} from './extHostDocuments';
|
||||
import {ExtHostEditors, MainThreadEditors} from './extHostEditors';
|
||||
import {ExtHostFileSystemEventService} from './extHostFileSystemEventService';
|
||||
import {ExtHostLanguageFeatures, MainThreadLanguageFeatures} from './extHostLanguageFeatures';
|
||||
import {MainThreadLanguages} from './extHostLanguages';
|
||||
import {MainThreadMessageService} from './extHostMessageService';
|
||||
import {MainThreadOutputService} from './extHostOutputService';
|
||||
import {ExtHostQuickOpen, MainThreadQuickOpen} from './extHostQuickOpen';
|
||||
import {MainThreadStatusBar} from './extHostStatusBar';
|
||||
import {MainThreadStorage} from './extHostStorage';
|
||||
import {MainThreadTelemetry} from './extHostTelemetry';
|
||||
import {MainThreadWorkspace} from './extHostWorkspace';
|
||||
import {ExtHostExtensionService, MainProcessExtensionService} from './nativeExtensionService';
|
||||
|
||||
let mainCounter = 0;
|
||||
export const MainContext = {
|
||||
MainProcessVSCodeAPIHelper: createMainId<MainProcessVSCodeAPIHelper>(++mainCounter),
|
||||
MainThreadCommands: createMainId<MainThreadCommands>(++mainCounter),
|
||||
MainThreadConfiguration: createMainId<MainThreadConfiguration>(++mainCounter),
|
||||
MainThreadDiagnostics: createMainId<MainThreadDiagnostics>(++mainCounter),
|
||||
MainThreadDocuments: createMainId<MainThreadDocuments>(++mainCounter),
|
||||
MainThreadEditors: createMainId<MainThreadEditors>(++mainCounter),
|
||||
MainThreadLanguageFeatures: createMainId<MainThreadLanguageFeatures>(++mainCounter),
|
||||
MainThreadLanguages: createMainId<MainThreadLanguages>(++mainCounter),
|
||||
MainThreadMessageService: createMainId<MainThreadMessageService>(++mainCounter),
|
||||
MainThreadOutputService: createMainId<MainThreadOutputService>(++mainCounter),
|
||||
MainThreadQuickOpen: createMainId<MainThreadQuickOpen>(++mainCounter),
|
||||
MainThreadStatusBar: createMainId<MainThreadStatusBar>(++mainCounter),
|
||||
MainThreadStorage: createMainId<MainThreadStorage>(++mainCounter),
|
||||
MainThreadTelemetry: createMainId<MainThreadTelemetry>(++mainCounter),
|
||||
MainThreadWorkspace: createMainId<MainThreadWorkspace>(++mainCounter),
|
||||
MainProcessExtensionService: createMainId<MainProcessExtensionService>(++mainCounter),
|
||||
};
|
||||
|
||||
let extCounter = 0;
|
||||
export const ExtHostContext = {
|
||||
ExtHostCommands: createExtId<ExtHostCommands>(++extCounter),
|
||||
ExtHostConfiguration: createExtId<ExtHostConfiguration>(++extCounter),
|
||||
ExtHostDiagnostics: createExtId<ExtHostDiagnostics>(++extCounter),
|
||||
ExtHostModelService: createExtId<ExtHostModelService>(++extCounter),
|
||||
ExtHostEditors: createExtId<ExtHostEditors>(++extCounter),
|
||||
ExtHostFileSystemEventService: createExtId<ExtHostFileSystemEventService>(++extCounter),
|
||||
ExtHostLanguageFeatures: createExtId<ExtHostLanguageFeatures>(++extCounter),
|
||||
ExtHostQuickOpen: createExtId<ExtHostQuickOpen>(++extCounter),
|
||||
ExtHostExtensionService: createExtId<ExtHostExtensionService>(++extCounter),
|
||||
};
|
||||
|
||||
export interface InstanceSetter<T> {
|
||||
set(instance:T): T;
|
||||
}
|
||||
|
||||
export class InstanceCollection {
|
||||
private _items: {[id:string]:any;};
|
||||
|
||||
constructor() {
|
||||
this._items = Object.create(null);
|
||||
}
|
||||
|
||||
public define<T>(id:ProxyIdentifier<T>): InstanceSetter<T> {
|
||||
let that = this;
|
||||
return new class {
|
||||
set(value:T) {
|
||||
that._set(id, value);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_set<T>(id:ProxyIdentifier<T>, value:T): void {
|
||||
this._items[id.id] = value;
|
||||
}
|
||||
|
||||
public finish(isMain:boolean, threadService:IThreadService): void {
|
||||
let expected = (isMain ? MainContext : ExtHostContext);
|
||||
Object.keys(expected).forEach((key) => {
|
||||
let id = expected[key];
|
||||
let value = this._items[id.id];
|
||||
|
||||
if (!value) {
|
||||
throw new Error(`Missing actor ${key} (isMain: ${id.isMain}, id: ${id.id})`);
|
||||
}
|
||||
threadService.set<any>(id, value);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,10 @@
|
||||
'use strict';
|
||||
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IQuickOpenService, IPickOpenEntry, IPickOptions, IInputOptions} from 'vs/workbench/services/quickopen/common/quickOpenService';
|
||||
import {QuickPickOptions, QuickPickItem, InputBoxOptions} from 'vscode';
|
||||
import {MainContext, ExtHostContext} from './extHostProtocol';
|
||||
|
||||
export interface MyQuickPickItems extends IPickOpenEntry {
|
||||
handle: number;
|
||||
@@ -15,15 +16,14 @@ export interface MyQuickPickItems extends IPickOpenEntry {
|
||||
|
||||
export type Item = string | QuickPickItem;
|
||||
|
||||
@Remotable.ExtHostContext('ExtHostQuickOpen')
|
||||
export class ExtHostQuickOpen {
|
||||
|
||||
private _proxy: MainThreadQuickOpen;
|
||||
private _onDidSelectItem: (handle: number) => void;
|
||||
private _validateInput: (input: string) => string;
|
||||
|
||||
constructor(@IThreadService threadService: IThreadService) {
|
||||
this._proxy = threadService.getRemotable(MainThreadQuickOpen);
|
||||
constructor(threadService: IThreadService) {
|
||||
this._proxy = threadService.get(MainContext.MainThreadQuickOpen);
|
||||
}
|
||||
|
||||
show(itemsOrItemsPromise: Item[] | Thenable<Item[]>, options?: QuickPickOptions): Thenable<Item> {
|
||||
@@ -112,7 +112,6 @@ export class ExtHostQuickOpen {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadQuickOpen')
|
||||
export class MainThreadQuickOpen {
|
||||
|
||||
private _proxy: ExtHostQuickOpen;
|
||||
@@ -123,7 +122,7 @@ export class MainThreadQuickOpen {
|
||||
private _token: number = 0;
|
||||
|
||||
constructor( @IThreadService threadService: IThreadService, @IQuickOpenService quickOpenService: IQuickOpenService) {
|
||||
this._proxy = threadService.getRemotable(ExtHostQuickOpen);
|
||||
this._proxy = threadService.get(ExtHostContext.ExtHostQuickOpen);
|
||||
this._quickOpenService = quickOpenService;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IStatusbarService, StatusbarAlignment as MainThreadStatusBarAlignment} from 'vs/platform/statusbar/common/statusbar';
|
||||
import {IDisposable} from 'vs/base/common/lifecycle';
|
||||
import {StatusBarAlignment as ExtHostStatusBarAlignment, Disposable} from './extHostTypes';
|
||||
import {StatusBarItem, StatusBarAlignment} from 'vscode';
|
||||
import {MainContext} from './extHostProtocol';
|
||||
|
||||
export class ExtHostStatusBarEntry implements StatusBarItem {
|
||||
private static ID_GEN = 0;
|
||||
@@ -161,8 +162,8 @@ export class ExtHostStatusBar {
|
||||
private _proxy: MainThreadStatusBar;
|
||||
private _statusMessage: StatusBarMessage;
|
||||
|
||||
constructor( @IThreadService threadService: IThreadService) {
|
||||
this._proxy = threadService.getRemotable(MainThreadStatusBar);
|
||||
constructor(threadService: IThreadService) {
|
||||
this._proxy = threadService.get(MainContext.MainThreadStatusBar);
|
||||
this._statusMessage = new StatusBarMessage(this);
|
||||
}
|
||||
|
||||
@@ -188,7 +189,6 @@ export class ExtHostStatusBar {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadStatusBar')
|
||||
export class MainThreadStatusBar {
|
||||
private mapIdToDisposable: { [id: number]: IDisposable };
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
'use strict';
|
||||
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
|
||||
import {MainContext} from './extHostProtocol';
|
||||
|
||||
@Remotable.MainContext('MainThreadStorage')
|
||||
export class MainThreadStorage {
|
||||
|
||||
private _storageService: IStorageService;
|
||||
@@ -47,7 +47,7 @@ export class ExtHostStorage {
|
||||
private _proxy: MainThreadStorage;
|
||||
|
||||
constructor(threadService: IThreadService) {
|
||||
this._proxy = threadService.getRemotable(MainThreadStorage);
|
||||
this._proxy = threadService.get(MainContext.MainThreadStorage);
|
||||
}
|
||||
|
||||
getValue<T>(shared: boolean, key: string, defaultValue?: T): TPromise<T> {
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
import {notImplemented} from 'vs/base/common/errors';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {ITelemetryService, ITelemetryInfo} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {MainContext} from './extHostProtocol';
|
||||
|
||||
/**
|
||||
* Helper always instantiated in the main process to receive telemetry events from remote telemetry services
|
||||
*/
|
||||
@Remotable.MainContext('RemoteTelemetryServiceHelper')
|
||||
export class RemoteTelemetryServiceHelper {
|
||||
export class MainThreadTelemetry {
|
||||
|
||||
private _telemetryService: ITelemetryService;
|
||||
|
||||
@@ -35,11 +35,11 @@ export class RemoteTelemetryService implements ITelemetryService {
|
||||
serviceId: any;
|
||||
|
||||
private _name: string;
|
||||
private _proxy: RemoteTelemetryServiceHelper;
|
||||
private _proxy: MainThreadTelemetry;
|
||||
|
||||
constructor(name: string, threadService: IThreadService) {
|
||||
this._name = name;
|
||||
this._proxy = threadService.getRemotable(RemoteTelemetryServiceHelper);
|
||||
this._proxy = threadService.get(MainContext.MainThreadTelemetry);
|
||||
}
|
||||
|
||||
get isOptedIn(): boolean {
|
||||
|
||||
@@ -8,7 +8,7 @@ import {isPromiseCanceledError} from 'vs/base/common/errors';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import {ISearchService, QueryType} from 'vs/platform/search/common/search';
|
||||
import {IWorkspaceContextService, IWorkspace} from 'vs/platform/workspace/common/workspace';
|
||||
import {Remotable, IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
|
||||
import {ITextFileService} from 'vs/workbench/parts/files/common/files';
|
||||
@@ -17,6 +17,7 @@ import {bulkEdit, IResourceEdit} from 'vs/editor/common/services/bulkEdit';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {fromRange} from 'vs/workbench/api/node/extHostTypeConverters';
|
||||
import {Uri, CancellationToken} from 'vscode';
|
||||
import {MainContext} from './extHostProtocol';
|
||||
|
||||
export class ExtHostWorkspace {
|
||||
|
||||
@@ -25,8 +26,8 @@ export class ExtHostWorkspace {
|
||||
private _proxy: MainThreadWorkspace;
|
||||
private _workspacePath: string;
|
||||
|
||||
constructor( @IThreadService threadService: IThreadService, workspacePath:string) {
|
||||
this._proxy = threadService.getRemotable(MainThreadWorkspace);
|
||||
constructor(threadService: IThreadService, workspacePath:string) {
|
||||
this._proxy = threadService.get(MainContext.MainThreadWorkspace);
|
||||
this._workspacePath = workspacePath;
|
||||
}
|
||||
|
||||
@@ -85,7 +86,6 @@ export class ExtHostWorkspace {
|
||||
}
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainThreadWorkspace')
|
||||
export class MainThreadWorkspace {
|
||||
|
||||
private _activeSearches: { [id: number]: TPromise<Uri[]> } = Object.create(null);
|
||||
|
||||
@@ -15,8 +15,9 @@ import {ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegist
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {ExtHostStorage} from 'vs/workbench/api/node/extHostStorage';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IThreadService, Remotable} from 'vs/platform/thread/common/thread';
|
||||
import {IThreadService} from 'vs/platform/thread/common/thread';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {MainContext, ExtHostContext} from './extHostProtocol';
|
||||
|
||||
const hasOwnProperty = Object.hasOwnProperty;
|
||||
|
||||
@@ -43,7 +44,6 @@ function messageWithSource(msg:IMessage): string {
|
||||
return (msg.source ? '[' + msg.source + ']: ' : '') + msg.message;
|
||||
}
|
||||
|
||||
@Remotable.MainContext('MainProcessExtensionService')
|
||||
export class MainProcessExtensionService extends AbstractExtensionService<ActivatedExtension> {
|
||||
|
||||
private _threadService: IThreadService;
|
||||
@@ -65,9 +65,8 @@ export class MainProcessExtensionService extends AbstractExtensionService<Activa
|
||||
this._isDev = !config.env.isBuilt || !!config.env.extensionDevelopmentPath;
|
||||
|
||||
this._messageService = messageService;
|
||||
threadService.registerRemotableInstance(MainProcessExtensionService, this);
|
||||
this._threadService = threadService;
|
||||
this._proxy = this._threadService.getRemotable(ExtHostExtensionService);
|
||||
this._proxy = this._threadService.get(ExtHostContext.ExtHostExtensionService);
|
||||
this._extensionsStatus = {};
|
||||
|
||||
ExtensionsRegistry.handleExtensionPoints((msg) => this._handleMessage(msg));
|
||||
@@ -238,7 +237,6 @@ export interface IExtensionContext {
|
||||
asAbsolutePath(relativePath: string): string;
|
||||
}
|
||||
|
||||
@Remotable.ExtHostContext('ExtHostExtensionService')
|
||||
export class ExtHostExtensionService extends AbstractExtensionService<ExtHostExtension> {
|
||||
|
||||
private _threadService: IThreadService;
|
||||
@@ -252,10 +250,9 @@ export class ExtHostExtensionService extends AbstractExtensionService<ExtHostExt
|
||||
*/
|
||||
constructor(threadService: IThreadService, telemetryService: ITelemetryService, args: { serviceId: any; workspaceStoragePath: string; }) {
|
||||
super(false);
|
||||
threadService.registerRemotableInstance(ExtHostExtensionService, this);
|
||||
this._threadService = threadService;
|
||||
this._storage = new ExtHostStorage(threadService);
|
||||
this._proxy = this._threadService.getRemotable(MainProcessExtensionService);
|
||||
this._proxy = this._threadService.get(MainContext.MainProcessExtensionService);
|
||||
this._telemetryService = telemetryService;
|
||||
this._workspaceStoragePath = args.workspaceStoragePath;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user