basant307/AI_Governance_Project
048
1import { NodeProp, SyntaxNode, Parser, Tree, Input, TreeFragment, NodeType } from '@lezer/common';2import { LRParser, ParserConfig } from '@lezer/lr';3import * as _codemirror_state from '@codemirror/state';4import { Facet, EditorState, Extension, Text, StateField, Range } from '@codemirror/state';5import { EditorView, DecorationSet, Command, KeyBinding, ViewUpdate, BlockInfo, Decoration } from '@codemirror/view';6import { Highlighter, Tag } from '@lezer/highlight';7import { StyleModule, StyleSpec } from 'style-mod';8 9/**10Node prop stored in a parser's top syntax node to provide the11facet that stores language-specific data for that language.12*/13declare const languageDataProp: NodeProp<Facet<{14 [name: string]: any;15}, readonly {16 [name: string]: any;17}[]>>;18/**19Helper function to define a facet (to be added to the top syntax20node(s) for a language via21[`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be22used to associate language data with the language. You23probably only need this when subclassing24[`Language`](https://codemirror.net/6/docs/ref/#language.Language).25*/26declare function defineLanguageFacet(baseData?: {27 [name: string]: any;28}): Facet<{29 [name: string]: any;30}, readonly {31 [name: string]: any;32}[]>;33/**34Some languages need to return different [language35data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) for some parts of their36tree. Sublanguages, registered by adding a [node37prop](https://codemirror.net/6/docs/ref/#language.sublanguageProp) to the language's top syntax38node, provide a mechanism to do this.39 40(Note that when using nested parsing, where nested syntax is41parsed by a different parser and has its own top node type, you42don't need a sublanguage.)43*/44interface Sublanguage {45 /**46 Determines whether the data provided by this sublanguage should47 completely replace the regular data or be added to it (with48 higher-precedence). The default is `"extend"`.49 */50 type?: "replace" | "extend";51 /**52 A predicate that returns whether the node at the queried53 position is part of the sublanguage.54 */55 test: (node: SyntaxNode, state: EditorState) => boolean;56 /**57 The language data facet that holds the sublanguage's data.58 You'll want to use59 [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet) to create60 this.61 */62 facet: Facet<{63 [name: string]: any;64 }>;65}66/**67Syntax node prop used to register sublanguages. Should be added to68the top level node type for the language.69*/70declare const sublanguageProp: NodeProp<Sublanguage[]>;71/**72A language object manages parsing and per-language73[metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is74managed as a [Lezer](https://lezer.codemirror.net) tree. The class75can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)76subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or77via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass78for stream parsers.79*/80declare class Language {81 /**82 The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet83 used for this language.84 */85 readonly data: Facet<{86 [name: string]: any;87 }>;88 /**89 A language name.90 */91 readonly name: string;92 /**93 The extension value to install this as the document language.94 */95 readonly extension: Extension;96 /**97 The parser object. Can be useful when using this as a [nested98 parser](https://lezer.codemirror.net/docs/ref#common.Parser).99 */100 parser: Parser;101 /**102 Construct a language object. If you need to invoke this103 directly, first define a data facet with104 [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then105 configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it106 to the language's outer syntax node.107 */108 constructor(109 /**110 The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet111 used for this language.112 */113 data: Facet<{114 [name: string]: any;115 }>, parser: Parser, extraExtensions?: Extension[], 116 /**117 A language name.118 */119 name?: string);120 /**121 Query whether this language is active at the given position.122 */123 isActiveAt(state: EditorState, pos: number, side?: -1 | 0 | 1): boolean;124 /**125 Find the document regions that were parsed using this language.126 The returned regions will _include_ any nested languages rooted127 in this language, when those exist.128 */129 findRegions(state: EditorState): {130 from: number;131 to: number;132 }[];133 /**134 Indicates whether this language allows nested languages. The135 default implementation returns true.136 */137 get allowsNesting(): boolean;138}139/**140A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer141[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)142parsers.143*/144declare class LRLanguage extends Language {145 readonly parser: LRParser;146 private constructor();147 /**148 Define a language from a parser.149 */150 static define(spec: {151 /**152 The [name](https://codemirror.net/6/docs/ref/#Language.name) of the language.153 */154 name?: string;155 /**156 The parser to use. Should already have added editor-relevant157 node props (and optionally things like dialect and top rule)158 configured.159 */160 parser: LRParser;161 /**162 [Language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)163 to register for this language.164 */165 languageData?: {166 [name: string]: any;167 };168 }): LRLanguage;169 /**170 Create a new instance of this language with a reconfigured171 version of its parser and optionally a new name.172 */173 configure(options: ParserConfig, name?: string): LRLanguage;174 get allowsNesting(): boolean;175}176/**177Get the syntax tree for a state, which is the current (possibly178incomplete) parse tree of the active179[language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no180language available.181*/182declare function syntaxTree(state: EditorState): Tree;183/**184Try to get a parse tree that spans at least up to `upto`. The185method will do at most `timeout` milliseconds of work to parse186up to that point if the tree isn't already available.187*/188declare function ensureSyntaxTree(state: EditorState, upto: number, timeout?: number): Tree | null;189/**190Queries whether there is a full syntax tree available up to the191given document position. If there isn't, the background parse192process _might_ still be working and update the tree further, but193there is no guarantee of that—the parser will [stop194working](https://codemirror.net/6/docs/ref/#language.syntaxParserRunning) when it has spent a195certain amount of time or has moved beyond the visible viewport.196Always returns false if no language has been enabled.197*/198declare function syntaxTreeAvailable(state: EditorState, upto?: number): boolean;199/**200Move parsing forward, and update the editor state afterwards to201reflect the new tree. Will work for at most `timeout`202milliseconds. Returns true if the parser managed get to the given203position in that time.204*/205declare function forceParsing(view: EditorView, upto?: number, timeout?: number): boolean;206/**207Tells you whether the language parser is planning to do more208parsing work (in a `requestIdleCallback` pseudo-thread) or has209stopped running, either because it parsed the entire document,210because it spent too much time and was cut off, or because there211is no language parser enabled.212*/213declare function syntaxParserRunning(view: EditorView): boolean;214/**215Lezer-style216[`Input`](https://lezer.codemirror.net/docs/ref#common.Input)217object for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.218*/219declare class DocInput implements Input {220 readonly doc: Text;221 private cursor;222 private cursorPos;223 private string;224 /**225 Create an input object for the given document.226 */227 constructor(doc: Text);228 get length(): number;229 private syncTo;230 chunk(pos: number): string;231 get lineChunks(): boolean;232 read(from: number, to: number): string;233}234/**235A parse context provided to parsers working on the editor content.236*/237declare class ParseContext {238 private parser;239 /**240 The current editor state.241 */242 readonly state: EditorState;243 /**244 Tree fragments that can be reused by incremental re-parses.245 */246 fragments: readonly TreeFragment[];247 /**248 The current editor viewport (or some overapproximation249 thereof). Intended to be used for opportunistically avoiding250 work (in which case251 [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)252 should be called to make sure the parser is restarted when the253 skipped region becomes visible).254 */255 viewport: {256 from: number;257 to: number;258 };259 private parse;260 private constructor();261 private startParse;262 private withContext;263 private withoutTempSkipped;264 /**265 Notify the parse scheduler that the given region was skipped266 because it wasn't in view, and the parse should be restarted267 when it comes into view.268 */269 skipUntilInView(from: number, to: number): void;270 /**271 Returns a parser intended to be used as placeholder when272 asynchronously loading a nested parser. It'll skip its input and273 mark it as not-really-parsed, so that the next update will parse274 it again.275 276 When `until` is given, a reparse will be scheduled when that277 promise resolves.278 */279 static getSkippingParser(until?: Promise<unknown>): Parser;280 /**281 Get the context for the current parse, or `null` if no editor282 parse is in progress.283 */284 static get(): ParseContext | null;285}286/**287The facet used to associate a language with an editor state. Used288by `Language` object's `extension` property (so you don't need to289manually wrap your languages in this). Can be used to access the290current language on a state.291*/292declare const language: Facet<Language, Language | null>;293/**294This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an295optional set of supporting extensions. Language packages are296encouraged to export a function that optionally takes a297configuration object and returns a `LanguageSupport` instance, as298the main way for client code to use the package.299*/300declare class LanguageSupport {301 /**302 The language object.303 */304 readonly language: Language;305 /**306 An optional set of supporting extensions. When nesting a307 language in another language, the outer language is encouraged308 to include the supporting extensions for its inner languages309 in its own set of support extensions.310 */311 readonly support: Extension;312 /**313 An extension including both the language and its support314 extensions. (Allowing the object to be used as an extension315 value itself.)316 */317 extension: Extension;318 /**319 Create a language support object.320 */321 constructor(322 /**323 The language object.324 */325 language: Language, 326 /**327 An optional set of supporting extensions. When nesting a328 language in another language, the outer language is encouraged329 to include the supporting extensions for its inner languages330 in its own set of support extensions.331 */332 support?: Extension);333}334/**335Language descriptions are used to store metadata about languages336and to dynamically load them. Their main role is finding the337appropriate language for a filename or dynamically loading nested338parsers.339*/340declare class LanguageDescription {341 /**342 The name of this language.343 */344 readonly name: string;345 /**346 Alternative names for the mode (lowercased, includes `this.name`).347 */348 readonly alias: readonly string[];349 /**350 File extensions associated with this language.351 */352 readonly extensions: readonly string[];353 /**354 Optional filename pattern that should be associated with this355 language.356 */357 readonly filename: RegExp | undefined;358 private loadFunc;359 /**360 If the language has been loaded, this will hold its value.361 */362 support: LanguageSupport | undefined;363 private loading;364 private constructor();365 /**366 Start loading the the language. Will return a promise that367 resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)368 object when the language successfully loads.369 */370 load(): Promise<LanguageSupport>;371 /**372 Create a language description.373 */374 static of(spec: {375 /**376 The language's name.377 */378 name: string;379 /**380 An optional array of alternative names.381 */382 alias?: readonly string[];383 /**384 An optional array of filename extensions associated with this385 language.386 */387 extensions?: readonly string[];388 /**389 An optional filename pattern associated with this language.390 */391 filename?: RegExp;392 /**393 A function that will asynchronously load the language.394 */395 load?: () => Promise<LanguageSupport>;396 /**397 Alternatively to `load`, you can provide an already loaded398 support object. Either this or `load` should be provided.399 */400 support?: LanguageSupport;401 }): LanguageDescription;402 /**403 Look for a language in the given array of descriptions that404 matches the filename. Will first match405 [`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,406 and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),407 and return the first language that matches.408 */409 static matchFilename(descs: readonly LanguageDescription[], filename: string): LanguageDescription | null;410 /**411 Look for a language whose name or alias matches the the given412 name (case-insensitively). If `fuzzy` is true, and no direct413 matchs is found, this'll also search for a language whose name414 or alias occurs in the string (for names shorter than three415 characters, only when surrounded by non-word characters).416 */417 static matchLanguageName(descs: readonly LanguageDescription[], name: string, fuzzy?: boolean): LanguageDescription | null;418}419 420/**421Facet that defines a way to provide a function that computes the422appropriate indentation depth, as a column number (see423[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)), at the start of a given424line. A return value of `null` indicates no indentation can be425determined, and the line should inherit the indentation of the one426above it. A return value of `undefined` defers to the next indent427service.428*/429declare const indentService: Facet<(context: IndentContext, pos: number) => number | null | undefined, readonly ((context: IndentContext, pos: number) => number | null | undefined)[]>;430/**431Facet for overriding the unit by which indentation happens. Should432be a string consisting entirely of the same whitespace character.433When not set, this defaults to 2 spaces.434*/435declare const indentUnit: Facet<string, string>;436/**437Return the _column width_ of an indent unit in the state.438Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)439facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that440contains tabs.441*/442declare function getIndentUnit(state: EditorState): number;443/**444Create an indentation string that covers columns 0 to `cols`.445Will use tabs for as much of the columns as possible when the446[`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains447tabs.448*/449declare function indentString(state: EditorState, cols: number): string;450/**451Get the indentation, as a column number, at the given position.452Will first consult any [indent services](https://codemirror.net/6/docs/ref/#language.indentService)453that are registered, and if none of those return an indentation,454this will check the syntax tree for the [indent node455prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp) and use that if found. Returns a456number when an indentation could be determined, and null457otherwise.458*/459declare function getIndentation(context: IndentContext | EditorState, pos: number): number | null;460/**461Create a change set that auto-indents all lines touched by the462given document range.463*/464declare function indentRange(state: EditorState, from: number, to: number): _codemirror_state.ChangeSet;465/**466Indentation contexts are used when calling [indentation467services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities468useful in indentation logic, and can selectively override the469indentation reported for some lines.470*/471declare class IndentContext {472 /**473 The editor state.474 */475 readonly state: EditorState;476 /**477 The indent unit (number of columns per indentation level).478 */479 unit: number;480 /**481 Create an indent context.482 */483 constructor(484 /**485 The editor state.486 */487 state: EditorState, 488 /**489 @internal490 */491 options?: {492 /**493 Override line indentations provided to the indentation494 helper function, which is useful when implementing region495 indentation, where indentation for later lines needs to refer496 to previous lines, which may have been reindented compared to497 the original start state. If given, this function should498 return -1 for lines (given by start position) that didn't499 change, and an updated indentation otherwise.500 */501 overrideIndentation?: (pos: number) => number;502 /**503 Make it look, to the indent logic, like a line break was504 added at the given position (which is mostly just useful for505 implementing something like506 [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)).507 */508 simulateBreak?: number;509 /**510 When `simulateBreak` is given, this can be used to make the511 simulated break behave like a double line break.512 */513 simulateDoubleBreak?: boolean;514 });515 /**516 Get a description of the line at the given position, taking517 [simulated line518 breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)519 into account. If there is such a break at `pos`, the `bias`520 argument determines whether the part of the line line before or521 after the break is used.522 */523 lineAt(pos: number, bias?: -1 | 1): {524 text: string;525 from: number;526 };527 /**528 Get the text directly after `pos`, either the entire line529 or the next 100 characters, whichever is shorter.530 */531 textAfterPos(pos: number, bias?: -1 | 1): string;532 /**533 Find the column for the given position.534 */535 column(pos: number, bias?: -1 | 1): number;536 /**537 Find the column position (taking tabs into account) of the given538 position in the given string.539 */540 countColumn(line: string, pos?: number): number;541 /**542 Find the indentation column of the line at the given point.543 */544 lineIndent(pos: number, bias?: -1 | 1): number;545 /**546 Returns the [simulated line547 break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)548 for this context, if any.549 */550 get simulatedBreak(): number | null;551}552/**553A syntax tree node prop used to associate indentation strategies554with node types. Such a strategy is a function from an indentation555context to a column number (see also556[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null557indicates that no definitive indentation can be determined.558*/559declare const indentNodeProp: NodeProp<(context: TreeIndentContext) => number | null>;560/**561Objects of this type provide context information and helper562methods to indentation functions registered on syntax nodes.563*/564declare class TreeIndentContext extends IndentContext {565 private base;566 /**567 The position at which indentation is being computed.568 */569 readonly pos: number;570 private constructor();571 /**572 The syntax tree node to which the indentation strategy573 applies.574 */575 get node(): SyntaxNode;576 /**577 Get the text directly after `this.pos`, either the entire line578 or the next 100 characters, whichever is shorter.579 */580 get textAfter(): string;581 /**582 Get the indentation at the reference line for `this.node`, which583 is the line on which it starts, unless there is a node that is584 _not_ a parent of this node covering the start of that line. If585 so, the line at the start of that node is tried, again skipping586 on if it is covered by another such node.587 */588 get baseIndent(): number;589 /**590 Get the indentation for the reference line of the given node591 (see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).592 */593 baseIndentFor(node: SyntaxNode): number;594 /**595 Continue looking for indentations in the node's parent nodes,596 and return the result of that.597 */598 continue(): number | null;599}600/**601An indentation strategy for delimited (usually bracketed) nodes.602Will, by default, indent one unit more than the parent's base603indent unless the line starts with a closing token. When `align`604is true and there are non-skipped nodes on the node's opening605line, the content of the node will be aligned with the end of the606opening node, like this:607 608 foo(bar,609 baz)610*/611declare function delimitedIndent({ closing, align, units }: {612 closing: string;613 align?: boolean;614 units?: number;615}): (context: TreeIndentContext) => number;616/**617An indentation strategy that aligns a node's content to its base618indentation.619*/620declare const flatIndent: (context: TreeIndentContext) => number;621/**622Creates an indentation strategy that, by default, indents623continued lines one unit more than the node's base indentation.624You can provide `except` to prevent indentation of lines that625match a pattern (for example `/^else\b/` in `if`/`else`626constructs), and you can change the amount of units used with the627`units` option.628*/629declare function continuedIndent({ except, units }?: {630 except?: RegExp;631 units?: number;632}): (context: TreeIndentContext) => number;633/**634Enables reindentation on input. When a language defines an635`indentOnInput` field in its [language636data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular637expression, the line at the cursor will be reindented whenever new638text is typed and the input from the start of the line up to the639cursor matches that regexp.640 641To avoid unneccesary reindents, it is recommended to start the642regexp with `^` (usually followed by `\s*`), and end it with `$`.643For example, `/^\s*\}$/` will reindent when a closing brace is644added at the start of a line.645*/646declare function indentOnInput(): Extension;647 648/**649A facet that registers a code folding service. When called with650the extent of a line, such a function should return a foldable651range that starts on that line (but continues beyond it), if one652can be found.653*/654declare const foldService: Facet<(state: EditorState, lineStart: number, lineEnd: number) => ({655 from: number;656 to: number;657} | null), readonly ((state: EditorState, lineStart: number, lineEnd: number) => ({658 from: number;659 to: number;660} | null))[]>;661/**662This node prop is used to associate folding information with663syntax node types. Given a syntax node, it should check whether664that tree is foldable and return the range that can be collapsed665when it is.666*/667declare const foldNodeProp: NodeProp<(node: SyntaxNode, state: EditorState) => ({668 from: number;669 to: number;670} | null)>;671/**672[Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but673the first and the last child of a syntax node. Useful for nodes674that start and end with delimiters.675*/676declare function foldInside(node: SyntaxNode): {677 from: number;678 to: number;679} | null;680/**681Check whether the given line is foldable. First asks any fold682services registered through683[`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return684a result, tries to query the [fold node685prop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end686of the line.687*/688declare function foldable(state: EditorState, lineStart: number, lineEnd: number): {689 from: number;690 to: number;691} | null;692type DocRange = {693 from: number;694 to: number;695};696/**697State effect that can be attached to a transaction to fold the698given range. (You probably only need this in exceptional699circumstances—usually you'll just want to let700[`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold701gutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)702*/703declare const foldEffect: _codemirror_state.StateEffectType<DocRange>;704/**705State effect that unfolds the given range (if it was folded).706*/707declare const unfoldEffect: _codemirror_state.StateEffectType<DocRange>;708/**709The state field that stores the folded ranges (as a [decoration710set](https://codemirror.net/6/docs/ref/#view.DecorationSet)). Can be passed to711[`EditorState.toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) and712[`fromJSON`](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) to serialize the fold713state.714*/715declare const foldState: StateField<DecorationSet>;716/**717Get a [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) containing the folded ranges718in the given state.719*/720declare function foldedRanges(state: EditorState): DecorationSet;721/**722Fold the lines that are selected, if possible.723*/724declare const foldCode: Command;725/**726Unfold folded ranges on selected lines.727*/728declare const unfoldCode: Command;729/**730Fold all top-level foldable ranges. Note that, in most cases,731folding information will depend on the [syntax732tree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work733reliably when the document hasn't been fully parsed (either734because the editor state was only just initialized, or because the735document is so big that the parser decided not to parse it736entirely).737*/738declare const foldAll: Command;739/**740Unfold all folded code.741*/742declare const unfoldAll: Command;743/**744Toggle folding at cursors. Unfolds if there is an existing fold745starting in that line, tries to find a foldable range around it746otherwise.747*/748declare const toggleFold: Command;749/**750Default fold-related key bindings.751 752 - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).753 - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).754 - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).755 - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).756*/757declare const foldKeymap: readonly KeyBinding[];758interface FoldConfig {759 /**760 A function that creates the DOM element used to indicate the761 position of folded code. The `onclick` argument is the default762 click event handler, which toggles folding on the line that763 holds the element, and should probably be added as an event764 handler to the returned element. If765 [`preparePlaceholder`](https://codemirror.net/6/docs/ref/#language.FoldConfig.preparePlaceholder)766 is given, its result will be passed as 3rd argument. Otherwise,767 this will be null.768 769 When this option isn't given, the `placeholderText` option will770 be used to create the placeholder element.771 */772 placeholderDOM?: ((view: EditorView, onclick: (event: Event) => void, prepared: any) => HTMLElement) | null;773 /**774 Text to use as placeholder for folded text. Defaults to `"…"`.775 Will be styled with the `"cm-foldPlaceholder"` class.776 */777 placeholderText?: string;778 /**779 Given a range that is being folded, create a value that780 describes it, to be used by `placeholderDOM` to render a custom781 widget that, for example, indicates something about the folded782 range's size or type.783 */784 preparePlaceholder?: (state: EditorState, range: {785 from: number;786 to: number;787 }) => any;788}789/**790Create an extension that configures code folding.791*/792declare function codeFolding(config?: FoldConfig): Extension;793type Handlers = {794 [event: string]: (view: EditorView, line: BlockInfo, event: Event) => boolean;795};796interface FoldGutterConfig {797 /**798 A function that creates the DOM element used to indicate a799 given line is folded or can be folded.800 When not given, the `openText`/`closeText` option will be used instead.801 */802 markerDOM?: ((open: boolean) => HTMLElement) | null;803 /**804 Text used to indicate that a given line can be folded.805 Defaults to `"⌄"`.806 */807 openText?: string;808 /**809 Text used to indicate that a given line is folded.810 Defaults to `"›"`.811 */812 closedText?: string;813 /**814 Supply event handlers for DOM events on this gutter.815 */816 domEventHandlers?: Handlers;817 /**818 When given, if this returns true for a given view update,819 recompute the fold markers.820 */821 foldingChanged?: (update: ViewUpdate) => boolean;822}823/**824Create an extension that registers a fold gutter, which shows a825fold status indicator before foldable lines (which can be clicked826to fold or unfold the line).827*/828declare function foldGutter(config?: FoldGutterConfig): Extension;829 830/**831A highlight style associates CSS styles with highlighting832[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).833*/834declare class HighlightStyle implements Highlighter {835 /**836 The tag styles used to create this highlight style.837 */838 readonly specs: readonly TagStyle[];839 /**840 A style module holding the CSS rules for this highlight style.841 When using842 [`highlightTree`](https://lezer.codemirror.net/docs/ref#highlight.highlightTree)843 outside of the editor, you may want to manually mount this844 module to show the highlighting.845 */846 readonly module: StyleModule | null;847 readonly style: (tags: readonly Tag[]) => string | null;848 readonly scope?: (type: NodeType) => boolean;849 private constructor();850 /**851 Create a highlighter style that associates the given styles to852 the given tags. The specs must be objects that hold a style tag853 or array of tags in their `tag` property, and either a single854 `class` property providing a static CSS class (for highlighter855 that rely on external styling), or a856 [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style857 set of CSS properties (which define the styling for those tags).858 859 The CSS rules created for a highlighter will be emitted in the860 order of the spec's properties. That means that for elements that861 have multiple tags associated with them, styles defined further862 down in the list will have a higher CSS precedence than styles863 defined earlier.864 */865 static define(specs: readonly TagStyle[], options?: {866 /**867 By default, highlighters apply to the entire document. You can868 scope them to a single language by providing the language869 object or a language's top node type here.870 */871 scope?: Language | NodeType;872 /**873 Add a style to _all_ content. Probably only useful in874 combination with `scope`.875 */876 all?: string | StyleSpec;877 /**878 Specify that this highlight style should only be active then879 the theme is dark or light. By default, it is active880 regardless of theme.881 */882 themeType?: "dark" | "light";883 }): HighlightStyle;884}885/**886Wrap a highlighter in an editor extension that uses it to apply887syntax highlighting to the editor content.888 889When multiple (non-fallback) styles are provided, the styling890applied is the union of the classes they emit.891*/892declare function syntaxHighlighting(highlighter: Highlighter, options?: {893 /**894 When enabled, this marks the highlighter as a fallback, which895 only takes effect if no other highlighters are registered.896 */897 fallback: boolean;898}): Extension;899/**900Returns the CSS classes (if any) that the highlighters active in901the state would assign to the given style902[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag) and903(optional) language904[scope](https://codemirror.net/6/docs/ref/#language.HighlightStyle^define^options.scope).905*/906declare function highlightingFor(state: EditorState, tags: readonly Tag[], scope?: NodeType): string | null;907/**908The type of object used in909[`HighlightStyle.define`](https://codemirror.net/6/docs/ref/#language.HighlightStyle^define).910Assigns a style to one or more highlighting911[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag), which can either be a fixed class name912(which must be defined elsewhere), or a set of CSS properties, for913which the library will define an anonymous class.914*/915interface TagStyle {916 /**917 The tag or tags to target.918 */919 tag: Tag | readonly Tag[];920 /**921 If given, this maps the tags to a fixed class name.922 */923 class?: string;924 /**925 Any further properties (if `class` isn't given) will be926 interpreted as in style objects given to927 [style-mod](https://github.com/marijnh/style-mod#documentation).928 (The type here is `any` because of TypeScript limitations.)929 */930 [styleProperty: string]: any;931}932/**933A default highlight style (works well with light themes).934*/935declare const defaultHighlightStyle: HighlightStyle;936 937interface Config {938 /**939 Whether the bracket matching should look at the character after940 the cursor when matching (if the one before isn't a bracket).941 Defaults to true.942 */943 afterCursor?: boolean;944 /**945 The bracket characters to match, as a string of pairs. Defaults946 to `"()[]{}"`. Note that these are only used as fallback when947 there is no [matching948 information](https://lezer.codemirror.net/docs/ref/#common.NodeProp^closedBy)949 in the syntax tree.950 */951 brackets?: string;952 /**953 The maximum distance to scan for matching brackets. This is only954 relevant for brackets not encoded in the syntax tree. Defaults955 to 10 000.956 */957 maxScanDistance?: number;958 /**959 Can be used to configure the way in which brackets are960 decorated. The default behavior is to add the961 `cm-matchingBracket` class for matching pairs, and962 `cm-nonmatchingBracket` for mismatched pairs or single brackets.963 */964 renderMatch?: (match: MatchResult, state: EditorState) => readonly Range<Decoration>[];965}966/**967Create an extension that enables bracket matching. Whenever the968cursor is next to a bracket, that bracket and the one it matches969are highlighted. Or, when no matching bracket is found, another970highlighting style is used to indicate this.971*/972declare function bracketMatching(config?: Config): Extension;973/**974When larger syntax nodes, such as HTML tags, are marked as975opening/closing, it can be a bit messy to treat the whole node as976a matchable bracket. This node prop allows you to define, for such977a node, a ‘handle’—the part of the node that is highlighted, and978that the cursor must be on to activate highlighting in the first979place.980*/981declare const bracketMatchingHandle: NodeProp<(node: SyntaxNode) => SyntaxNode | null>;982/**983The result returned from `matchBrackets`.984*/985interface MatchResult {986 /**987 The extent of the bracket token found.988 */989 start: {990 from: number;991 to: number;992 };993 /**994 The extent of the matched token, if any was found.995 */996 end?: {997 from: number;998 to: number;999 };1000 /**1001 Whether the tokens match. This can be false even when `end` has1002 a value, if that token doesn't match the opening token.1003 */1004 matched: boolean;1005}1006/**1007Find the matching bracket for the token at `pos`, scanning1008direction `dir`. Only the `brackets` and `maxScanDistance`1009properties are used from `config`, if given. Returns null if no1010bracket was found at `pos`, or a match result otherwise.1011*/1012declare function matchBrackets(state: EditorState, pos: number, dir: -1 | 1, config?: Config): MatchResult | null;1013 1014/**1015Encapsulates a single line of input. Given to stream syntax code,1016which uses it to tokenize the content.1017*/1018declare class StringStream {1019 /**1020 The line.1021 */1022 string: string;1023 private tabSize;1024 /**1025 The current indent unit size.1026 */1027 indentUnit: number;1028 private overrideIndent?;1029 /**1030 The current position on the line.1031 */1032 pos: number;1033 /**1034 The start position of the current token.1035 */1036 start: number;1037 private lastColumnPos;1038 private lastColumnValue;1039 /**1040 Create a stream.1041 */1042 constructor(1043 /**1044 The line.1045 */1046 string: string, tabSize: number, 1047 /**1048 The current indent unit size.1049 */1050 indentUnit: number, overrideIndent?: number | undefined);1051 /**1052 True if we are at the end of the line.1053 */1054 eol(): boolean;1055 /**1056 True if we are at the start of the line.1057 */1058 sol(): boolean;1059 /**1060 Get the next code unit after the current position, or undefined1061 if we're at the end of the line.1062 */1063 peek(): string | undefined;1064 /**1065 Read the next code unit and advance `this.pos`.1066 */1067 next(): string | void;1068 /**1069 Match the next character against the given string, regular1070 expression, or predicate. Consume and return it if it matches.1071 */1072 eat(match: string | RegExp | ((ch: string) => boolean)): string | void;1073 /**1074 Continue matching characters that match the given string,1075 regular expression, or predicate function. Return true if any1076 characters were consumed.1077 */1078 eatWhile(match: string | RegExp | ((ch: string) => boolean)): boolean;1079 /**1080 Consume whitespace ahead of `this.pos`. Return true if any was1081 found.1082 */1083 eatSpace(): boolean;1084 /**1085 Move to the end of the line.1086 */1087 skipToEnd(): void;1088 /**1089 Move to directly before the given character, if found on the1090 current line.1091 */1092 skipTo(ch: string): boolean | void;1093 /**1094 Move back `n` characters.1095 */1096 backUp(n: number): void;1097 /**1098 Get the column position at `this.pos`.1099 */1100 column(): number;1101 /**1102 Get the indentation column of the current line.1103 */1104 indentation(): number;1105 /**1106 Match the input against the given string or regular expression1107 (which should start with a `^`). Return true or the regexp match1108 if it matches.1109 1110 Unless `consume` is set to `false`, this will move `this.pos`1111 past the matched text.1112 1113 When matching a string `caseInsensitive` can be set to true to1114 make the match case-insensitive.1115 */1116 match(pattern: string | RegExp, consume?: boolean, caseInsensitive?: boolean): boolean | RegExpMatchArray | null;1117 /**1118 Get the current token.1119 */1120 current(): string;1121}1122 1123/**1124A stream parser parses or tokenizes content from start to end,1125emitting tokens as it goes over it. It keeps a mutable (but1126copyable) object with state, in which it can store information1127about the current context.1128*/1129interface StreamParser<State> {1130 /**1131 A name for this language.1132 */1133 name?: string;1134 /**1135 Produce a start state for the parser.1136 */1137 startState?(indentUnit: number): State;1138 /**1139 Read one token, advancing the stream past it, and returning a1140 string indicating the token's style tag—either the name of one1141 of the tags in1142 [`tags`](https://lezer.codemirror.net/docs/ref#highlight.tags)1143 or [`tokenTable`](https://codemirror.net/6/docs/ref/#language.StreamParser.tokenTable), or such a1144 name suffixed by one or more tag1145 [modifier](https://lezer.codemirror.net/docs/ref#highlight.Tag^defineModifier)1146 names, separated by periods. For example `"keyword"` or1147 "`variableName.constant"`, or a space-separated set of such1148 token types.1149 1150 It is okay to return a zero-length token, but only if that1151 updates the state so that the next call will return a non-empty1152 token again.1153 */1154 token(stream: StringStream, state: State): string | null;1155 /**1156 This notifies the parser of a blank line in the input. It can1157 update its state here if it needs to.1158 */1159 blankLine?(state: State, indentUnit: number): void;1160 /**1161 Copy a given state. By default, a shallow object copy is done1162 which also copies arrays held at the top level of the object.1163 */1164 copyState?(state: State): State;1165 /**1166 Compute automatic indentation for the line that starts with the1167 given state and text.1168 */1169 indent?(state: State, textAfter: string, context: IndentContext): number | null;1170 /**1171 Default [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) to1172 attach to this language.1173 */1174 languageData?: {1175 [name: string]: any;1176 };1177 /**1178 Extra tokens to use in this parser. When the tokenizer returns a1179 token name that exists as a property in this object, the1180 corresponding tags will be assigned to the token.1181 */1182 tokenTable?: {1183 [name: string]: Tag | readonly Tag[];1184 };1185 /**1186 By default, adjacent tokens of the same type are merged in the1187 output tree. Set this to false to disable that.1188 */1189 mergeTokens?: boolean;1190}1191/**1192A [language](https://codemirror.net/6/docs/ref/#language.Language) class based on a CodeMirror11935-style [streaming parser](https://codemirror.net/6/docs/ref/#language.StreamParser).1194*/1195declare class StreamLanguage<State> extends Language {1196 private constructor();1197 /**1198 Define a stream language.1199 */1200 static define<State>(spec: StreamParser<State>): StreamLanguage<State>;