@@ -7,7 +7,7 @@ export class ErrorCollector {
77 constructor (
88 private documents : TextDocuments ,
99 private connection : IConnection ,
10- private initialDelay : number = 1500 ,
10+ private initialDelay : number = 750 ,
1111 private nextDelay : number = 20 ) { }
1212
1313 public requestErrors ( ...documents : TextDocumentIdentifier [ ] ) {
@@ -28,23 +28,25 @@ export class ErrorCollector {
2828
2929 private sendErrorsFor ( document : TextDocumentIdentifier ) {
3030 const { fileName, service} = this . documents . getServiceInfo ( document ) ;
31- const diagnostics = service . getDiagnostics ( fileName ) ;
32- if ( diagnostics ) {
33- const offsets = ( [ ] as number [ ] ) . concat ( ...diagnostics . map ( d => [ d . span . start , d . span . end ] ) ) ;
34- const positions = this . documents . offsetsToPositions ( document , offsets ) ;
35- const ranges : Range [ ] = [ ] ;
36- for ( let i = 0 ; i < positions . length ; i += 2 ) {
37- ranges . push ( Range . create ( positions [ i ] , positions [ i + 1 ] ) ) ;
31+ if ( service ) {
32+ const diagnostics = service . getDiagnostics ( fileName ) ;
33+ if ( diagnostics ) {
34+ const offsets = ( [ ] as number [ ] ) . concat ( ...diagnostics . map ( d => [ d . span . start , d . span . end ] ) ) ;
35+ const positions = this . documents . offsetsToPositions ( document , offsets ) ;
36+ const ranges : Range [ ] = [ ] ;
37+ for ( let i = 0 ; i < positions . length ; i += 2 ) {
38+ ranges . push ( Range . create ( positions [ i ] , positions [ i + 1 ] ) ) ;
39+ }
40+ this . connection . sendDiagnostics ( {
41+ uri : document . uri ,
42+ diagnostics : diagnostics . map ( ( diagnostic , i ) => ( {
43+ range : ranges [ i ] ,
44+ message : diagnostic . message ,
45+ severity : DiagnosticSeverity . Error ,
46+ source : 'Angular'
47+ } ) )
48+ } ) ;
3849 }
39- this . connection . sendDiagnostics ( {
40- uri : document . uri ,
41- diagnostics : diagnostics . map ( ( diagnostic , i ) => ( {
42- range : ranges [ i ] ,
43- message : diagnostic . message ,
44- severity : DiagnosticSeverity . Error ,
45- source : 'Angular'
46- } ) )
47- } ) ;
4850 }
4951 }
5052}
0 commit comments