Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/agentHost/common/agentHostFileSystemService.ts
13394 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Disposable, IDisposable } from '../../../base/common/lifecycle.js';
7
import { IFileService } from '../../files/common/files.js';
8
import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';
9
import { createDecorator } from '../../instantiation/common/instantiation.js';
10
import { ILabelService } from '../../label/common/label.js';
11
import { AgentHostFileSystemProvider, type IRemoteFilesystemConnection } from './agentHostFileSystemProvider.js';
12
import { AGENT_HOST_LABEL_FORMATTER, AGENT_HOST_SCHEME } from './agentHostUri.js';
13
14
export type { IRemoteFilesystemConnection } from './agentHostFileSystemProvider.js';
15
16
export const IAgentHostFileSystemService = createDecorator<IAgentHostFileSystemService>('agentHostFileSystemService');
17
18
export interface IAgentHostFileSystemService {
19
readonly _serviceBrand: undefined;
20
21
/**
22
* Register a mapping from a URI authority to a connection so that
23
* `vscode-agent-host://[authority]/…` URIs resolve through this connection.
24
*/
25
registerAuthority(authority: string, connection: IRemoteFilesystemConnection): IDisposable;
26
}
27
28
class AgentHostFileSystemService extends Disposable implements IAgentHostFileSystemService {
29
declare readonly _serviceBrand: undefined;
30
31
private readonly _fsProvider: AgentHostFileSystemProvider;
32
33
constructor(
34
@IFileService fileService: IFileService,
35
@ILabelService labelService: ILabelService,
36
) {
37
super();
38
39
this._fsProvider = this._register(new AgentHostFileSystemProvider());
40
this._register(fileService.registerProvider(AGENT_HOST_SCHEME, this._fsProvider));
41
this._register(labelService.registerFormatter(AGENT_HOST_LABEL_FORMATTER));
42
}
43
44
registerAuthority(authority: string, connection: IRemoteFilesystemConnection): IDisposable {
45
return this._fsProvider.registerAuthority(authority, connection);
46
}
47
}
48
49
registerSingleton(IAgentHostFileSystemService, AgentHostFileSystemService, InstantiationType.Delayed);
50
51