Skip to content

Commit 8349c95

Browse files
authored
Revert "file watcher - log extension host created watcher logic" (#251085)
* Revert "file watcher - log extension host created watcher logic (#248507)" This reverts commit 3c3303a. * .
1 parent 3f25a2d commit 8349c95

File tree

1 file changed

+9
-63
lines changed

1 file changed

+9
-63
lines changed

src/vs/workbench/api/common/extHostFileSystemEventService.ts

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Disposable, WorkspaceEdit } from './extHostTypes.js';
1414
import { IExtensionDescription } from '../../../platform/extensions/common/extensions.js';
1515
import { FileChangeFilter, FileOperation, IGlobPatterns } from '../../../platform/files/common/files.js';
1616
import { CancellationToken } from '../../../base/common/cancellation.js';
17-
import { ILogService, LogLevel } from '../../../platform/log/common/log.js';
17+
import { ILogService } from '../../../platform/log/common/log.js';
1818
import { IExtHostWorkspace } from './extHostWorkspace.js';
1919
import { Lazy } from '../../../base/common/lazy.js';
2020
import { ExtHostConfigProvider } from './extHostConfiguration.js';
@@ -29,9 +29,6 @@ export interface FileSystemWatcherCreateOptions {
2929

3030
class FileSystemWatcher implements vscode.FileSystemWatcher {
3131

32-
private static IDS = 0;
33-
34-
private readonly id = FileSystemWatcher.IDS++;
3532
private readonly session = Math.random();
3633

3734
private readonly _onDidCreate = new Emitter<vscode.Uri>();
@@ -53,16 +50,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
5350
return Boolean(this._config & 0b100);
5451
}
5552

56-
constructor(
57-
mainContext: IMainContext,
58-
logService: ILogService,
59-
configuration: ExtHostConfigProvider,
60-
workspace: IExtHostWorkspace,
61-
extension: IExtensionDescription,
62-
dispatcher: Event<FileSystemEvents>,
63-
globPattern: string | IRelativePatternDto,
64-
options: FileSystemWatcherCreateOptions
65-
) {
53+
constructor(mainContext: IMainContext, configuration: ExtHostConfigProvider, workspace: IExtHostWorkspace, extension: IExtensionDescription, dispatcher: Event<FileSystemEvents>, globPattern: string | IRelativePatternDto, options: FileSystemWatcherCreateOptions) {
6654
this._config = 0;
6755
if (options.ignoreCreateEvents) {
6856
this._config += 0b001;
@@ -74,18 +62,6 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
7462
this._config += 0b100;
7563
}
7664

77-
const trace = logService.getLevel() === LogLevel.Trace;
78-
if (trace) {
79-
let patternLogMsg: string;
80-
if (typeof globPattern === 'string') {
81-
patternLogMsg = `'${globPattern}'`;
82-
} else {
83-
patternLogMsg = `base: '${globPattern.base}', pattern: '${globPattern.pattern}'`;
84-
}
85-
86-
logService.trace(`[File Watcher ('API') ${this.id}] createFileSystemWatcher(${patternLogMsg}, ${JSON.stringify(options)})`);
87-
}
88-
8965
const parsedPattern = parse(globPattern);
9066

9167
// 1.64.x behaviour change: given the new support to watch any folder
@@ -105,64 +81,34 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
10581

10682
const subscription = dispatcher(events => {
10783
if (typeof events.session === 'number' && events.session !== this.session) {
108-
if (trace) {
109-
logService.trace(`[File Watcher ('API') ${this.id}] dispatch(): returning early due to event correlation mismatch`);
110-
}
11184
return; // ignore events from other file watchers that are in correlation mode
11285
}
11386

11487
if (excludeUncorrelatedEvents && typeof events.session === 'undefined') {
115-
if (trace) {
116-
logService.trace(`[File Watcher ('API') ${this.id}] dispatch(): returning early due to event correlation mismatch`);
117-
}
11888
return; // ignore events from other non-correlating file watcher when we are in correlation mode
11989
}
12090

12191
if (!options.ignoreCreateEvents) {
12292
for (const created of events.created) {
12393
const uri = URI.revive(created);
124-
if (parsedPattern(uri.fsPath)) {
125-
if (!excludeOutOfWorkspaceEvents || workspace.getWorkspaceFolder(uri)) {
126-
this._onDidCreate.fire(uri);
127-
} else {
128-
logService.trace(`[File Watcher ('API') ${this.id}] dispatch(created): ${uri.fsPath} did not match out-of-workspace rule`);
129-
}
130-
} else {
131-
if (trace) {
132-
logService.trace(`[File Watcher ('API') ${this.id}] dispatch(created): ${uri.fsPath} did not match pattern`);
133-
}
94+
if (parsedPattern(uri.fsPath) && (!excludeOutOfWorkspaceEvents || workspace.getWorkspaceFolder(uri))) {
95+
this._onDidCreate.fire(uri);
13496
}
13597
}
13698
}
13799
if (!options.ignoreChangeEvents) {
138100
for (const changed of events.changed) {
139101
const uri = URI.revive(changed);
140-
if (parsedPattern(uri.fsPath)) {
141-
if (!excludeOutOfWorkspaceEvents || workspace.getWorkspaceFolder(uri)) {
142-
this._onDidChange.fire(uri);
143-
} else {
144-
logService.trace(`[File Watcher ('API') ${this.id}] dispatch(changed): ${uri.fsPath} did not match out-of-workspace rule`);
145-
}
146-
} else {
147-
if (trace) {
148-
logService.trace(`[File Watcher ('API') ${this.id}] dispatch(changed): ${uri.fsPath} did not match pattern`);
149-
}
102+
if (parsedPattern(uri.fsPath) && (!excludeOutOfWorkspaceEvents || workspace.getWorkspaceFolder(uri))) {
103+
this._onDidChange.fire(uri);
150104
}
151105
}
152106
}
153107
if (!options.ignoreDeleteEvents) {
154108
for (const deleted of events.deleted) {
155109
const uri = URI.revive(deleted);
156-
if (parsedPattern(uri.fsPath)) {
157-
if (!excludeOutOfWorkspaceEvents || workspace.getWorkspaceFolder(uri)) {
158-
this._onDidDelete.fire(uri);
159-
} else {
160-
logService.trace(`[File Watcher ('API') ${this.id}] dispatch(deleted): ${uri.fsPath} did not match out-of-workspace rule`);
161-
}
162-
} else {
163-
if (trace) {
164-
logService.trace(`[File Watcher ('API') ${this.id}] dispatch(deleted): ${uri.fsPath} did not match pattern`);
165-
}
110+
if (parsedPattern(uri.fsPath) && (!excludeOutOfWorkspaceEvents || workspace.getWorkspaceFolder(uri))) {
111+
this._onDidDelete.fire(uri);
166112
}
167113
}
168114
}
@@ -339,7 +285,7 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
339285
//--- file events
340286

341287
createFileSystemWatcher(workspace: IExtHostWorkspace, configProvider: ExtHostConfigProvider, extension: IExtensionDescription, globPattern: vscode.GlobPattern, options: FileSystemWatcherCreateOptions): vscode.FileSystemWatcher {
342-
return new FileSystemWatcher(this._mainContext, this._logService, configProvider, workspace, extension, this._onFileSystemEvent.event, typeConverter.GlobPattern.from(globPattern), options);
288+
return new FileSystemWatcher(this._mainContext, configProvider, workspace, extension, this._onFileSystemEvent.event, typeConverter.GlobPattern.from(globPattern), options);
343289
}
344290

345291
$onFileEvent(events: FileSystemEvents) {

0 commit comments

Comments
 (0)