@@ -397,11 +397,41 @@ namespace ts.server {
397397 }
398398
399399 getSyntacticDiagnostics ( fileName : string ) : Diagnostic [ ] {
400- throw new Error ( "Not Implemented Yet." ) ;
400+ const args : protocol . SyntacticDiagnosticsSyncRequestArgs = { file : fileName , includeLinePosition : true } ;
401+
402+ const request = this . processRequest < protocol . SyntacticDiagnosticsSyncRequest > ( CommandNames . SyntacticDiagnosticsSync , args ) ;
403+ const response = this . processResponse < protocol . SyntacticDiagnosticsSyncResponse > ( request ) ;
404+
405+ return ( < protocol . DiagnosticWithLinePosition [ ] > response . body ) . map ( entry => this . convertDiagnostic ( entry , fileName ) ) ;
401406 }
402407
403408 getSemanticDiagnostics ( fileName : string ) : Diagnostic [ ] {
404- throw new Error ( "Not Implemented Yet." ) ;
409+ const args : protocol . SemanticDiagnosticsSyncRequestArgs = { file : fileName , includeLinePosition : true } ;
410+
411+ const request = this . processRequest < protocol . SemanticDiagnosticsSyncRequest > ( CommandNames . SemanticDiagnosticsSync , args ) ;
412+ const response = this . processResponse < protocol . SemanticDiagnosticsSyncResponse > ( request ) ;
413+
414+ return ( < protocol . DiagnosticWithLinePosition [ ] > response . body ) . map ( entry => this . convertDiagnostic ( entry , fileName ) ) ;
415+ }
416+
417+ convertDiagnostic ( entry : protocol . DiagnosticWithLinePosition , fileName : string ) : Diagnostic {
418+ let category : DiagnosticCategory ;
419+ for ( const id in DiagnosticCategory ) {
420+ if ( typeof id === "string" && entry . category === id . toLowerCase ( ) ) {
421+ category = ( < any > DiagnosticCategory ) [ id ] ;
422+ }
423+ }
424+
425+ Debug . assert ( category !== undefined , "convertDiagnostic: category should not be undefined" ) ;
426+
427+ return {
428+ file : undefined ,
429+ start : entry . start ,
430+ length : entry . length ,
431+ messageText : entry . message ,
432+ category : category ,
433+ code : entry . code
434+ } ;
405435 }
406436
407437 getCompilerOptionsDiagnostics ( ) : Diagnostic [ ] {
0 commit comments