mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 011858832762aaff245b2336fb1c38166e7a10fb (#4663)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IRemoteAgentEnvironment, RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
|
||||
import { RemoteAgentConnectionContext, IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
|
||||
export const RemoteExtensionLogFileName = 'remoteagent';
|
||||
@@ -15,13 +15,12 @@ export interface IRemoteAgentService {
|
||||
_serviceBrand: any;
|
||||
|
||||
getConnection(): IRemoteAgentConnection | null;
|
||||
getEnvironment(): Promise<IRemoteAgentEnvironment | null>;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. 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>;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -3,86 +3,72 @@
|
||||
* Licensed under the Source EULA. 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';
|
||||
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 { IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
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';
|
||||
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { DialogChannel } from 'vs/platform/dialogs/node/dialogIpc';
|
||||
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 { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { RemoteAgentConnectionContext, IRemoteAgentEnvironment } 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';
|
||||
import { RemoteExtensionEnvironmentChannelClient } from 'vs/workbench/services/remote/node/remoteAgentEnvironmentChannel';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export class RemoteAgentService implements IRemoteAgentService {
|
||||
export class RemoteAgentService extends Disposable implements IRemoteAgentService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly _connection: IRemoteAgentConnection | null = null;
|
||||
private _environment: Promise<IRemoteAgentEnvironment | null> | null;
|
||||
|
||||
constructor(
|
||||
@IWindowService windowService: IWindowService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@IRemoteAuthorityResolverService remoteAuthorityResolverService: IRemoteAuthorityResolverService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@ILogService logService: ILogService,
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
{ remoteAuthority }: IWindowConfiguration,
|
||||
@IEnvironmentService private readonly _environmentService: IEnvironmentService,
|
||||
@IRemoteAuthorityResolverService remoteAuthorityResolverService: IRemoteAuthorityResolverService
|
||||
) {
|
||||
const { remoteAuthority } = windowService.getConfiguration();
|
||||
super();
|
||||
if (remoteAuthority) {
|
||||
const connection = this._connection = new RemoteAgentConnection(remoteAuthority, notificationService, environmentService, remoteAuthorityResolverService);
|
||||
|
||||
lifecycleService.when(LifecyclePhase.Ready).then(() => {
|
||||
connection.registerChannel('dialog', instantiationService.createInstance(DialogChannel));
|
||||
connection.registerChannel('download', new DownloadServiceChannel());
|
||||
connection.registerChannel('loglevel', new LogLevelSetterChannel(logService));
|
||||
});
|
||||
this._connection = this._register(new RemoteAgentConnection(remoteAuthority, _environmentService, remoteAuthorityResolverService));
|
||||
}
|
||||
}
|
||||
|
||||
getConnection(): IRemoteAgentConnection | null {
|
||||
return this._connection;
|
||||
}
|
||||
|
||||
getEnvironment(bail?: boolean): Promise<IRemoteAgentEnvironment | null> {
|
||||
if (!this._environment) {
|
||||
const connection = this.getConnection();
|
||||
if (connection) {
|
||||
const client = new RemoteExtensionEnvironmentChannelClient(connection.getChannel('remoteextensionsenvironment'));
|
||||
this._environment = client.getEnvironmentData(connection.remoteAuthority, this._environmentService.extensionDevelopmentLocationURI);
|
||||
} else {
|
||||
this._environment = Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
return bail ? this._environment : this._environment.then(undefined, () => null);
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -108,4 +94,18 @@ class RemoteAgentConnection extends Disposable implements IRemoteAgentConnection
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IRemoteAgentService, RemoteAgentService);
|
||||
class RemoteConnectionFailureNotificationContribution implements IWorkbenchContribution {
|
||||
|
||||
constructor(
|
||||
@IRemoteAgentService remoteAgentService: RemoteAgentService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
) {
|
||||
// Let's cover the case where connecting to fetch the remote extension info fails
|
||||
remoteAgentService.getEnvironment(true)
|
||||
.then(undefined, err => notificationService.error(localize('connectionError', "Failed to connect to the remote extension host agent (Error: {0})", err ? err.message : '')));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench);
|
||||
workbenchRegistry.registerWorkbenchContribution(RemoteConnectionFailureNotificationContribution, LifecyclePhase.Ready);
|
||||
@@ -19,6 +19,7 @@ export interface IRemoteAgentEnvironmentDTO {
|
||||
pid: number;
|
||||
appRoot: UriComponents;
|
||||
appSettingsHome: UriComponents;
|
||||
appSettingsPath: UriComponents;
|
||||
logsPath: UriComponents;
|
||||
extensionsPath: UriComponents;
|
||||
extensionHostLogsPath: UriComponents;
|
||||
@@ -45,6 +46,7 @@ export class RemoteExtensionEnvironmentChannelClient {
|
||||
pid: data.pid,
|
||||
appRoot: URI.revive(data.appRoot),
|
||||
appSettingsHome: URI.revive(data.appSettingsHome),
|
||||
appSettingsPath: URI.revive(data.appSettingsPath),
|
||||
logsPath: URI.revive(data.logsPath),
|
||||
extensionsPath: URI.revive(data.extensionsPath),
|
||||
extensionHostLogsPath: URI.revive(data.extensionHostLogsPath),
|
||||
|
||||
Reference in New Issue
Block a user