@@ -14,7 +14,7 @@ import { Disposable, WorkspaceEdit } from './extHostTypes.js';
14
14
import { IExtensionDescription } from '../../../platform/extensions/common/extensions.js' ;
15
15
import { FileChangeFilter , FileOperation , IGlobPatterns } from '../../../platform/files/common/files.js' ;
16
16
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' ;
18
18
import { IExtHostWorkspace } from './extHostWorkspace.js' ;
19
19
import { Lazy } from '../../../base/common/lazy.js' ;
20
20
import { ExtHostConfigProvider } from './extHostConfiguration.js' ;
@@ -29,9 +29,6 @@ export interface FileSystemWatcherCreateOptions {
29
29
30
30
class FileSystemWatcher implements vscode . FileSystemWatcher {
31
31
32
- private static IDS = 0 ;
33
-
34
- private readonly id = FileSystemWatcher . IDS ++ ;
35
32
private readonly session = Math . random ( ) ;
36
33
37
34
private readonly _onDidCreate = new Emitter < vscode . Uri > ( ) ;
@@ -53,16 +50,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
53
50
return Boolean ( this . _config & 0b100 ) ;
54
51
}
55
52
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 ) {
66
54
this . _config = 0 ;
67
55
if ( options . ignoreCreateEvents ) {
68
56
this . _config += 0b001 ;
@@ -74,18 +62,6 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
74
62
this . _config += 0b100 ;
75
63
}
76
64
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
-
89
65
const parsedPattern = parse ( globPattern ) ;
90
66
91
67
// 1.64.x behaviour change: given the new support to watch any folder
@@ -105,64 +81,34 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
105
81
106
82
const subscription = dispatcher ( events => {
107
83
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
- }
111
84
return ; // ignore events from other file watchers that are in correlation mode
112
85
}
113
86
114
87
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
- }
118
88
return ; // ignore events from other non-correlating file watcher when we are in correlation mode
119
89
}
120
90
121
91
if ( ! options . ignoreCreateEvents ) {
122
92
for ( const created of events . created ) {
123
93
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 ) ;
134
96
}
135
97
}
136
98
}
137
99
if ( ! options . ignoreChangeEvents ) {
138
100
for ( const changed of events . changed ) {
139
101
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 ) ;
150
104
}
151
105
}
152
106
}
153
107
if ( ! options . ignoreDeleteEvents ) {
154
108
for ( const deleted of events . deleted ) {
155
109
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 ) ;
166
112
}
167
113
}
168
114
}
@@ -339,7 +285,7 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
339
285
//--- file events
340
286
341
287
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 ) ;
343
289
}
344
290
345
291
$onFileEvent ( events : FileSystemEvents ) {
0 commit comments