(project: Project, original: ts.DiagnosticWithLocation | ts.Diagnostic)
| 283 | async emitFile(fileName: string): Promise<EmitResult> { |
| 284 | return this.doEmitFile(fileName, undefined, undefined); |
| 285 | } |
| 286 | |
| 287 | transformDiagnostic(project: Project, original: ts.DiagnosticWithLocation | ts.Diagnostic): Diagnostic { |
| 288 | const text = project.formatDiagnostic(original); |
| 289 | |
| 290 | let category: string; |
| 291 | switch (original.category) { |
| 292 | case ts.DiagnosticCategory.Warning: |
| 293 | category = 'warning'; |
| 294 | break; |
| 295 | case ts.DiagnosticCategory.Error: |
| 296 | category = 'error'; |
| 297 | break; |
| 298 | case ts.DiagnosticCategory.Suggestion: |
| 299 | category = 'suggestion'; |
| 300 | break; |
| 301 | case ts.DiagnosticCategory.Message: |
| 302 | category = 'message'; |
| 303 | break; |
| 304 | } |
| 305 | |
| 306 | let file = original.file ?? (original.source && project.getOpenedSourceFile(original.source)); |
| 307 | |
| 308 | let start: Location; |
| 309 | let end: Location; |
| 310 | if (file && original.start) { |
| 311 | start = this.getLocationOfPositionInFile(file, original.start); |
| 312 | end = this.getLocationOfPositionInFile(file, original.start + (original.length ?? 0)); |
| 313 | } else { |
| 314 | start = { line: 0, offset: 0 }; |
| 315 | end = { line: 0, offset: 0 }; |
| 316 | } |
| 317 | |
| 318 | const transformed = { |
| 319 | start, |
| 320 | end, |
| 321 | text, |
| 322 | category, |
| 323 | }; |
| 324 | return transformed; |
| 325 | } |
| 326 |
no test coverage detected