Skip to content

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).

TypeScript
function countBySeverity(
  items: readonly EditorDiagnostic[],
): { errors: number; other: number; warnings: number }
Parameters
NameTypeDescription
itemsreadonly EditorDiagnostic[]

The findings to count.

{ errors: number; other: number; warnings: number }

ui/src/code/editor/diagnostics.ts:96

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.

TypeScript
function diagnosticMarkers(items: readonly EditorDiagnostic[]): Marker[]
Parameters
NameTypeDescription
itemsreadonly EditorDiagnostic[]

The findings to mark.

Marker[]

ui/src/code/editor/diagnostics.ts:118

diagnosticsAtFunction#

Diagnostics whose range covers a 1-based (line, column), such as the findings under the pointer.

TypeScript
function diagnosticsAt<D extends EditorDiagnostic>(
  items: readonly D[],
  line: number,
  column: number,
): D[]
Type parameters
NameTypeDescription
Dextends EditorDiagnostic
Parameters
NameTypeDescription
itemsreadonly D[]

The findings to filter.

linenumber

1-based line.

columnnumber

1-based column.

D[]

ui/src/code/editor/diagnostics.ts:81

diagnosticsByLineFunction#

Findings grouped per line, in first-seen order: one annotation row each.

TypeScript
function diagnosticsByLine<D extends EditorDiagnostic>(
  items: readonly D[],
): Map<number, D[]>
Type parameters
NameTypeDescription
Dextends EditorDiagnostic
Parameters
NameTypeDescription
itemsreadonly D[]

The findings to group, keyed by their start line.

Map<number, D[]>

ui/src/code/editor/diagnostics.ts:136

Constants#

DIAGNOSTIC_GLYPHConstant#

Icon class and text colour class each severity is drawn with, shared by the annotations, the chip and the hover card.

TypeScript
const DIAGNOSTIC_GLYPH: Record<DiagnosticSeverity, { icon: string; tone: string }>

ui/src/code/editor/diagnostics.ts:67

Interfaces#

EditorDefinitionInterface#

Where a symbol is defined, and the extent of the symbol it was asked from.

TypeScript
interface EditorDefinition extends EditorLocation
EditorDefinition properties
NameTypeDescription
columnfrom EditorLocationnumber

1-based column.

linefrom EditorLocationnumber

1-based line.

origin?EditorRange

The symbol the definition was asked from, in the asking file, as the language service delimits it (LSP originSelectionRange): a whole import path rather than the word under the pointer. Cmd/Ctrl-hover underlines it. Absent when the service doesn't say.

pathfrom EditorLocationstring

Relative to the editor's root.

ui/src/code/editor/diagnostics.ts:56

EditorDiagnosticInterface#

One finding on a file: where it sits, how serious it is, what it says and which tool raised it.

TypeScript
interface EditorDiagnostic
EditorDiagnostic properties
NameTypeDescription
code?string

Rule / error code (TS2322, no-unused-vars).

columnnumber

1-based column the range starts at.

endColumn?number

1-based column the range ends before (exclusive). Defaults to one character past column.

endLine?number

1-based line the range ends on. Defaults to line.

linenumber

1-based line the range starts on.

messagestring

The finding's text, as the tool wrote it.

pathstring

Relative to the editor's root.

severityDiagnosticSeverity

How serious the finding is.

sourcestring

Tool id (tsc, eslint, ...).

ui/src/code/editor/diagnostics.ts:12

EditorLocationInterface#

A position in a file a language service points at (a definition, a reference).

TypeScript
interface EditorLocation
EditorLocation properties
NameTypeDescription
columnnumber

1-based column.

linenumber

1-based line.

pathstring

Relative to the editor's root.

ui/src/code/editor/diagnostics.ts:34

EditorRangeInterface#

A span of a file's text, 1-based.

TypeScript
interface EditorRange
EditorRange properties
NameTypeDescription
columnnumber

1-based column the span starts at.

endColumnnumber

1-based column the span ends before (exclusive).

endLinenumber

1-based line the span ends on.

linenumber

1-based line the span starts on.

ui/src/code/editor/diagnostics.ts:44

Types#

DiagnosticSeverityType#

How serious a finding is; picks its glyph, colour and which count it adds to.

TypeScript
type DiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint'

ui/src/code/editor/diagnostics.ts:9