mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-29 00:00:29 -04:00
Merge from master
This commit is contained in:
24
src/vs/platform/remote/common/remoteAuthorityResolver.ts
Normal file
24
src/vs/platform/remote/common/remoteAuthorityResolver.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const IRemoteAuthorityResolverService = createDecorator<IRemoteAuthorityResolverService>('remoteAuthorityResolverService');
|
||||
|
||||
export interface ResolvedAuthority {
|
||||
readonly authority: string;
|
||||
readonly host: string;
|
||||
readonly port: number;
|
||||
readonly syncExtensions: boolean;
|
||||
}
|
||||
|
||||
export interface IRemoteAuthorityResolverService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
resolveAuthority(authority: string): Thenable<ResolvedAuthority>;
|
||||
|
||||
setResolvedAuthority(resolvedAuthority: ResolvedAuthority): void;
|
||||
}
|
||||
12
src/vs/platform/remote/common/remoteHosts.ts
Normal file
12
src/vs/platform/remote/common/remoteHosts.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
export const REMOTE_HOST_SCHEME = 'vscode-remote';
|
||||
|
||||
export function getRemoteAuthority(uri: URI) {
|
||||
return uri.scheme === REMOTE_HOST_SCHEME ? uri.authority : void 0;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ResolvedAuthority, IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
import { ipcRenderer as ipc } from 'electron';
|
||||
|
||||
class PendingResolveAuthorityRequest {
|
||||
constructor(
|
||||
public readonly resolve: (value: ResolvedAuthority) => void,
|
||||
public readonly reject: (err: any) => void,
|
||||
public readonly promise: Promise<ResolvedAuthority>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
export class RemoteAuthorityResolverService implements IRemoteAuthorityResolverService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private _pendingResolveAuthorityRequests: { [authority: string]: PendingResolveAuthorityRequest; };
|
||||
private _resolvedAuthorities: { [authority: string]: ResolvedAuthority; };
|
||||
|
||||
constructor() {
|
||||
this._pendingResolveAuthorityRequests = Object.create(null);
|
||||
this._resolvedAuthorities = Object.create(null);
|
||||
}
|
||||
|
||||
resolveAuthority(authority: string): Thenable<ResolvedAuthority> {
|
||||
if (this._resolvedAuthorities[authority]) {
|
||||
return Promise.resolve(this._resolvedAuthorities[authority]);
|
||||
}
|
||||
if (!this._pendingResolveAuthorityRequests[authority]) {
|
||||
let resolve: (value: ResolvedAuthority) => void;
|
||||
let reject: (err: any) => void;
|
||||
let promise = new Promise<ResolvedAuthority>((_resolve, _reject) => {
|
||||
resolve = _resolve;
|
||||
reject = _reject;
|
||||
});
|
||||
this._pendingResolveAuthorityRequests[authority] = new PendingResolveAuthorityRequest(resolve!, reject!, promise);
|
||||
}
|
||||
return this._pendingResolveAuthorityRequests[authority].promise;
|
||||
}
|
||||
|
||||
setResolvedAuthority(resolvedAuthority: ResolvedAuthority) {
|
||||
this._resolvedAuthorities[resolvedAuthority.authority] = resolvedAuthority;
|
||||
if (this._pendingResolveAuthorityRequests[resolvedAuthority.authority]) {
|
||||
let request = this._pendingResolveAuthorityRequests[resolvedAuthority.authority];
|
||||
delete this._pendingResolveAuthorityRequests[resolvedAuthority.authority];
|
||||
ipc.send('vscode:remoteAuthorityResolved', resolvedAuthority);
|
||||
request.resolve(resolvedAuthority);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
src/vs/platform/remote/node/remoteAgentConnection.ts
Normal file
26
src/vs/platform/remote/node/remoteAgentConnection.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Client, Protocol } from 'vs/base/parts/ipc/node/ipc.net';
|
||||
import { IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
|
||||
|
||||
export interface RemoteAgentConnectionContext {
|
||||
remoteAuthority: string;
|
||||
clientId: string;
|
||||
}
|
||||
|
||||
export function connectRemoteAgentManagement(remoteAuthority: string, host: string, port: number, clientId: string): TPromise<Client<RemoteAgentConnectionContext>> {
|
||||
throw new Error(`Not implemented`);
|
||||
}
|
||||
|
||||
export interface IExtensionHostConnectionResult {
|
||||
protocol: Protocol;
|
||||
debugPort?: number;
|
||||
}
|
||||
|
||||
export function connectRemoteAgentExtensionHost(host: string, port: number, debugArguments: IExtensionHostDebugParams): TPromise<IExtensionHostConnectionResult> {
|
||||
throw new Error(`Not implemented`);
|
||||
}
|
||||
110
src/vs/platform/remote/node/remoteAgentFileSystemChannel.ts
Normal file
110
src/vs/platform/remote/node/remoteAgentFileSystemChannel.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IChannel } from 'vs/base/parts/ipc/node/ipc';
|
||||
import { FileChangeType, FileDeleteOptions, FileOverwriteOptions, FileSystemProviderCapabilities, FileType, FileWriteOptions, IFileChange, IFileSystemProvider, IStat, IWatchOptions } from 'vs/platform/files/common/files';
|
||||
|
||||
export const REMOTE_FILE_SYSTEM_CHANNEL_NAME = 'remotefilesystem';
|
||||
|
||||
export interface IFileChangeDto {
|
||||
resource: UriComponents;
|
||||
type: FileChangeType;
|
||||
}
|
||||
|
||||
export class RemoteExtensionsFileSystemProvider extends Disposable implements IFileSystemProvider {
|
||||
|
||||
private readonly _session: string;
|
||||
private readonly _channel: IChannel;
|
||||
|
||||
private readonly _onDidChange = this._register(new Emitter<IFileChange[]>());
|
||||
readonly onDidChangeFile: Event<IFileChange[]> = this._onDidChange.event;
|
||||
|
||||
public capabilities: FileSystemProviderCapabilities;
|
||||
private readonly _onDidChangeCapabilities = this._register(new Emitter<void>());
|
||||
readonly onDidChangeCapabilities: Event<void> = this._onDidChangeCapabilities.event;
|
||||
|
||||
constructor(channel: IChannel) {
|
||||
super();
|
||||
this._session = generateUuid();
|
||||
this._channel = channel;
|
||||
|
||||
this.setCaseSensitive(true);
|
||||
|
||||
this._channel.listen<IFileChangeDto[]>('filechange', [this._session])((events) => {
|
||||
this._onDidChange.fire(events.map(RemoteExtensionsFileSystemProvider._createFileChange));
|
||||
});
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
setCaseSensitive(isCaseSensitive: boolean) {
|
||||
let capabilities = (
|
||||
FileSystemProviderCapabilities.FileReadWrite
|
||||
| FileSystemProviderCapabilities.FileFolderCopy
|
||||
);
|
||||
if (isCaseSensitive) {
|
||||
capabilities |= FileSystemProviderCapabilities.PathCaseSensitive;
|
||||
}
|
||||
this.capabilities = capabilities;
|
||||
this._onDidChangeCapabilities.fire(void 0);
|
||||
}
|
||||
|
||||
watch(resource: URI, opts: IWatchOptions): IDisposable {
|
||||
const req = Math.random();
|
||||
this._channel.call('watch', [this._session, req, resource, opts]);
|
||||
return toDisposable(() => {
|
||||
this._channel.call('unwatch', [this._session, req]);
|
||||
});
|
||||
}
|
||||
|
||||
private static _createFileChange(dto: IFileChangeDto): IFileChange {
|
||||
return { resource: URI.revive(dto.resource), type: dto.type };
|
||||
}
|
||||
|
||||
// --- forwarding calls
|
||||
|
||||
private static _asBuffer(data: Uint8Array): Buffer {
|
||||
return Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
||||
}
|
||||
|
||||
stat(resource: URI): Thenable<IStat> {
|
||||
return this._channel.call('stat', [resource]);
|
||||
}
|
||||
|
||||
readFile(resource: URI): Thenable<Uint8Array> {
|
||||
return this._channel.call('readFile', [resource]);
|
||||
}
|
||||
|
||||
writeFile(resource: URI, content: Uint8Array, opts: FileWriteOptions): Thenable<void> {
|
||||
const contents = RemoteExtensionsFileSystemProvider._asBuffer(content);
|
||||
return this._channel.call('writeFile', [resource, contents, opts]);
|
||||
}
|
||||
|
||||
delete(resource: URI, opts: FileDeleteOptions): Thenable<void> {
|
||||
return this._channel.call('delete', [resource, opts]);
|
||||
}
|
||||
|
||||
mkdir(resource: URI): Thenable<void> {
|
||||
return this._channel.call('mkdir', [resource]);
|
||||
}
|
||||
|
||||
readdir(resource: URI): Thenable<[string, FileType][]> {
|
||||
return this._channel.call('readdir', [resource]);
|
||||
}
|
||||
|
||||
rename(resource: URI, target: URI, opts: FileOverwriteOptions): Thenable<void> {
|
||||
return this._channel.call('rename', [resource, target, opts]);
|
||||
}
|
||||
|
||||
copy(resource: URI, target: URI, opts: FileOverwriteOptions): Thenable<void> {
|
||||
return this._channel.call('copy', [resource, target, opts]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user