Making IFileChange readonly

This commit is contained in:
Matt Bierner
2019-09-25 18:30:03 -07:00
parent af4e34851f
commit c25e7e90f0
10 changed files with 27 additions and 22 deletions

View File

@@ -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;

View File

@@ -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>();

View File

@@ -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;
}
}
}

View 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;

View File

@@ -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(() => {

View File

@@ -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)); }