提交 954d03fd 编写于 作者: B Benjamin Pasero

files - rename events to follow conventions

上级 92df7a03
......@@ -352,7 +352,7 @@ export class UserSettings extends Disposable {
super();
this.parser = new ConfigurationModelParser(this.userSettingsResource.toString(), this.scopes);
this._register(this.fileService.watch(dirname(this.userSettingsResource)));
this._register(Event.filter(this.fileService.onFileChanges, e => e.contains(this.userSettingsResource))(() => this._onDidChange.fire()));
this._register(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.userSettingsResource))(() => this._onDidChange.fire()));
}
async loadConfiguration(): Promise<ConfigurationModel> {
......
......@@ -55,7 +55,7 @@ export class FileService extends Disposable implements IFileService {
// Forward events from provider
const providerDisposables = new DisposableStore();
providerDisposables.add(provider.onDidChangeFile(changes => this._onFileChanges.fire(new FileChangesEvent(changes))));
providerDisposables.add(provider.onDidChangeFile(changes => this._onDidFilesChange.fire(new FileChangesEvent(changes))));
providerDisposables.add(provider.onDidChangeCapabilities(() => this._onDidChangeFileSystemProviderCapabilities.fire({ provider, scheme })));
if (typeof provider.onDidErrorOccur === 'function') {
providerDisposables.add(provider.onDidErrorOccur(error => this._onError.fire(new Error(error))));
......@@ -147,11 +147,11 @@ export class FileService extends Disposable implements IFileService {
//#endregion
private _onAfterOperation: Emitter<FileOperationEvent> = this._register(new Emitter<FileOperationEvent>());
readonly onAfterOperation: Event<FileOperationEvent> = this._onAfterOperation.event;
private _onDidRunOperation = this._register(new Emitter<FileOperationEvent>());
readonly onDidRunOperation = this._onDidRunOperation.event;
private _onError: Emitter<Error> = this._register(new Emitter<Error>());
readonly onError: Event<Error> = this._onError.event;
private _onError = this._register(new Emitter<Error>());
readonly onError = this._onError.event;
//#region File Metadata Resolving
......@@ -299,7 +299,7 @@ export class FileService extends Disposable implements IFileService {
const fileStat = await this.writeFile(resource, bufferOrReadableOrStream);
// events
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
this._onDidRunOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
return fileStat;
}
......@@ -549,7 +549,7 @@ export class FileService extends Disposable implements IFileService {
// resolve and send events
const fileStat = await this.resolve(target, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(source, mode === 'move' ? FileOperation.MOVE : FileOperation.COPY, fileStat));
this._onDidRunOperation.fire(new FileOperationEvent(source, mode === 'move' ? FileOperation.MOVE : FileOperation.COPY, fileStat));
return fileStat;
}
......@@ -563,7 +563,7 @@ export class FileService extends Disposable implements IFileService {
// resolve and send events
const fileStat = await this.resolve(target, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(source, mode === 'copy' ? FileOperation.COPY : FileOperation.MOVE, fileStat));
this._onDidRunOperation.fire(new FileOperationEvent(source, mode === 'copy' ? FileOperation.COPY : FileOperation.MOVE, fileStat));
return fileStat;
}
......@@ -717,7 +717,7 @@ export class FileService extends Disposable implements IFileService {
// events
const fileStat = await this.resolve(resource, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
this._onDidRunOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
return fileStat;
}
......@@ -799,15 +799,15 @@ export class FileService extends Disposable implements IFileService {
await provider.delete(resource, { recursive, useTrash });
// Events
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.DELETE));
this._onDidRunOperation.fire(new FileOperationEvent(resource, FileOperation.DELETE));
}
//#endregion
//#region File Watching
private _onFileChanges: Emitter<FileChangesEvent> = this._register(new Emitter<FileChangesEvent>());
readonly onFileChanges: Event<FileChangesEvent> = this._onFileChanges.event;
private _onDidFilesChange = this._register(new Emitter<FileChangesEvent>());
readonly onDidFilesChange = this._onDidFilesChange.event;
private activeWatchers = new Map<string, { disposable: IDisposable, count: number }>();
......
......@@ -63,12 +63,12 @@ export interface IFileService {
* Allows to listen for file changes. The event will fire for every file within the opened workspace
* (if any) as well as all files that have been watched explicitly using the #watch() API.
*/
readonly onFileChanges: Event<FileChangesEvent>;
readonly onDidFilesChange: Event<FileChangesEvent>;
/**
* An event that is fired upon successful completion of a certain file operation.
*/
readonly onAfterOperation: Event<FileOperationEvent>;
readonly onDidRunOperation: Event<FileOperationEvent>;
/**
* Resolve the properties of a file/folder identified by the resource.
......@@ -471,15 +471,7 @@ export interface IFileChange {
export class FileChangesEvent {
private readonly _changes: readonly IFileChange[];
constructor(changes: readonly IFileChange[]) {
this._changes = changes;
}
get changes() {
return this._changes;
}
constructor(public readonly changes: readonly IFileChange[]) { }
/**
* Returns true if this change event contains the provided file with the given change type (if provided). In case of
......@@ -493,7 +485,7 @@ export class FileChangesEvent {
const checkForChangeType = !isUndefinedOrNull(type);
return this._changes.some(change => {
return this.changes.some(change => {
if (checkForChangeType && change.type !== type) {
return false;
}
......@@ -550,11 +542,11 @@ export class FileChangesEvent {
}
private getOfType(type: FileChangeType): IFileChange[] {
return this._changes.filter(change => change.type === type);
return this.changes.filter(change => change.type === type);
}
private hasType(type: FileChangeType): boolean {
return this._changes.some(change => {
return this.changes.some(change => {
return change.type === type;
});
}
......
......@@ -20,7 +20,7 @@ export class FileWatcher extends Disposable {
constructor(
private path: string,
private onFileChanges: (changes: IDiskFileChange[]) => void,
private onDidFilesChange: (changes: IDiskFileChange[]) => void,
private onLogMessage: (msg: ILogMessage) => void,
private verboseLogging: boolean
) {
......@@ -101,7 +101,7 @@ export class FileWatcher extends Disposable {
// Fire
if (normalizedFileChanges.length > 0) {
this.onFileChanges(normalizedFileChanges);
this.onDidFilesChange(normalizedFileChanges);
}
return Promise.resolve();
......
......@@ -21,7 +21,7 @@ export class FileWatcher extends Disposable {
constructor(
private folders: IWatcherRequest[],
private onFileChanges: (changes: IDiskFileChange[]) => void,
private onDidFilesChange: (changes: IDiskFileChange[]) => void,
private onLogMessage: (msg: ILogMessage) => void,
private verboseLogging: boolean,
) {
......@@ -68,7 +68,7 @@ export class FileWatcher extends Disposable {
this.service.setVerboseLogging(this.verboseLogging);
const options = {};
this._register(this.service.watch(options)(e => !this.isDisposed && this.onFileChanges(e)));
this._register(this.service.watch(options)(e => !this.isDisposed && this.onDidFilesChange(e)));
this._register(this.service.onLogMessage(m => this.onLogMessage(m)));
......
......@@ -20,7 +20,7 @@ export class FileWatcher extends Disposable {
constructor(
private folders: IWatcherRequest[],
private onFileChanges: (changes: IDiskFileChange[]) => void,
private onDidFilesChange: (changes: IDiskFileChange[]) => void,
private onLogMessage: (msg: ILogMessage) => void,
private verboseLogging: boolean,
private watcherOptions: IWatcherOptions = {}
......@@ -67,7 +67,7 @@ export class FileWatcher extends Disposable {
this.service.setVerboseLogging(this.verboseLogging);
this._register(this.service.watch(this.watcherOptions)(e => !this.isDisposed && this.onFileChanges(e)));
this._register(this.service.watch(this.watcherOptions)(e => !this.isDisposed && this.onDidFilesChange(e)));
this._register(this.service.onLogMessage(m => this.onLogMessage(m)));
......
......@@ -16,7 +16,7 @@ export class FileWatcher implements IDisposable {
constructor(
folders: { path: string, excludes: string[] }[],
private onFileChanges: (changes: IDiskFileChange[]) => void,
private onDidFilesChange: (changes: IDiskFileChange[]) => void,
private onLogMessage: (msg: ILogMessage) => void,
private verboseLogging: boolean
) {
......@@ -62,7 +62,7 @@ export class FileWatcher implements IDisposable {
// Emit through event emitter
if (events.length > 0) {
this.onFileChanges(events);
this.onDidFilesChange(events);
}
}
......@@ -72,4 +72,4 @@ export class FileWatcher implements IDisposable {
this.service = undefined;
}
}
}
\ No newline at end of file
}
......@@ -165,7 +165,7 @@ suite('Disk File Service', function () {
test('createFolder', async () => {
let event: FileOperationEvent | undefined;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const parent = await service.resolve(URI.file(testDir));
......@@ -185,7 +185,7 @@ suite('Disk File Service', function () {
test('createFolder: creating multiple folders at once', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const multiFolderPaths = ['a', 'couple', 'of', 'folders'];
const parent = await service.resolve(URI.file(testDir));
......@@ -460,7 +460,7 @@ suite('Disk File Service', function () {
test('deleteFile', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const resource = URI.file(join(testDir, 'deep', 'conway.js'));
const source = await service.resolve(resource);
......@@ -496,7 +496,7 @@ suite('Disk File Service', function () {
const source = await service.resolve(link);
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
await service.del(source.resource);
......@@ -519,7 +519,7 @@ suite('Disk File Service', function () {
await symlink(target.fsPath, link.fsPath);
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
await service.del(link);
......@@ -532,7 +532,7 @@ suite('Disk File Service', function () {
test('deleteFolder (recursive)', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const resource = URI.file(join(testDir, 'deep'));
const source = await service.resolve(resource);
......@@ -561,7 +561,7 @@ suite('Disk File Service', function () {
test('move', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = URI.file(join(testDir, 'index.html'));
const sourceContents = readFileSync(source.fsPath);
......@@ -641,7 +641,7 @@ suite('Disk File Service', function () {
async function testMoveAcrossProviders(sourceFile = 'index.html'): Promise<void> {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = URI.file(join(testDir, sourceFile));
const sourceContents = readFileSync(source.fsPath);
......@@ -665,7 +665,7 @@ suite('Disk File Service', function () {
test('move - multi folder', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const multiFolderPaths = ['a', 'couple', 'of', 'folders'];
const renameToPath = join(...multiFolderPaths, 'other.html');
......@@ -684,7 +684,7 @@ suite('Disk File Service', function () {
test('move - directory', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = URI.file(join(testDir, 'deep'));
......@@ -728,7 +728,7 @@ suite('Disk File Service', function () {
async function testMoveFolderAcrossProviders(): Promise<void> {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = URI.file(join(testDir, 'deep'));
const sourceChildren = readdirSync(source.fsPath);
......@@ -753,7 +753,7 @@ suite('Disk File Service', function () {
test('move - MIX CASE', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = await service.resolve(URI.file(join(testDir, 'index.html')), { resolveMetadata: true });
assert.ok(source.size > 0);
......@@ -774,7 +774,7 @@ suite('Disk File Service', function () {
test('move - same file', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = await service.resolve(URI.file(join(testDir, 'index.html')), { resolveMetadata: true });
assert.ok(source.size > 0);
......@@ -794,7 +794,7 @@ suite('Disk File Service', function () {
test('move - same file #2', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = await service.resolve(URI.file(join(testDir, 'index.html')), { resolveMetadata: true });
assert.ok(source.size > 0);
......@@ -817,7 +817,7 @@ suite('Disk File Service', function () {
test('move - source parent of target', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
let source = await service.resolve(URI.file(join(testDir, 'index.html')), { resolveMetadata: true });
const originalSize = source.size;
......@@ -839,7 +839,7 @@ suite('Disk File Service', function () {
test('move - FILE_MOVE_CONFLICT', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
let source = await service.resolve(URI.file(join(testDir, 'index.html')), { resolveMetadata: true });
const originalSize = source.size;
......@@ -863,7 +863,7 @@ suite('Disk File Service', function () {
let createEvent: FileOperationEvent;
let moveEvent: FileOperationEvent;
let deleteEvent: FileOperationEvent;
disposables.add(service.onAfterOperation(e => {
disposables.add(service.onDidRunOperation(e => {
if (e.operation === FileOperation.CREATE) {
createEvent = e;
} else if (e.operation === FileOperation.DELETE) {
......@@ -927,7 +927,7 @@ suite('Disk File Service', function () {
async function doTestCopy(sourceName: string = 'index.html') {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = await service.resolve(URI.file(join(testDir, sourceName)));
const target = URI.file(join(testDir, 'other.html'));
......@@ -952,7 +952,7 @@ suite('Disk File Service', function () {
let createEvent: FileOperationEvent;
let copyEvent: FileOperationEvent;
let deleteEvent: FileOperationEvent;
disposables.add(service.onAfterOperation(e => {
disposables.add(service.onDidRunOperation(e => {
if (e.operation === FileOperation.CREATE) {
createEvent = e;
} else if (e.operation === FileOperation.DELETE) {
......@@ -1057,7 +1057,7 @@ suite('Disk File Service', function () {
test('copy - same file', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = await service.resolve(URI.file(join(testDir, 'index.html')), { resolveMetadata: true });
assert.ok(source.size > 0);
......@@ -1077,7 +1077,7 @@ suite('Disk File Service', function () {
test('copy - same file #2', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const source = await service.resolve(URI.file(join(testDir, 'index.html')), { resolveMetadata: true });
assert.ok(source.size > 0);
......@@ -1567,7 +1567,7 @@ suite('Disk File Service', function () {
async function assertCreateFile(converter: (content: string) => VSBuffer | VSBufferReadable | VSBufferReadableStream): Promise<void> {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const contents = 'Hello World';
const resource = URI.file(join(testDir, 'test.txt'));
......@@ -1600,7 +1600,7 @@ suite('Disk File Service', function () {
test('createFile (allows to overwrite existing)', async () => {
let event: FileOperationEvent;
disposables.add(service.onAfterOperation(e => event = e));
disposables.add(service.onDidRunOperation(e => event = e));
const contents = 'Hello World';
const resource = URI.file(join(testDir, 'test.txt'));
......@@ -2152,7 +2152,7 @@ suite('Disk File Service', function () {
return event.changes.map(change => `Change: type ${toString(change.type)} path ${change.resource.toString()}`).join('\n');
}
const listenerDisposable = service.onFileChanges(event => {
const listenerDisposable = service.onDidFilesChange(event => {
watcherDisposable.dispose();
listenerDisposable.dispose();
......
......@@ -15,14 +15,14 @@ function toFileChangesEvent(changes: IDiskFileChange[]): FileChangesEvent {
}
class TestFileWatcher {
private readonly _onFileChanges: Emitter<FileChangesEvent>;
private readonly _onDidFilesChange: Emitter<FileChangesEvent>;
constructor() {
this._onFileChanges = new Emitter<FileChangesEvent>();
this._onDidFilesChange = new Emitter<FileChangesEvent>();
}
get onFileChanges(): Event<FileChangesEvent> {
return this._onFileChanges.event;
get onDidFilesChange(): Event<FileChangesEvent> {
return this._onDidFilesChange.event;
}
report(changes: IDiskFileChange[]): void {
......@@ -36,7 +36,7 @@ class TestFileWatcher {
// Emit through event emitter
if (normalizedEvents.length > 0) {
this._onFileChanges.fire(toFileChangesEvent(normalizedEvents));
this._onDidFilesChange.fire(toFileChangesEvent(normalizedEvents));
}
}
}
......@@ -62,7 +62,7 @@ suite('Normalizer', () => {
{ path: deleted.fsPath, type: FileChangeType.DELETED },
];
watch.onFileChanges(e => {
watch.onDidFilesChange(e => {
assert.ok(e);
assert.equal(e.changes.length, 3);
assert.ok(e.contains(added, FileChangeType.ADDED));
......@@ -101,7 +101,7 @@ suite('Normalizer', () => {
{ path: updatedFile.fsPath, type: FileChangeType.UPDATED }
];
watch.onFileChanges(e => {
watch.onDidFilesChange(e => {
assert.ok(e);
assert.equal(e.changes.length, 5);
......@@ -131,7 +131,7 @@ suite('Normalizer', () => {
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
];
watch.onFileChanges(e => {
watch.onDidFilesChange(e => {
assert.ok(e);
assert.equal(e.changes.length, 1);
......@@ -156,7 +156,7 @@ suite('Normalizer', () => {
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
];
watch.onFileChanges(e => {
watch.onDidFilesChange(e => {
assert.ok(e);
assert.equal(e.changes.length, 2);
......@@ -182,7 +182,7 @@ suite('Normalizer', () => {
{ path: unrelated.fsPath, type: FileChangeType.UPDATED },
];
watch.onFileChanges(e => {
watch.onDidFilesChange(e => {
assert.ok(e);
assert.equal(e.changes.length, 2);
......@@ -211,7 +211,7 @@ suite('Normalizer', () => {
{ path: updated.fsPath, type: FileChangeType.DELETED }
];
watch.onFileChanges(e => {
watch.onDidFilesChange(e => {
assert.ok(e);
assert.equal(e.changes.length, 2);
......
......@@ -224,7 +224,7 @@ export class FileStorageDatabase extends Disposable implements IStorageDatabase
this.isWatching = true;
this._register(this.fileService.watch(this.file));
this._register(this.fileService.onFileChanges(e => {
this._register(this.fileService.onDidFilesChange(e => {
if (document.hasFocus()) {
return; // optimization: ignore changes from ourselves by checking for focus
}
......
......@@ -174,7 +174,7 @@ export abstract class AbstractFileSynchroniser extends AbstractSynchroniser {
) {
super(source, fileService, environmentService, userDataSyncStoreService, userDataSyncEnablementService, telemetryService, logService);
this._register(this.fileService.watch(dirname(file)));
this._register(this.fileService.onFileChanges(e => this.onFileChanges(e)));
this._register(this.fileService.onDidFilesChange(e => this.onFileChanges(e)));
}
async stop(): Promise<void> {
......
......@@ -39,7 +39,7 @@ export class GlobalStateSynchroniser extends AbstractSynchroniser implements IUs
) {
super(SyncSource.GlobalState, fileService, environmentService, userDataSyncStoreService, userDataSyncEnablementService, telemetryService, logService);
this._register(this.fileService.watch(dirname(this.environmentService.argvResource)));
this._register(Event.filter(this.fileService.onFileChanges, e => e.contains(this.environmentService.argvResource))(() => this._onDidChangeLocal.fire()));
this._register(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.environmentService.argvResource))(() => this._onDidChangeLocal.fire()));
}
async pull(): Promise<void> {
......
......@@ -42,7 +42,7 @@ export class MainThreadFileSystemEventService {
changed: [],
deleted: []
};
this._listener.add(fileService.onFileChanges(event => {
this._listener.add(fileService.onDidFilesChange(event => {
for (let change of event.changes) {
switch (change.type) {
case FileChangeType.ADDED:
......
......@@ -24,7 +24,7 @@ suite('BulkEditPreview', function () {
setup(function () {
const fileService: IFileService = new class extends mock<IFileService>() {
onFileChanges = Event.None;
onDidFilesChange = Event.None;
async exists() {
return true;
}
......
......@@ -125,7 +125,7 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
this._register(this._editorInfoStore.onChange(() => this.updateContexts()));
this._register(this.editorService.onDidActiveEditorChange(() => this.updateContexts()));
this._register(fileService.onAfterOperation(e => {
this._register(fileService.onDidRunOperation(e => {
if (e.isOperation(FileOperation.MOVE)) {
this.handleMovedFileInOpenedFileEditors(e.resource, e.target.resource);
}
......
......@@ -124,7 +124,7 @@ export class DebugService implements IDebugService {
this.viewModel = new ViewModel(contextKeyService);
this.taskRunner = this.instantiationService.createInstance(DebugTaskRunner);
this.toDispose.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
this.toDispose.push(this.fileService.onDidFilesChange(e => this.onFileChanges(e)));
this.toDispose.push(this.lifecycleService.onShutdown(this.dispose, this));
this.toDispose.push(this.extensionHostDebugService.onAttachSession(event => {
......
......@@ -53,10 +53,10 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
private registerListeners(): void {
// Update editors from operation changes
this._register(this.fileService.onAfterOperation(e => this.onFileOperation(e)));
this._register(this.fileService.onDidRunOperation(e => this.onFileOperation(e)));
// Update editors from disk changes
this._register(this.fileService.onFileChanges(e => this.onFileChanges(e)));
this._register(this.fileService.onDidFilesChange(e => this.onDidFilesChange(e)));
// Ensure dirty text file and untitled models are always opened as editors
this._register(this.textFileService.files.onDidChangeDirty(m => this.ensureDirtyFilesAreOpenedWorker.work(m.resource)));
......@@ -187,7 +187,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
}
}
private onFileChanges(e: FileChangesEvent): void {
private onDidFilesChange(e: FileChangesEvent): void {
if (e.gotDeleted()) {
this.handleDeletes(e, true);
}
......
......@@ -61,7 +61,7 @@ export class TextFileEditor extends BaseTextEditor {
this.updateRestoreViewStateConfiguration();
// Clear view state for deleted files
this._register(this.fileService.onFileChanges(e => this.onFilesChanged(e)));
this._register(this.fileService.onDidFilesChange(e => this.onFilesChanged(e)));
}
private onFilesChanged(e: FileChangesEvent): void {
......
......@@ -56,8 +56,8 @@ export class ExplorerService implements IExplorerService {
this.model = new ExplorerModel(this.contextService, this.fileService);
this.disposables.add(this.model);
this.disposables.add(this.fileService.onAfterOperation(e => this.onFileOperation(e)));
this.disposables.add(this.fileService.onFileChanges(e => this.onFileChanges(e)));
this.disposables.add(this.fileService.onDidRunOperation(e => this.onDidRunOperation(e)));
this.disposables.add(this.fileService.onDidFilesChange(e => this.onDidFilesChange(e)));
this.disposables.add(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(this.configurationService.getValue<IFilesConfiguration>())));
this.disposables.add(Event.any<{ scheme: string }>(this.fileService.onDidChangeFileSystemProviderRegistrations, this.fileService.onDidChangeFileSystemProviderCapabilities)(e => {
let affected = false;
......@@ -214,7 +214,7 @@ export class ExplorerService implements IExplorerService {
// File events
private onFileOperation(e: FileOperationEvent): void {
private onDidRunOperation(e: FileOperationEvent): void {
// Add
if (e.isOperation(FileOperation.CREATE) || e.isOperation(FileOperation.COPY)) {
const addedElement = e.target;
......@@ -294,7 +294,7 @@ export class ExplorerService implements IExplorerService {
}
}
private onFileChanges(e: FileChangesEvent): void {
private onDidFilesChange(e: FileChangesEvent): void {
// Check if an explorer refresh is necessary (delayed to give internal events a chance to react first)
// Note: there is no guarantee when the internal events are fired vs real ones. Code has to deal with the fact that one might
// be fired first over the other or not at all.
......
......@@ -171,7 +171,7 @@ export class TextFileContentProvider extends Disposable implements ITextModelCon
// Make sure to keep contents up to date when it changes
if (!this.fileWatcherDisposable.value) {
this.fileWatcherDisposable.value = this.fileService.onFileChanges(changes => {
this.fileWatcherDisposable.value = this.fileService.onDidFilesChange(changes => {
if (changes.contains(savedFileResource, FileChangeType.UPDATED)) {
this.resolveEditorModel(resource, false /* do not create if missing */); // update model when resource changes
}
......
......@@ -80,7 +80,7 @@ class LogOutputChannels extends Disposable implements IWorkbenchContribution {
}
const watcher = this.fileService.watch(dirname(file));
const disposable = this.fileService.onFileChanges(e => {
const disposable = this.fileService.onDidFilesChange(e => {
if (e.contains(file, FileChangeType.ADDED) || e.contains(file, FileChangeType.UPDATED)) {
watcher.dispose();
disposable.dispose();
......
......@@ -212,7 +212,7 @@ export class SearchView extends ViewPane {
this.memento = new Memento(this.id, storageService);
this.viewletState = this.memento.getMemento(StorageScope.WORKSPACE);
this._register(this.fileService.onFileChanges(e => this.onFilesChanged(e)));
this._register(this.fileService.onDidFilesChange(e => this.onFilesChanged(e)));
this._register(this.textFileService.untitled.onDidDisposeModel(e => this.onUntitledDidDispose(e)));
this._register(this.contextService.onDidChangeWorkbenchState(() => this.onDidChangeWorkbenchState()));
this._register(this.searchHistoryService.onDidClearHistory(() => this.clearHistory()));
......
......@@ -116,7 +116,7 @@ namespace snippetExt {
function watch(service: IFileService, resource: URI, callback: (type: FileChangeType, resource: URI) => any): IDisposable {
return combinedDisposable(
service.watch(resource),
service.onFileChanges(e => {
service.onDidFilesChange(e => {
for (const change of e.changes) {
if (resources.isEqualOrParent(change.resource, resource)) {
callback(change.type, change.resource);
......@@ -277,7 +277,7 @@ class SnippetsService implements ISnippetsService {
this._initFolderSnippets(SnippetSource.Workspace, snippetFolder, bucket);
} else {
// watch
bucket.add(this._fileService.onFileChanges(e => {
bucket.add(this._fileService.onDidFilesChange(e => {
if (e.contains(snippetFolder, FileChangeType.ADDED)) {
this._initFolderSnippets(SnippetSource.Workspace, snippetFolder, bucket);
}
......
......@@ -50,7 +50,7 @@ export class ConflictDetector {
}
// listen to file changes
this._disposables.add(fileService.onFileChanges(e => {
this._disposables.add(fileService.onDidFilesChange(e => {
for (let change of e.changes) {
if (modelService.getModel(change.resource)) {
......
......@@ -86,7 +86,7 @@ class FileServiceBasedConfigurationWithNames extends Disposable {
this._cache = new ConfigurationModel();
this.changeEventTriggerScheduler = this._register(new RunOnceScheduler(() => this._onDidChange.fire(), 50));
this._register(this.fileService.onFileChanges((e) => this.handleFileEvents(e)));
this._register(this.fileService.onDidFilesChange((e) => this.handleFileEvents(e)));
}
async loadConfiguration(): Promise<ConfigurationModel> {
......@@ -268,7 +268,7 @@ class FileServiceBasedRemoteUserConfiguration extends Disposable {
super();
this.parser = new ConfigurationModelParser(this.configurationResource.toString(), this.scopes);
this._register(fileService.onFileChanges(e => this.handleFileEvents(e)));
this._register(fileService.onDidFilesChange(e => this.handleFileEvents(e)));
this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this.reload().then(configurationModel => this._onDidChangeConfiguration.fire(configurationModel)), 50));
this._register(toDisposable(() => {
this.stopWatchingResource();
......@@ -523,7 +523,7 @@ class FileServiceBasedWorkspaceConfiguration extends Disposable implements IWork
this.workspaceConfigurationModelParser = new WorkspaceConfigurationModelParser('');
this.workspaceSettings = new ConfigurationModel();
this._register(fileService.onFileChanges(e => this.handleWorkspaceFileEvents(e)));
this._register(fileService.onDidFilesChange(e => this.handleWorkspaceFileEvents(e)));
this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this._onDidChange.fire(), 50));
this.workspaceConfigWatcher = this._register(this.watchWorkspaceConfigurationFile());
}
......
......@@ -125,7 +125,7 @@ export class HistoryService extends Disposable implements IHistoryService {
this._register(this.editorService.onDidOpenEditorFail(event => this.remove(event.editor)));
this._register(this.editorService.onDidCloseEditor(event => this.onEditorClosed(event)));
this._register(this.storageService.onWillSaveState(() => this.saveState()));
this._register(this.fileService.onFileChanges(event => this.onFileChanges(event)));
this._register(this.fileService.onDidFilesChange(event => this.onDidFilesChange(event)));
this._register(this.resourceFilter.onExpressionChange(() => this.removeExcludedFromHistory()));
this._register(this.editorService.onDidMostRecentlyActiveEditorsChange(() => this.handleEditorEventInRecentEditorsStack()));
......@@ -220,7 +220,7 @@ export class HistoryService extends Disposable implements IHistoryService {
return identifier.editor.matches(editor.input);
}
private onFileChanges(e: FileChangesEvent): void {
private onDidFilesChange(e: FileChangesEvent): void {
if (e.gotDeleted()) {
this.remove(e); // remove from history files that got deleted or moved
}
......
......@@ -635,7 +635,7 @@ class UserKeybindings extends Disposable {
this._onDidChange.fire();
}
}), 50));
this._register(Event.filter(this.fileService.onFileChanges, e => e.contains(this.keybindingsResource))(() => this.reloadConfigurationScheduler.schedule()));
this._register(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.keybindingsResource))(() => this.reloadConfigurationScheduler.schedule()));
}
async initialize(): Promise<void> {
......
......@@ -474,7 +474,7 @@ class UserKeyboardLayout extends Disposable {
}
}), 50));
this._register(Event.filter(this.fileService.onFileChanges, e => e.contains(this.keyboardLayoutResource))(() => this.reloadConfigurationScheduler.schedule()));
this._register(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.keyboardLayoutResource))(() => this.reloadConfigurationScheduler.schedule()));
}
async initialize(): Promise<void> {
......
......@@ -52,7 +52,7 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannelModel implement
this.rotatingFilePath = resources.joinPath(rotatingFilePathDirectory, `${id}.1.log`);
this._register(fileService.watch(rotatingFilePathDirectory));
this._register(fileService.onFileChanges(e => {
this._register(fileService.onDidFilesChange(e => {
if (e.contains(this.rotatingFilePath)) {
this.resettingDelayer.trigger(() => this.resetModel());
}
......
......@@ -110,11 +110,11 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
}
private registerListeners(): void {
this._register(this.fileService.onFileChanges(e => this.onFileChanges(e)));
this._register(this.fileService.onDidFilesChange(e => this.onDidFilesChange(e)));
this._register(this.filesConfigurationService.onFilesAssociationChange(e => this.onFilesAssociationChange()));
}
private async onFileChanges(e: FileChangesEvent): Promise<void> {
private async onDidFilesChange(e: FileChangesEvent): Promise<void> {
let fileEventImpactsModel = false;
let newInOrphanModeGuess: boolean | undefined;
......
......@@ -83,7 +83,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
private registerListeners(): void {
// Update models from file change events
this._register(this.fileService.onFileChanges(e => this.onFileChanges(e)));
this._register(this.fileService.onDidFilesChange(e => this.onDidFilesChange(e)));
// Working copy operations
this._register(this.workingCopyFileService.onWillRunWorkingCopyFileOperation(e => this.onWillRunWorkingCopyFileOperation(e)));
......@@ -94,7 +94,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
this.lifecycleService.onShutdown(this.dispose, this);
}
private onFileChanges(e: FileChangesEvent): void {
private onDidFilesChange(e: FileChangesEvent): void {
// Collect distinct (saved) models to update.
//
......
......@@ -252,7 +252,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
}
});
this.fileService.onFileChanges(async e => {
this.fileService.onDidFilesChange(async e => {
if (this.watchedColorThemeLocation && this.currentColorTheme && e.contains(this.watchedColorThemeLocation, FileChangeType.UPDATED)) {
this.reloadCurrentColorTheme();
}
......
......@@ -348,7 +348,7 @@ suite('FileUserDataProvider - Watching', () => {
test('file added change event', done => {
const expected = joinPath(userDataResource, 'settings.json');
const target = joinPath(localUserDataResource, 'settings.json');
testObject.onFileChanges(e => {
testObject.onDidFilesChange(e => {
if (e.contains(expected, FileChangeType.ADDED)) {
done();
}
......@@ -362,7 +362,7 @@ suite('FileUserDataProvider - Watching', () => {
test('file updated change event', done => {
const expected = joinPath(userDataResource, 'settings.json');
const target = joinPath(localUserDataResource, 'settings.json');
testObject.onFileChanges(e => {
testObject.onDidFilesChange(e => {
if (e.contains(expected, FileChangeType.UPDATED)) {
done();
}
......@@ -376,7 +376,7 @@ suite('FileUserDataProvider - Watching', () => {
test('file deleted change event', done => {
const expected = joinPath(userDataResource, 'settings.json');
const target = joinPath(localUserDataResource, 'settings.json');
testObject.onFileChanges(e => {
testObject.onDidFilesChange(e => {
if (e.contains(expected, FileChangeType.DELETED)) {
done();
}
......@@ -390,7 +390,7 @@ suite('FileUserDataProvider - Watching', () => {
test('file under folder created change event', done => {
const expected = joinPath(userDataResource, 'snippets', 'settings.json');
const target = joinPath(localUserDataResource, 'snippets', 'settings.json');
testObject.onFileChanges(e => {
testObject.onDidFilesChange(e => {
if (e.contains(expected, FileChangeType.ADDED)) {
done();
}
......@@ -404,7 +404,7 @@ suite('FileUserDataProvider - Watching', () => {
test('file under folder updated change event', done => {
const expected = joinPath(userDataResource, 'snippets', 'settings.json');
const target = joinPath(localUserDataResource, 'snippets', 'settings.json');
testObject.onFileChanges(e => {
testObject.onDidFilesChange(e => {
if (e.contains(expected, FileChangeType.UPDATED)) {
done();
}
......@@ -418,7 +418,7 @@ suite('FileUserDataProvider - Watching', () => {
test('file under folder deleted change event', done => {
const expected = joinPath(userDataResource, 'snippets', 'settings.json');
const target = joinPath(localUserDataResource, 'snippets', 'settings.json');
testObject.onFileChanges(e => {
testObject.onDidFilesChange(e => {
if (e.contains(expected, FileChangeType.DELETED)) {
done();
}
......@@ -432,7 +432,7 @@ suite('FileUserDataProvider - Watching', () => {
test('event is not triggered if file is not under user data', async () => {
const target = joinPath(dirname(localUserDataResource), 'settings.json');
let triggered = false;
testObject.onFileChanges(() => triggered = true);
testObject.onDidFilesChange(() => triggered = true);
fileEventEmitter.fire([{
resource: target,
type: FileChangeType.DELETED
......@@ -446,7 +446,7 @@ suite('FileUserDataProvider - Watching', () => {
test('backup file created change event', done => {
const expected = joinPath(userDataResource, BACKUPS, 'settings.json');
const target = joinPath(localBackupsResource, 'settings.json');
testObject.onFileChanges(e => {
testObject.onDidFilesChange(e => {
if (e.contains(expected, FileChangeType.ADDED)) {
done();
}
......@@ -460,7 +460,7 @@ suite('FileUserDataProvider - Watching', () => {
test('backup file update change event', done => {
const expected = joinPath(userDataResource, BACKUPS, 'settings.json');
const target = joinPath(localBackupsResource, 'settings.json');
testObject.onFileChanges(e => {
testObject.onDidFilesChange(e => {
if (e.contains(expected, FileChangeType.UPDATED)) {
done();
}
......@@ -474,7 +474,7 @@ suite('FileUserDataProvider - Watching', () => {
test('backup file delete change event', done => {
const expected = joinPath(userDataResource, BACKUPS, 'settings.json');
const target = joinPath(localBackupsResource, 'settings.json');
testObject.onFileChanges(e => {
testObject.onDidFilesChange(e => {
if (e.contains(expected, FileChangeType.DELETED)) {
done();
}
......
......@@ -58,7 +58,7 @@ suite('MainThreadDocumentsAndEditors', () => {
const editorGroupService = new TestEditorGroupsService();
const fileService = new class extends mock<IFileService>() {
onAfterOperation = Event.None;
onDidRunOperation = Event.None;
};
new MainThreadDocumentsAndEditors(
......
......@@ -603,8 +603,8 @@ export class TestFileService implements IFileService {
_serviceBrand: undefined;
private readonly _onFileChanges: Emitter<FileChangesEvent>;
private readonly _onAfterOperation: Emitter<FileOperationEvent>;
private readonly _onDidFilesChange = new Emitter<FileChangesEvent>();
private readonly _onDidRunOperation = new Emitter<FileOperationEvent>();
readonly onWillActivateFileSystemProvider = Event.None;
readonly onDidChangeFileSystemProviderCapabilities = Event.None;
......@@ -613,18 +613,13 @@ export class TestFileService implements IFileService {
private content = 'Hello Html';
private lastReadFileUri!: URI;
constructor() {
this._onFileChanges = new Emitter<FileChangesEvent>();
this._onAfterOperation = new Emitter<FileOperationEvent>();
}
setContent(content: string): void { this.content = content; }
getContent(): string { return this.content; }
getLastReadFileUri(): URI { return this.lastReadFileUri; }
get onFileChanges(): Event<FileChangesEvent> { return this._onFileChanges.event; }
fireFileChanges(event: FileChangesEvent): void { this._onFileChanges.fire(event); }
get onAfterOperation(): Event<FileOperationEvent> { return this._onAfterOperation.event; }
fireAfterOperation(event: FileOperationEvent): void { this._onAfterOperation.fire(event); }
get onDidFilesChange(): Event<FileChangesEvent> { return this._onDidFilesChange.event; }
fireFileChanges(event: FileChangesEvent): void { this._onDidFilesChange.fire(event); }
get onDidRunOperation(): Event<FileOperationEvent> { return this._onDidRunOperation.event; }
fireAfterOperation(event: FileOperationEvent): void { this._onDidRunOperation.fire(event); }
resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat>;
resolve(resource: URI, _options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册