aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/editor/DiagnosticValue.ts
blob: ad23c4677b0274f1c17801866de3a165661ea2e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import type { Diagnostic } from '@codemirror/lint';
import { RangeValue } from '@codemirror/state';

export default class DiagnosticValue extends RangeValue {
  static VALUES: Record<Diagnostic['severity'], DiagnosticValue> = {
    error: new DiagnosticValue('error'),
    warning: new DiagnosticValue('warning'),
    info: new DiagnosticValue('info'),
  };

  private constructor(public readonly severity: Diagnostic['severity']) {
    super();
  }

  override point = true;

  override eq(other: RangeValue): boolean {
    return other instanceof DiagnosticValue && other.severity === this.severity;
  }
}