@@ -196,39 +196,8 @@ export default class Autocompleter {
196
196
197
197
if ( debugLog . enabled ) {
198
198
for ( const filename of this . listFiles ( ) ) {
199
- try {
200
- debugLog (
201
- 'getSyntacticDiagnostics' ,
202
- filename ,
203
- filterDiagnostics (
204
- this . languageService . getSyntacticDiagnostics ( filename )
205
- )
206
- ) ;
207
- } catch ( err : any ) {
208
- debugLog (
209
- 'getSyntacticDiagnostics' ,
210
- filename ,
211
- err . stack ,
212
- err . ProgramFiles
213
- ) ;
214
- }
215
- try {
216
- debugLog (
217
- 'getSemanticDiagnostics' ,
218
- filename ,
219
- filterDiagnostics (
220
- this . languageService . getSemanticDiagnostics ( filename )
221
- )
222
- ) ;
223
- } catch ( err : any ) {
224
- debugLog (
225
- 'getSemanticDiagnostics' ,
226
- filename ,
227
- err . stack ,
228
- err . ProgramFiles
229
- ) ;
230
- }
231
- //debugLog('getSuggestionDiagnostics', filename, filterDiagnostics(this.languageService.getSuggestionDiagnostics(filename));
199
+ this . debugLanguageService ( filename , 'getSyntacticDiagnostics' ) ;
200
+ this . debugLanguageService ( filename , 'getSemanticDiagnostics' ) ;
232
201
}
233
202
}
234
203
@@ -241,4 +210,25 @@ export default class Autocompleter {
241
210
242
211
return [ ] ;
243
212
}
213
+
214
+ debugLanguageService (
215
+ filename : string ,
216
+ method :
217
+ | 'getSyntacticDiagnostics'
218
+ | 'getSemanticDiagnostics'
219
+ | 'getSuggestionDiagnostics'
220
+ ) {
221
+ try {
222
+ debugLog (
223
+ method ,
224
+ filename ,
225
+ filterDiagnostics ( this . languageService [ method ] ( filename ) )
226
+ ) ;
227
+ } catch ( err : any ) {
228
+ // These methods can throw and then it would be nice to at least know
229
+ // why/where. One example would be when you try and alias and then import
230
+ // a global module in the code passed to the language service.
231
+ debugLog ( method , filename , err . stack , err . ProgramFiles ) ;
232
+ }
233
+ }
244
234
}
0 commit comments