@@ -211,19 +211,27 @@ module ts {
211211 return hasProperty ( filesByName , fileName ) ? filesByName [ fileName ] : undefined ;
212212 }
213213
214- function getSyntacticDiagnostics ( sourceFile ? : SourceFile ) : Diagnostic [ ] {
214+ function getDiagnosticsHelper ( sourceFile : SourceFile , getDiagnostics : ( sourceFile : SourceFile ) => Diagnostic [ ] ) : Diagnostic [ ] {
215215 if ( sourceFile ) {
216- return ts . getSyntacticDiagnostics ( sourceFile ) ;
216+ return getDiagnostics ( sourceFile ) ;
217217 }
218218
219219 var allDiagnostics : Diagnostic [ ] = [ ] ;
220220 forEach ( program . getSourceFiles ( ) , sourceFile => {
221- addRange ( allDiagnostics , ts . getSyntacticDiagnostics ( sourceFile ) ) ;
221+ addRange ( allDiagnostics , getDiagnostics ( sourceFile ) ) ;
222222 } ) ;
223223
224224 return sortAndDeduplicateDiagnostics ( allDiagnostics ) ;
225225 }
226226
227+ function getSyntacticDiagnostics ( sourceFile ?: SourceFile ) : Diagnostic [ ] {
228+ return getDiagnosticsHelper ( sourceFile , ts . getSyntacticDiagnostics ) ;
229+ }
230+
231+ function getSemanticDiagnostics ( sourceFile ?: SourceFile ) : Diagnostic [ ] {
232+ return getDiagnosticsHelper ( sourceFile , getSemanticDiagnosticsForFile ) ;
233+ }
234+
227235 function getSemanticDiagnosticsForFile ( sourceFile : SourceFile ) : Diagnostic [ ] {
228236 var typeChecker = getDiagnosticsProducingTypeChecker ( ) ;
229237
@@ -235,19 +243,6 @@ module ts {
235243 return bindDiagnostics . concat ( checkDiagnostics ) . concat ( programDiagnostics ) ;
236244 }
237245
238- function getSemanticDiagnostics ( sourceFile ?: SourceFile ) : Diagnostic [ ] {
239- if ( sourceFile ) {
240- return sortAndDeduplicateDiagnostics ( getSemanticDiagnosticsForFile ( sourceFile ) ) ;
241- }
242-
243- var allDiagnostics : Diagnostic [ ] = [ ] ;
244- forEach ( program . getSourceFiles ( ) , sourceFile => {
245- addRange ( allDiagnostics , getSemanticDiagnosticsForFile ( sourceFile ) ) ;
246- } ) ;
247-
248- return sortAndDeduplicateDiagnostics ( allDiagnostics ) ;
249- }
250-
251246 function getGlobalDiagnostics ( ) : Diagnostic [ ] {
252247 var typeChecker = getDiagnosticsProducingTypeChecker ( ) ;
253248
0 commit comments