code/editor/diagnostics
import { … } from 'zidane-ui/code/editor'ui/src/code/editor/diagnostics.ts
Functions#
countBySeverityFunction#
How many findings are errors, warnings, and anything else (info and hints together).
function countBySeverity(
items: readonly EditorDiagnostic[],
): { errors: number; other: number; warnings: number }Parameters
| Name | Type | Description |
|---|---|---|
| items | readonly EditorDiagnostic[] | The findings to count. |
Returns
{ errors: number; other: number; warnings: number }diagnosticMarkersFunction#
The editor's squiggles (pierre markers, 0-based) for a set of findings. Each marker's message carries the source and code after the text.
function diagnosticMarkers(items: readonly EditorDiagnostic[]): Marker[]Parameters
| Name | Type | Description |
|---|---|---|
| items | readonly EditorDiagnostic[] | The findings to mark. |
Returns
Marker[]diagnosticsAtFunction#
Diagnostics whose range covers a 1-based (line, column), such as the findings under the pointer.
function diagnosticsAt<D extends EditorDiagnostic>(
items: readonly D[],
line: number,
column: number,
): D[]Type parameters
| Name | Type | Description |
|---|---|---|
| D | extends EditorDiagnostic |
Parameters
| Name | Type | Description |
|---|---|---|
| items | readonly D[] | The findings to filter. |
| line | number | 1-based line. |
| column | number | 1-based column. |
Returns
D[]diagnosticsByLineFunction#
Findings grouped per line, in first-seen order: one annotation row each.
function diagnosticsByLine<D extends EditorDiagnostic>(
items: readonly D[],
): Map<number, D[]>Type parameters
| Name | Type | Description |
|---|---|---|
| D | extends EditorDiagnostic |
Parameters
| Name | Type | Description |
|---|---|---|
| items | readonly D[] | The findings to group, keyed by their start line. |
Returns
Map<number, D[]>Constants#
DIAGNOSTIC_GLYPHConstant#
Icon class and text colour class each severity is drawn with, shared by the annotations, the chip and the hover card.
const DIAGNOSTIC_GLYPH: Record<DiagnosticSeverity, { icon: string; tone: string }>Interfaces#
EditorDefinitionInterface#
Where a symbol is defined, and the extent of the symbol it was asked from.
interface EditorDefinition extends EditorLocationProperties
| Name | Type | Description |
|---|---|---|
columnfrom EditorLocation | number | 1-based column. |
linefrom EditorLocation | number | 1-based line. |
| origin? | EditorRange | The symbol the definition was asked from, in the asking file, as the
language service delimits it (LSP |
pathfrom EditorLocation | string | Relative to the editor's root. |
EditorDiagnosticInterface#
One finding on a file: where it sits, how serious it is, what it says and which tool raised it.
interface EditorDiagnosticProperties
| Name | Type | Description |
|---|---|---|
| code? | string | Rule / error code ( |
| column | number | 1-based column the range starts at. |
| endColumn? | number | 1-based column the range ends before (exclusive). Defaults to one character past |
| endLine? | number | 1-based line the range ends on. Defaults to |
| line | number | 1-based line the range starts on. |
| message | string | The finding's text, as the tool wrote it. |
| path | string | Relative to the editor's root. |
| severity | DiagnosticSeverity | How serious the finding is. |
| source | string | Tool id ( |
EditorLocationInterface#
A position in a file a language service points at (a definition, a reference).
interface EditorLocationProperties
| Name | Type | Description |
|---|---|---|
| column | number | 1-based column. |
| line | number | 1-based line. |
| path | string | Relative to the editor's root. |
EditorRangeInterface#
A span of a file's text, 1-based.
interface EditorRangeProperties
| Name | Type | Description |
|---|---|---|
| column | number | 1-based column the span starts at. |
| endColumn | number | 1-based column the span ends before (exclusive). |
| endLine | number | 1-based line the span ends on. |
| line | number | 1-based line the span starts on. |
Types#
DiagnosticSeverityType#
How serious a finding is; picks its glyph, colour and which count it adds to.
type DiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint'