Skip to content

Commit fd4973b

Browse files
committed
cleaner
1 parent 67b800d commit fd4973b

File tree

1 file changed

+23
-33
lines changed

1 file changed

+23
-33
lines changed

packages/ts-autocomplete/src/index.ts

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -196,39 +196,8 @@ export default class Autocompleter {
196196

197197
if (debugLog.enabled) {
198198
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');
232201
}
233202
}
234203

@@ -241,4 +210,25 @@ export default class Autocompleter {
241210

242211
return [];
243212
}
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+
}
244234
}

0 commit comments

Comments
 (0)