@@ -424,33 +424,39 @@ namespace ts.server {
424424 }
425425
426426 getSyntacticDiagnostics ( fileName : string ) : Diagnostic [ ] {
427- const args : protocol . SyntacticDiagnosticsSyncRequestArgs = { file : fileName } ;
427+ const args : protocol . SyntacticDiagnosticsSyncRequestArgs = { file : fileName , includeLinePosition : true } ;
428428
429429 const request = this . processRequest < protocol . SyntacticDiagnosticsSyncRequest > ( CommandNames . SyntacticDiagnosticsSync , args ) ;
430430 const response = this . processResponse < protocol . SyntacticDiagnosticsSyncResponse > ( request ) ;
431431
432- return ( < protocol . Diagnostic [ ] > response . body ) . map ( entry => this . convertDiagnostic ( entry , fileName ) ) ;
432+ return ( < protocol . DiagnosticWithLinePosition [ ] > response . body ) . map ( entry => this . convertDiagnostic ( entry , fileName ) ) ;
433433 }
434434
435435 getSemanticDiagnostics ( fileName : string ) : Diagnostic [ ] {
436- const args : protocol . SemanticDiagnosticsSyncRequestArgs = { file : fileName } ;
436+ const args : protocol . SemanticDiagnosticsSyncRequestArgs = { file : fileName , includeLinePosition : true } ;
437437
438438 const request = this . processRequest < protocol . SemanticDiagnosticsSyncRequest > ( CommandNames . SemanticDiagnosticsSync , args ) ;
439439 const response = this . processResponse < protocol . SemanticDiagnosticsSyncResponse > ( request ) ;
440440
441- return ( < protocol . Diagnostic [ ] > response . body ) . map ( entry => this . convertDiagnostic ( entry , fileName ) ) ;
441+ return ( < protocol . DiagnosticWithLinePosition [ ] > response . body ) . map ( entry => this . convertDiagnostic ( entry , fileName ) ) ;
442442 }
443443
444- convertDiagnostic ( entry : protocol . Diagnostic , fileName : string ) : Diagnostic {
445- const start = this . lineOffsetToPosition ( fileName , entry . start ) ;
446- const end = this . lineOffsetToPosition ( fileName , entry . end ) ;
444+ convertDiagnostic ( entry : protocol . DiagnosticWithLinePosition , fileName : string ) : Diagnostic {
445+ let category : DiagnosticCategory ;
446+ for ( const id in DiagnosticCategory ) {
447+ if ( typeof id === "string" && entry . category === id . toLowerCase ( ) ) {
448+ category = ( < any > DiagnosticCategory ) [ id ] ;
449+ }
450+ }
451+
452+ Debug . assert ( category !== undefined , "convertDiagnostic: category should not be undefined" ) ;
447453
448454 return {
449455 file : undefined ,
450- start : start ,
451- length : end - start ,
452- messageText : entry . text ,
453- category : undefined ,
456+ start : entry . start ,
457+ length : entry . length ,
458+ messageText : entry . message ,
459+ category : category ,
454460 code : entry . code
455461 } ;
456462 }
0 commit comments