UNPKG

617 BPlain TextView Raw
1import { DiagnosticCategory, Node, ts } from 'ts-simple-ast';
2
3export class CompilerDiagnostic implements ts.Diagnostic {
4 constructor(
5 private readonly node: Node,
6 public readonly messageText: string,
7 public readonly code: number,
8 public readonly category: DiagnosticCategory,
9 ) {}
10
11 public get file(): ts.SourceFile | undefined {
12 return this.node.getSourceFile().compilerNode;
13 }
14
15 public get start(): number {
16 return this.node.getStart();
17 }
18
19 public get length(): number {
20 return this.node.getWidth();
21 }
22
23 public get source(): string {
24 return this.node.getText();
25 }
26}