@@ -62,16 +62,16 @@ class WorkerServerProcess implements TsServerProcess {
62
62
private readonly _onDataHandlers = new Set < ( data : Proto . Response ) => void > ( ) ;
63
63
private readonly _onErrorHandlers = new Set < ( err : Error ) => void > ( ) ;
64
64
private readonly _onExitHandlers = new Set < ( code : number | null , signal : string | null ) => void > ( ) ;
65
- private readonly _watches : FileWatcherManager ;
66
65
67
- private readonly worker : Worker ;
66
+ private readonly _worker : Worker ;
67
+ private readonly _watches : FileWatcherManager ;
68
68
69
69
/** For communicating with TS server synchronously */
70
- private readonly tsserver : MessagePort ;
70
+ private readonly _tsserver : MessagePort ;
71
71
/** For communicating watches asynchronously */
72
- private readonly watcher : MessagePort ;
72
+ private readonly _watcher : MessagePort ;
73
73
/** For communicating with filesystem synchronously */
74
- private readonly syncFs : MessagePort ;
74
+ private readonly _syncFs : MessagePort ;
75
75
76
76
public constructor (
77
77
private readonly kind : TsServerProcessKind ,
@@ -81,18 +81,18 @@ class WorkerServerProcess implements TsServerProcess {
81
81
private readonly tsServerLog : TsServerLog | undefined ,
82
82
logger : Logger ,
83
83
) {
84
- this . worker = new Worker ( tsServerPath , { name : `TS ${ kind } server #${ this . id } ` } ) ;
84
+ this . _worker = new Worker ( tsServerPath , { name : `TS ${ kind } server #${ this . id } ` } ) ;
85
85
86
86
this . _watches = new FileWatcherManager ( logger ) ;
87
87
88
88
const tsserverChannel = new MessageChannel ( ) ;
89
89
const watcherChannel = new MessageChannel ( ) ;
90
90
const syncChannel = new MessageChannel ( ) ;
91
- this . tsserver = tsserverChannel . port2 ;
92
- this . watcher = watcherChannel . port2 ;
93
- this . syncFs = syncChannel . port2 ;
91
+ this . _tsserver = tsserverChannel . port2 ;
92
+ this . _watcher = watcherChannel . port2 ;
93
+ this . _syncFs = syncChannel . port2 ;
94
94
95
- this . tsserver . onmessage = ( event ) => {
95
+ this . _tsserver . onmessage = ( event ) => {
96
96
if ( event . data . type === 'log' ) {
97
97
console . error ( `unexpected log message on tsserver channel: ${ JSON . stringify ( event ) } ` ) ;
98
98
return ;
@@ -102,7 +102,7 @@ class WorkerServerProcess implements TsServerProcess {
102
102
}
103
103
} ;
104
104
105
- this . watcher . onmessage = ( event : MessageEvent < BrowserWatchEvent > ) => {
105
+ this . _watcher . onmessage = ( event : MessageEvent < BrowserWatchEvent > ) => {
106
106
switch ( event . data . type ) {
107
107
case 'dispose' : {
108
108
this . _watches . delete ( event . data . id ) ;
@@ -111,9 +111,9 @@ class WorkerServerProcess implements TsServerProcess {
111
111
case 'watchDirectory' :
112
112
case 'watchFile' : {
113
113
this . _watches . create ( event . data . id , vscode . Uri . from ( event . data . uri ) , /*watchParentDirs*/ true , ! ! event . data . recursive , {
114
- change : uri => this . watcher . postMessage ( { type : 'watch' , event : 'change' , uri } ) ,
115
- create : uri => this . watcher . postMessage ( { type : 'watch' , event : 'create' , uri } ) ,
116
- delete : uri => this . watcher . postMessage ( { type : 'watch' , event : 'delete' , uri } ) ,
114
+ change : uri => this . _watcher . postMessage ( { type : 'watch' , event : 'change' , uri } ) ,
115
+ create : uri => this . _watcher . postMessage ( { type : 'watch' , event : 'create' , uri } ) ,
116
+ delete : uri => this . _watcher . postMessage ( { type : 'watch' , event : 'delete' , uri } ) ,
117
117
} ) ;
118
118
break ;
119
119
}
@@ -122,7 +122,7 @@ class WorkerServerProcess implements TsServerProcess {
122
122
}
123
123
} ;
124
124
125
- this . worker . onmessage = ( msg : any ) => {
125
+ this . _worker . onmessage = ( msg : any ) => {
126
126
// for logging only
127
127
if ( msg . data . type === 'log' ) {
128
128
this . appendLog ( msg . data . body ) ;
@@ -131,15 +131,15 @@ class WorkerServerProcess implements TsServerProcess {
131
131
console . error ( `unexpected message on main channel: ${ JSON . stringify ( msg ) } ` ) ;
132
132
} ;
133
133
134
- this . worker . onerror = ( err : ErrorEvent ) => {
134
+ this . _worker . onerror = ( err : ErrorEvent ) => {
135
135
console . error ( 'error! ' + JSON . stringify ( err ) ) ;
136
136
for ( const handler of this . _onErrorHandlers ) {
137
137
// TODO: The ErrorEvent type might be wrong; previously this was typed as Error and didn't have the property access.
138
138
handler ( err . error ) ;
139
139
}
140
140
} ;
141
141
142
- this . worker . postMessage (
142
+ this . _worker . postMessage (
143
143
{ args, extensionUri } ,
144
144
[ syncChannel . port1 , tsserverChannel . port1 , watcherChannel . port1 ]
145
145
) ;
@@ -150,7 +150,7 @@ class WorkerServerProcess implements TsServerProcess {
150
150
}
151
151
152
152
write ( serverRequest : Proto . Request ) : void {
153
- this . tsserver . postMessage ( serverRequest ) ;
153
+ this . _tsserver . postMessage ( serverRequest ) ;
154
154
}
155
155
156
156
onData ( handler : ( response : Proto . Response ) => void ) : void {
@@ -167,10 +167,11 @@ class WorkerServerProcess implements TsServerProcess {
167
167
}
168
168
169
169
kill ( ) : void {
170
- this . worker . terminate ( ) ;
171
- this . tsserver . close ( ) ;
172
- this . watcher . close ( ) ;
173
- this . syncFs . close ( ) ;
170
+ this . _worker . terminate ( ) ;
171
+ this . _tsserver . close ( ) ;
172
+ this . _watcher . close ( ) ;
173
+ this . _syncFs . close ( ) ;
174
+ this . _watches . dispose ( ) ;
174
175
}
175
176
176
177
private appendLog ( msg : string ) {
0 commit comments