提交 c25e7e90 编写于 作者: M Matt Bierner

Making IFileChange readonly

上级 af4e3485
......@@ -209,7 +209,7 @@ export interface IFileSystemProvider {
readonly onDidErrorOccur?: Event<string>; // TODO@ben remove once file watchers are solid
readonly onDidChangeFile: Event<IFileChange[]>;
readonly onDidChangeFile: Event<readonly IFileChange[]>;
watch(resource: URI, opts: IWatchOptions): IDisposable;
stat(resource: URI): Promise<IStat>;
......@@ -389,12 +389,12 @@ export interface IFileChange {
/**
* The type of change that occurred to the file.
*/
type: FileChangeType;
readonly type: FileChangeType;
/**
* The unified resource identifier of the file that changed.
*/
resource: URI;
readonly resource: URI;
}
export class FileChangesEvent {
......
......@@ -449,8 +449,8 @@ export class DiskFileSystemProvider extends Disposable implements IFileSystemPro
private _onDidWatchErrorOccur: Emitter<string> = this._register(new Emitter<string>());
readonly onDidErrorOccur: Event<string> = this._onDidWatchErrorOccur.event;
private _onDidChangeFile: Emitter<IFileChange[]> = this._register(new Emitter<IFileChange[]>());
get onDidChangeFile(): Event<IFileChange[]> { return this._onDidChangeFile.event; }
private _onDidChangeFile = this._register(new Emitter<readonly IFileChange[]>());
get onDidChangeFile(): Event<readonly IFileChange[]> { return this._onDidChangeFile.event; }
private recursiveWatcher: WindowsWatcherService | UnixWatcherService | NsfwWatcherService | undefined;
private recursiveFoldersToWatch: { path: string, excludes: string[] }[] = [];
......
......@@ -13,7 +13,7 @@ export class NullFileSystemProvider implements IFileSystemProvider {
capabilities: FileSystemProviderCapabilities = FileSystemProviderCapabilities.Readonly;
onDidChangeCapabilities: Event<void> = Event.None;
onDidChangeFile: Event<IFileChange[]> = Event.None;
onDidChangeFile: Event<readonly IFileChange[]> = Event.None;
constructor(private disposableFactory: () => IDisposable = () => Disposable.None) { }
......@@ -30,4 +30,4 @@ export class NullFileSystemProvider implements IFileSystemProvider {
close?(fd: number): Promise<void> { return Promise.resolve(undefined!); }
read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return Promise.resolve(undefined!); }
write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return Promise.resolve(undefined!); }
}
\ No newline at end of file
}
......@@ -24,8 +24,8 @@ export class RemoteExtensionsFileSystemProvider extends Disposable implements IF
private readonly session: string = generateUuid();
private readonly _onDidChange = this._register(new Emitter<IFileChange[]>());
readonly onDidChangeFile: Event<IFileChange[]> = this._onDidChange.event;
private readonly _onDidChange = this._register(new Emitter<readonly IFileChange[]>());
readonly onDidChangeFile: Event<readonly IFileChange[]> = this._onDidChange.event;
private _onDidWatchErrorOccur: Emitter<string> = this._register(new Emitter<string>());
readonly onDidErrorOccur: Event<string> = this._onDidWatchErrorOccur.event;
......
......@@ -123,10 +123,10 @@ export class MainThreadFileSystem implements MainThreadFileSystemShape {
class RemoteFileSystemProvider implements IFileSystemProvider {
private readonly _onDidChange = new Emitter<IFileChange[]>();
private readonly _onDidChange = new Emitter<readonly IFileChange[]>();
private readonly _registration: IDisposable;
readonly onDidChangeFile: Event<IFileChange[]> = this._onDidChange.event;
readonly onDidChangeFile: Event<readonly IFileChange[]> = this._onDidChange.event;
readonly capabilities: FileSystemProviderCapabilities;
readonly onDidChangeCapabilities: Event<void> = Event.None;
......
......@@ -17,8 +17,8 @@ export abstract class KeyValueLogProvider extends Disposable implements IFileSys
readonly capabilities: FileSystemProviderCapabilities = FileSystemProviderCapabilities.FileReadWrite;
readonly onDidChangeCapabilities: Event<void> = Event.None;
private readonly _onDidChangeFile: Emitter<IFileChange[]> = this._register(new Emitter<IFileChange[]>());
readonly onDidChangeFile: Event<IFileChange[]> = this._onDidChangeFile.event;
private readonly _onDidChangeFile = this._register(new Emitter<readonly IFileChange[]>());
readonly onDidChangeFile: Event<readonly IFileChange[]> = this._onDidChangeFile.event;
private readonly versions: Map<string, number> = new Map<string, number>();
......
......@@ -17,8 +17,8 @@ export class FileUserDataProvider extends Disposable implements IFileSystemProvi
readonly capabilities: FileSystemProviderCapabilities = this.fileSystemProvider.capabilities;
readonly onDidChangeCapabilities: Event<void> = Event.None;
private readonly _onDidChangeFile: Emitter<IFileChange[]> = this._register(new Emitter<IFileChange[]>());
readonly onDidChangeFile: Event<IFileChange[]> = this._onDidChangeFile.event;
private readonly _onDidChangeFile = this._register(new Emitter<readonly IFileChange[]>());
readonly onDidChangeFile: Event<readonly IFileChange[]> = this._onDidChangeFile.event;
private readonly userDataHome: URI;
......@@ -103,7 +103,7 @@ export class FileUserDataProvider extends Disposable implements IFileSystemProvi
return this.fileSystemProvider.delete(this.toFileSystemResource(resource), opts);
}
private handleFileChanges(changes: IFileChange[]): void {
private handleFileChanges(changes: readonly IFileChange[]): void {
const userDataChanges: IFileChange[] = [];
for (const change of changes) {
const userDataResource = this.toUserDataResource(change.resource);
......@@ -139,4 +139,4 @@ export class FileUserDataProvider extends Disposable implements IFileSystemProvi
return null;
}
}
\ No newline at end of file
}
......@@ -205,8 +205,8 @@ export class InMemoryFileSystemProvider extends Disposable implements IFileSyste
// --- manage file events
private readonly _onDidChangeFile: Emitter<IFileChange[]> = this._register(new Emitter<IFileChange[]>());
readonly onDidChangeFile: Event<IFileChange[]> = this._onDidChangeFile.event;
private readonly _onDidChangeFile = this._register(new Emitter<readonly IFileChange[]>());
readonly onDidChangeFile: Event<readonly IFileChange[]> = this._onDidChangeFile.event;
private _bufferedChanges: IFileChange[] = [];
private _fireSoonHandle?: any;
......
......@@ -277,7 +277,7 @@ suite('FileUserDataProvider', () => {
class TestFileSystemProvider implements IFileSystemProviderWithFileReadWriteCapability {
constructor(readonly onDidChangeFile: Event<IFileChange[]>) { }
constructor(readonly onDidChangeFile: Event<readonly IFileChange[]>) { }
readonly capabilities: FileSystemProviderCapabilities = FileSystemProviderCapabilities.FileReadWrite;
......@@ -309,7 +309,7 @@ suite('FileUserDataProvider - Watching', () => {
let userDataResource: URI;
const disposables = new DisposableStore();
const fileEventEmitter: Emitter<IFileChange[]> = new Emitter<IFileChange[]>();
const fileEventEmitter: Emitter<readonly IFileChange[]> = new Emitter<readonly IFileChange[]>();
disposables.add(fileEventEmitter);
setup(() => {
......
......@@ -1346,7 +1346,12 @@ export class RemoteFileSystemProvider implements IFileSystemProvider {
readonly capabilities: FileSystemProviderCapabilities = this.diskFileSystemProvider.capabilities;
readonly onDidChangeCapabilities: Event<void> = this.diskFileSystemProvider.onDidChangeCapabilities;
readonly onDidChangeFile: Event<IFileChange[]> = Event.map(this.diskFileSystemProvider.onDidChangeFile, changes => changes.map(c => { c.resource = c.resource.with({ scheme: Schemas.vscodeRemote, authority: this.remoteAuthority }); return c; }));
readonly onDidChangeFile: Event<readonly IFileChange[]> = Event.map(this.diskFileSystemProvider.onDidChangeFile, changes => changes.map((c): IFileChange => {
return {
type: c.type,
resource: c.resource.with({ scheme: Schemas.vscodeRemote, authority: this.remoteAuthority }),
};
}));
watch(resource: URI, opts: IWatchOptions): IDisposable { return this.diskFileSystemProvider.watch(this.toFileResource(resource), opts); }
stat(resource: URI): Promise<IStat> { return this.diskFileSystemProvider.stat(this.toFileResource(resource)); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册