提交 c2653380 编写于 作者: S Sandeep Somavarapu

move getting environment from remote agent service to remote environment service

上级 e764acdb
......@@ -123,7 +123,7 @@ export class TerminalProcessManager implements ITerminalProcessManager {
this.os = platform.OS;
if (launchRemotely) {
if (hasRemoteAuthority) {
this._remoteEnvironmentService.remoteEnvironment.then(env => {
this._remoteEnvironmentService.getEnvironment().then(env => {
if (!env) {
return;
}
......
......@@ -111,7 +111,7 @@ export class RemoteFileDialog {
private async getOptions(options: ISaveDialogOptions | IOpenDialogOptions): Promise<IOpenDialogOptions | undefined> {
let defaultUri = options.defaultUri;
if (!defaultUri) {
const env = await this.remoteEnvironmentService.remoteEnvironment;
const env = await this.remoteEnvironmentService.getEnvironment();
if (env) {
defaultUri = env.userHome;
} else {
......
......@@ -14,12 +14,12 @@ import { URI } from 'vs/base/common/uri';
import { Disposable } from 'vs/base/common/lifecycle';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { getManifest } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { localize } from 'vs/nls';
import { isUIExtension } from 'vs/workbench/services/extensions/node/extensionsUtil';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IRemoteEnvironmentService } from 'vs/workbench/services/remote/common/remoteEnvironmentService';
export class MultiExtensionManagementService extends Disposable implements IExtensionManagementService {
......@@ -36,7 +36,7 @@ export class MultiExtensionManagementService extends Disposable implements IExte
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@IExtensionGalleryService private readonly extensionGalleryService: IExtensionGalleryService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService
@IRemoteEnvironmentService private readonly remoteEnvironmentService: IRemoteEnvironmentService
) {
super();
this.servers = this.extensionManagementServerService.remoteExtensionManagementServer ? [this.extensionManagementServerService.localExtensionManagementServer, this.extensionManagementServerService.remoteExtensionManagementServer] : [this.extensionManagementServerService.localExtensionManagementServer];
......@@ -204,16 +204,10 @@ export class MultiExtensionManagementService extends Disposable implements IExte
if (!this.extensionManagementServerService.remoteExtensionManagementServer) {
return false;
}
const connection = this.remoteAgentService.getConnection();
if (!connection) {
return false;
}
const remoteEnv = await connection.getEnvironment();
const remoteEnv = await this.remoteEnvironmentService.getEnvironment();
if (!remoteEnv) {
return false;
}
return remoteEnv.syncExtensions;
}
}
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IRemoteAgentEnvironment, RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
export const RemoteExtensionLogFileName = 'remoteagent';
......@@ -20,8 +20,6 @@ export interface IRemoteAgentService {
export interface IRemoteAgentConnection {
readonly remoteAuthority: string;
getEnvironment(): Promise<IRemoteAgentEnvironment | null>;
getChannel<T extends IChannel>(channelName: string): T;
registerChannel<T extends IServerChannel<RemoteAgentConnectionContext>>(channelName: string, channel: T): void;
}
......@@ -3,32 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export interface IRemoteEnvironmentService {
_serviceBrand: any;
remoteEnvironment: Promise<IRemoteAgentEnvironment | null>;
getEnvironment(): Promise<IRemoteAgentEnvironment | null>;
}
export const IRemoteEnvironmentService = createDecorator<IRemoteEnvironmentService>('remoteEnvironmentService');
export class RemoteEnvironmentService implements IRemoteEnvironmentService {
_serviceBrand: any;
constructor(
@IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService,
) { }
get remoteEnvironment(): Promise<IRemoteAgentEnvironment | null> {
const connection = this.remoteAgentService.getConnection();
if (connection) {
return connection.getEnvironment();
}
return Promise.resolve(null);
}
}
registerSingleton(IRemoteEnvironmentService, RemoteEnvironmentService, true);
\ No newline at end of file
export const IRemoteEnvironmentService = createDecorator<IRemoteEnvironmentService>('remoteEnvironmentService');
\ No newline at end of file
......@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { Disposable } from 'vs/base/common/lifecycle';
import { getDelayedChannel } from 'vs/base/parts/ipc/node/ipc';
import { Client } from 'vs/base/parts/ipc/node/ipc.net';
......@@ -11,7 +10,6 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { INotificationService } from 'vs/platform/notification/common/notification';
import { connectRemoteAgentManagement } from 'vs/platform/remote/node/remoteAgentConnection';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { RemoteExtensionEnvironmentChannelClient } from 'vs/workbench/services/remote/node/remoteAgentEnvironmentChannel';
import { IRemoteAgentConnection, IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
......@@ -21,7 +19,7 @@ import { DownloadServiceChannel } from 'vs/platform/download/node/downloadIpc';
import { LogLevelSetterChannel } from 'vs/platform/log/node/logIpc';
import { ILogService } from 'vs/platform/log/common/log';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IRemoteAgentEnvironment, RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions } from 'vs/workbench/common/contributions';
import { Registry } from 'vs/platform/registry/common/platform';
......@@ -40,7 +38,7 @@ export class RemoteAgentService implements IRemoteAgentService {
) {
const { remoteAuthority } = windowService.getConfiguration();
if (remoteAuthority) {
this._connection = new RemoteAgentConnection(remoteAuthority, notificationService, environmentService, remoteAuthorityResolverService);
this._connection = new RemoteAgentConnection(remoteAuthority, environmentService, remoteAuthorityResolverService);
}
}
......@@ -53,29 +51,15 @@ class RemoteAgentConnection extends Disposable implements IRemoteAgentConnection
readonly remoteAuthority: string;
private _connection: Promise<Client<RemoteAgentConnectionContext>> | null;
private _environment: Promise<IRemoteAgentEnvironment | null> | null;
constructor(
remoteAuthority: string,
private _notificationService: INotificationService,
private _environmentService: IEnvironmentService,
private _remoteAuthorityResolverService: IRemoteAuthorityResolverService
) {
super();
this.remoteAuthority = remoteAuthority;
this._connection = null;
this._environment = null;
}
getEnvironment(): Promise<IRemoteAgentEnvironment | null> {
if (!this._environment) {
const client = new RemoteExtensionEnvironmentChannelClient(this.getChannel('remoteextensionsenvironment'));
// Let's cover the case where connecting to fetch the remote extension info fails
this._environment = client.getEnvironmentData(this.remoteAuthority, this._environmentService.extensionDevelopmentLocationURI)
.then(undefined, err => { this._notificationService.error(localize('connectionError', "Failed to connect to the remote extension host agent (Error: {0})", err ? err.message : '')); return null; });
}
return this._environment;
}
getChannel<T extends IChannel>(channelName: string): T {
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { RemoteExtensionEnvironmentChannelClient } from 'vs/workbench/services/remote/node/remoteAgentEnvironmentChannel';
import { IRemoteEnvironmentService } from 'vs/workbench/services/remote/common/remoteEnvironmentService';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { localize } from 'vs/nls';
export class RemoteEnvironmentService implements IRemoteEnvironmentService {
_serviceBrand: any;
private _environment: Promise<IRemoteAgentEnvironment | null> | null;
constructor(
@IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@INotificationService private readonly notificationService: INotificationService,
) { }
getEnvironment(): Promise<IRemoteAgentEnvironment | null> {
if (!this._environment) {
const connection = this.remoteAgentService.getConnection();
if (connection) {
const client = new RemoteExtensionEnvironmentChannelClient(connection.getChannel('remoteextensionsenvironment'));
// Let's cover the case where connecting to fetch the remote extension info fails
this._environment = client.getEnvironmentData(connection.remoteAuthority, this.environmentService.extensionDevelopmentLocationURI)
.then(undefined, err => { this.notificationService.error(localize('connectionError', "Failed to connect to the remote extension host agent (Error: {0})", err ? err.message : '')); return null; });
} else {
this._environment = Promise.resolve(null);
}
}
return this._environment;
}
}
registerSingleton(IRemoteEnvironmentService, RemoteEnvironmentService, true);
\ No newline at end of file
......@@ -7,12 +7,12 @@ import { URI } from 'vs/base/common/uri';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { OperatingSystem, OS } from 'vs/base/common/platform';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { Schemas } from 'vs/base/common/network';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { IRemoteEnvironmentService } from 'vs/workbench/services/remote/common/remoteEnvironmentService';
export class TextResourcePropertiesService implements ITextResourcePropertiesService {
......@@ -22,14 +22,11 @@ export class TextResourcePropertiesService implements ITextResourcePropertiesSer
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService,
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
@IRemoteEnvironmentService remoteEnvironmentService: IRemoteEnvironmentService,
@IWindowService private readonly windowService: IWindowService,
@IStorageService private readonly storageService: IStorageService
) {
const remoteAgentConnection = remoteAgentService.getConnection();
if (remoteAgentConnection) {
remoteAgentConnection.getEnvironment().then(remoteEnv => this.remoteEnvironment = remoteEnv);
}
remoteEnvironmentService.getEnvironment().then(remoteEnv => this.remoteEnvironment = remoteEnv);
}
getEOL(resource: URI, language?: string): string {
......
......@@ -133,7 +133,7 @@ import 'vs/workbench/services/label/common/labelService';
import 'vs/workbench/services/extensions/electron-browser/extensionManagementServerService';
import 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl';
import 'vs/workbench/services/notification/common/notificationService';
import 'vs/workbench/services/remote/common/remoteEnvironmentService';
import 'vs/workbench/services/remote/electron-browser/remoteEnvironmentServiceImpl';
import 'vs/workbench/services/heap/node/heap';
registerSingleton(IMenuService, MenuService, true);
......
......@@ -137,7 +137,7 @@ import 'vs/workbench/services/label/common/labelService';
// import 'vs/workbench/services/extensions/electron-browser/extensionManagementServerService';
// import 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl';
import 'vs/workbench/services/notification/common/notificationService';
import 'vs/workbench/services/remote/common/remoteEnvironmentService';
import 'vs/workbench/services/remote/electron-browser/remoteEnvironmentServiceImpl';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册