Package-level declarations

Types

Link copied to clipboard
data class DiagnosticFix(val replacement: String, val label: String = replacement)

A fix for a diagnostic: replacement for its range, shown on the menu as label. A label says what a fix does where the replacement alone would not, such as "Remove “the”" for an empty replacement.

Link copied to clipboard
data class DiagnosticStyle(val message: String, val fixes: List<DiagnosticFix>, val color: Color, val severity: DiagnosticSeverity = DiagnosticSeverity.Error, val layer: DecorationLayer = DiagnosticsLayer) : DecorationStyle

The underline of one diagnostic, on layer. It carries the diagnostic's message and fixes itself, so they move with the span as the text around it is edited. By default it is on the layer a TextDiagnosticsState reads, replaces and clears as its own; one on a layer of its own is left to that layer's owner.

Link copied to clipboard
data class LineCheck(val diagnostics: List<LineDiagnostic>, val complete: Boolean = true)

One line's result from TextDiagnosticsChecker.check: the diagnostics to underline, and whether the line was completely checked. A complete result is kept until the line's text changes. An incomplete one, such as when a service the checker relies on could not be reached, is underlined and the line goes to TextDiagnosticsChecker.check again on each refresh until a complete result comes back. Each refresh, after any edit, sends every incomplete line again, so a checker that retries something slow should hold off on its own and answer incomplete meanwhile. A failure that will not pass, such as a line the service refuses, is complete, or the line is sent again for as long as it stays.

Link copied to clipboard
data class LineDiagnostic(val start: Int, val end: Int, val message: String, val fixes: List<DiagnosticFix> = emptyList(), val severity: DiagnosticSeverity = DiagnosticSeverity.Error)

An issue in one line, from start to end, as character offsets into the line.

Link copied to clipboard

Finds issues other than spelling, such as grammar, in lines of text.

Link copied to clipboard
class TextDiagnosticsState(val textState: TextEditorState, checker: TextDiagnosticsChecker?, color: Color = DefaultDiagnosticColor, suggestionColor: Color = DefaultSuggestionColor, scanContext: CoroutineContext = Dispatchers.Default, cacheLines: Int = DEFAULT_CACHE_LINES)

Underlines what a TextDiagnosticsChecker finds in textState, line by line. Results are kept by line text, so after an edit only the lines that changed, and those whose result was an incomplete LineCheck, go to TextDiagnosticsChecker.check; TextDiagnosticsChecker.checkText sees the whole text every time. Pass it to com.darkrockstudios.texteditor.spellcheck.SpellCheckingTextEditor, which refreshes it as the text changes and opens a menu of the message and fixes on an underline. The underlines are on the diagnostics decoration layer, which it reads and replaces by line; a state made for the same editor later takes over the underlines an earlier one left.

Properties

Link copied to clipboard

The default underline color: blue, apart from spell check's red.

Link copied to clipboard

The default underline color of a DiagnosticSeverity.Suggestion: a muted gold.

Functions

Link copied to clipboard
fun LineDiagnostic(start: Int, end: Int, message: String, fixes: List<String>): LineDiagnostic

A LineDiagnostic whose fixes are replacements, each shown as itself.

Link copied to clipboard
fun rememberTextDiagnosticsState(textState: TextEditorState, checker: TextDiagnosticsChecker?, color: Color = DefaultDiagnosticColor, suggestionColor: Color = DefaultSuggestionColor): TextDiagnosticsState

Remembers a TextDiagnosticsState for textState, following checker and the colors as they change. Pass a stable checker: a new instance checks the whole text again.