@codemirror/language 0.19.8 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- import { NodeProp, NodeType, Parser, Tree, TreeFragment, Input, PartialParse, SyntaxNode } from '@lezer/common';
1
+ import { NodeProp, Parser, Tree, TreeFragment, SyntaxNode, NodeType } from '@lezer/common';
2
2
  import { LRParser, ParserConfig } from '@lezer/lr';
3
- import { Facet, Extension, EditorState } from '@codemirror/state';
4
- import { EditorView } from '@codemirror/view';
3
+ import * as _codemirror_state from '@codemirror/state';
4
+ import { Facet, Extension, EditorState, Range } from '@codemirror/state';
5
+ import { EditorView, DecorationSet, Command, KeyBinding, BlockInfo, Decoration } from '@codemirror/view';
6
+ import { Highlighter, Tag } from '@lezer/highlight';
7
+ import { StyleModule, StyleSpec } from 'style-mod';
5
8
 
6
9
  /**
7
- Node prop stored in a grammar's top syntax node to provide the
8
- facet that stores language data for that language.
10
+ Node prop stored in a parser's top syntax node to provide the
11
+ facet that stores language-specific data for that language.
9
12
  */
10
13
  declare const languageDataProp: NodeProp<Facet<{
11
14
  [name: string]: any;
@@ -30,26 +33,22 @@ declare function defineLanguageFacet(baseData?: {
30
33
  /**
31
34
  A language object manages parsing and per-language
32
35
  [metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
33
- managed as a [Lezer](https://lezer.codemirror.net) tree. You'll
34
- want to subclass this class for custom parsers, or use the
35
- [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage) or
36
- [`StreamLanguage`](https://codemirror.net/6/docs/ref/#stream-parser.StreamLanguage) abstractions for
37
- [Lezer](https://lezer.codemirror.net/) or stream parsers.
36
+ managed as a [Lezer](https://lezer.codemirror.net) tree. The class
37
+ can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
38
+ subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
39
+ via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
40
+ for stream parsers.
38
41
  */
39
42
  declare class Language {
40
43
  /**
41
- The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) data
42
- facet used for this language.
44
+ The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
45
+ used for this language.
43
46
  */
44
47
  readonly data: Facet<{
45
48
  [name: string]: any;
46
49
  }>;
47
50
  /**
48
- The node type of the top node of trees produced by this parser.
49
- */
50
- readonly topNode: NodeType;
51
- /**
52
- The extension value to install this provider.
51
+ The extension value to install this as the document language.
53
52
  */
54
53
  readonly extension: Extension;
55
54
  /**
@@ -58,23 +57,20 @@ declare class Language {
58
57
  */
59
58
  parser: Parser;
60
59
  /**
61
- Construct a language object. You usually don't need to invoke
62
- this directly. But when you do, make sure you use
63
- [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet) to create
64
- the first argument.
60
+ Construct a language object. If you need to invoke this
61
+ directly, first define a data facet with
62
+ [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
63
+ configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
64
+ to the language's outer syntax node.
65
65
  */
66
66
  constructor(
67
67
  /**
68
- The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) data
69
- facet used for this language.
68
+ The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
69
+ used for this language.
70
70
  */
71
71
  data: Facet<{
72
72
  [name: string]: any;
73
- }>, parser: Parser,
74
- /**
75
- The node type of the top node of trees produced by this parser.
76
- */
77
- topNode: NodeType, extraExtensions?: Extension[]);
73
+ }>, parser: Parser, extraExtensions?: Extension[]);
78
74
  /**
79
75
  Query whether this language is active at the given position.
80
76
  */
@@ -129,8 +125,9 @@ declare class LRLanguage extends Language {
129
125
  }
130
126
  /**
131
127
  Get the syntax tree for a state, which is the current (possibly
132
- incomplete) parse tree of active [language](https://codemirror.net/6/docs/ref/#language.Language),
133
- or the empty tree if there is no language available.
128
+ incomplete) parse tree of the active
129
+ [language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
130
+ language available.
134
131
  */
135
132
  declare function syntaxTree(state: EditorState): Tree;
136
133
  /**
@@ -144,19 +141,26 @@ Queries whether there is a full syntax tree available up to the
144
141
  given document position. If there isn't, the background parse
145
142
  process _might_ still be working and update the tree further, but
146
143
  there is no guarantee of that—the parser will [stop
147
- working](https://codemirror.net/6/docs/ref/#language.syntaxParserStopped) when it has spent a
144
+ working](https://codemirror.net/6/docs/ref/#language.syntaxParserRunning) when it has spent a
148
145
  certain amount of time or has moved beyond the visible viewport.
149
146
  Always returns false if no language has been enabled.
150
147
  */
151
148
  declare function syntaxTreeAvailable(state: EditorState, upto?: number): boolean;
152
149
  /**
150
+ Move parsing forward, and update the editor state afterwards to
151
+ reflect the new tree. Will work for at most `timeout`
152
+ milliseconds. Returns true if the parser managed get to the given
153
+ position in that time.
154
+ */
155
+ declare function forceParsing(view: EditorView, upto?: number, timeout?: number): boolean;
156
+ /**
153
157
  Tells you whether the language parser is planning to do more
154
158
  parsing work (in a `requestIdleCallback` pseudo-thread) or has
155
159
  stopped running, either because it parsed the entire document,
156
160
  because it spent too much time and was cut off, or because there
157
161
  is no language parser enabled.
158
162
  */
159
- declare function syntaxParserRunning(view: EditorView): boolean | (() => void);
163
+ declare function syntaxParserRunning(view: EditorView): boolean;
160
164
  /**
161
165
  A parse context provided to parsers working on the editor content.
162
166
  */
@@ -170,7 +174,6 @@ declare class ParseContext {
170
174
  Tree fragments that can be reused by incremental re-parses.
171
175
  */
172
176
  fragments: readonly TreeFragment[];
173
- treeLen: number;
174
177
  /**
175
178
  The current editor viewport (or some overapproximation
176
179
  thereof). Intended to be used for opportunistically avoiding
@@ -202,20 +205,7 @@ declare class ParseContext {
202
205
  When `until` is given, a reparse will be scheduled when that
203
206
  promise resolves.
204
207
  */
205
- static getSkippingParser(until?: Promise<unknown>): {
206
- createParse(input: Input, fragments: readonly TreeFragment[], ranges: readonly {
207
- from: number;
208
- to: number;
209
- }[]): PartialParse;
210
- startParse(input: string | Input, fragments?: readonly TreeFragment[] | undefined, ranges?: readonly {
211
- from: number;
212
- to: number;
213
- }[] | undefined): PartialParse;
214
- parse(input: string | Input, fragments?: readonly TreeFragment[] | undefined, ranges?: readonly {
215
- from: number;
216
- to: number;
217
- }[] | undefined): Tree;
218
- };
208
+ static getSkippingParser(until?: Promise<unknown>): Parser;
219
209
  /**
220
210
  Get the context for the current parse, or `null` if no editor
221
211
  parse is in progress.
@@ -227,7 +217,7 @@ The facet used to associate a language with an editor state.
227
217
  */
228
218
  declare const language: Facet<Language, Language | null>;
229
219
  /**
230
- This class bundles a [language object](https://codemirror.net/6/docs/ref/#language.Language) with an
220
+ This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an
231
221
  optional set of supporting extensions. Language packages are
232
222
  encouraged to export a function that optionally takes a
233
223
  configuration object and returns a `LanguageSupport` instance, as
@@ -252,7 +242,7 @@ declare class LanguageSupport {
252
242
  */
253
243
  extension: Extension;
254
244
  /**
255
- Create a support object.
245
+ Create a language support object.
256
246
  */
257
247
  constructor(
258
248
  /**
@@ -484,7 +474,7 @@ definitive indentation can be determined.
484
474
  declare const indentNodeProp: NodeProp<(context: TreeIndentContext) => number | null>;
485
475
  /**
486
476
  Objects of this type provide context information and helper
487
- methods to indentation functions.
477
+ methods to indentation functions registered on syntax nodes.
488
478
  */
489
479
  declare class TreeIndentContext extends IndentContext {
490
480
  private base;
@@ -608,5 +598,448 @@ declare function foldable(state: EditorState, lineStart: number, lineEnd: number
608
598
  from: number;
609
599
  to: number;
610
600
  } | null;
601
+ declare type DocRange = {
602
+ from: number;
603
+ to: number;
604
+ };
605
+ /**
606
+ State effect that can be attached to a transaction to fold the
607
+ given range. (You probably only need this in exceptional
608
+ circumstances—usually you'll just want to let
609
+ [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold
610
+ gutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)
611
+ */
612
+ declare const foldEffect: _codemirror_state.StateEffectType<DocRange>;
613
+ /**
614
+ State effect that unfolds the given range (if it was folded).
615
+ */
616
+ declare const unfoldEffect: _codemirror_state.StateEffectType<DocRange>;
617
+ /**
618
+ Get a [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) containing the folded ranges
619
+ in the given state.
620
+ */
621
+ declare function foldedRanges(state: EditorState): DecorationSet;
622
+ /**
623
+ Fold the lines that are selected, if possible.
624
+ */
625
+ declare const foldCode: Command;
626
+ /**
627
+ Unfold folded ranges on selected lines.
628
+ */
629
+ declare const unfoldCode: Command;
630
+ /**
631
+ Fold all top-level foldable ranges. Note that, in most cases,
632
+ folding information will depend on the [syntax
633
+ tree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work
634
+ reliably when the document hasn't been fully parsed (either
635
+ because the editor state was only just initialized, or because the
636
+ document is so big that the parser decided not to parse it
637
+ entirely).
638
+ */
639
+ declare const foldAll: Command;
640
+ /**
641
+ Unfold all folded code.
642
+ */
643
+ declare const unfoldAll: Command;
644
+ /**
645
+ Default fold-related key bindings.
646
+
647
+ - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).
648
+ - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).
649
+ - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).
650
+ - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).
651
+ */
652
+ declare const foldKeymap: readonly KeyBinding[];
653
+ interface FoldConfig {
654
+ /**
655
+ A function that creates the DOM element used to indicate the
656
+ position of folded code. The `onclick` argument is the default
657
+ click event handler, which toggles folding on the line that
658
+ holds the element, and should probably be added as an event
659
+ handler to the returned element.
660
+
661
+ When this option isn't given, the `placeholderText` option will
662
+ be used to create the placeholder element.
663
+ */
664
+ placeholderDOM?: ((view: EditorView, onclick: (event: Event) => void) => HTMLElement) | null;
665
+ /**
666
+ Text to use as placeholder for folded text. Defaults to `"…"`.
667
+ Will be styled with the `"cm-foldPlaceholder"` class.
668
+ */
669
+ placeholderText?: string;
670
+ }
671
+ /**
672
+ Create an extension that configures code folding.
673
+ */
674
+ declare function codeFolding(config?: FoldConfig): Extension;
675
+ declare type Handlers = {
676
+ [event: string]: (view: EditorView, line: BlockInfo, event: Event) => boolean;
677
+ };
678
+ interface FoldGutterConfig {
679
+ /**
680
+ A function that creates the DOM element used to indicate a
681
+ given line is folded or can be folded.
682
+ When not given, the `openText`/`closeText` option will be used instead.
683
+ */
684
+ markerDOM?: ((open: boolean) => HTMLElement) | null;
685
+ /**
686
+ Text used to indicate that a given line can be folded.
687
+ Defaults to `"⌄"`.
688
+ */
689
+ openText?: string;
690
+ /**
691
+ Text used to indicate that a given line is folded.
692
+ Defaults to `"›"`.
693
+ */
694
+ closedText?: string;
695
+ /**
696
+ Supply event handlers for DOM events on this gutter.
697
+ */
698
+ domEventHandlers?: Handlers;
699
+ }
700
+ /**
701
+ Create an extension that registers a fold gutter, which shows a
702
+ fold status indicator before foldable lines (which can be clicked
703
+ to fold or unfold the line).
704
+ */
705
+ declare function foldGutter(config?: FoldGutterConfig): Extension;
706
+
707
+ /**
708
+ A highlight style associates CSS styles with higlighting
709
+ [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
710
+ */
711
+ declare class HighlightStyle implements Highlighter {
712
+ /**
713
+ A style module holding the CSS rules for this highlight style.
714
+ When using
715
+ [`highlightTree`](https://lezer.codemirror.net/docs/ref#highlight.highlightTree)
716
+ outside of the editor, you may want to manually mount this
717
+ module to show the highlighting.
718
+ */
719
+ readonly module: StyleModule | null;
720
+ readonly style: (tags: readonly Tag[]) => string | null;
721
+ readonly scope: ((type: NodeType) => boolean) | undefined;
722
+ private constructor();
723
+ /**
724
+ Create a highlighter style that associates the given styles to
725
+ the given tags. The specs must be objects that hold a style tag
726
+ or array of tags in their `tag` property, and either a single
727
+ `class` property providing a static CSS class (for highlighter
728
+ that rely on external styling), or a
729
+ [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
730
+ set of CSS properties (which define the styling for those tags).
731
+
732
+ The CSS rules created for a highlighter will be emitted in the
733
+ order of the spec's properties. That means that for elements that
734
+ have multiple tags associated with them, styles defined further
735
+ down in the list will have a higher CSS precedence than styles
736
+ defined earlier.
737
+ */
738
+ static define(specs: readonly TagStyle[], options?: {
739
+ /**
740
+ By default, highlighters apply to the entire document. You can
741
+ scope them to a single language by providing the language
742
+ object or a language's top node type here.
743
+ */
744
+ scope?: Language | NodeType;
745
+ /**
746
+ Add a style to _all_ content. Probably only useful in
747
+ combination with `scope`.
748
+ */
749
+ all?: string | StyleSpec;
750
+ /**
751
+ Specify that this highlight style should only be active then
752
+ the theme is dark or light. By default, it is active
753
+ regardless of theme.
754
+ */
755
+ themeType?: "dark" | "light";
756
+ }): HighlightStyle;
757
+ }
758
+ /**
759
+ Wrap a highlighter in an editor extension that uses it to apply
760
+ syntax highlighting to the editor content.
761
+
762
+ When multiple (non-fallback) styles are provided, the styling
763
+ applied is the union of the classes they emit.
764
+ */
765
+ declare function syntaxHighlighting(highlighter: Highlighter, options?: {
766
+ /**
767
+ When enabled, this marks the highlighter as a fallback, which
768
+ only takes effect if no other highlighters are registered.
769
+ */
770
+ fallback: boolean;
771
+ }): Extension;
772
+ /**
773
+ Returns the CSS classes (if any) that the highlighters active in
774
+ the state would assign to the given style
775
+ [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag) and
776
+ (optional) language
777
+ [scope](https://codemirror.net/6/docs/ref/#language.HighlightStyle^define^options.scope).
778
+ */
779
+ declare function highlightingFor(state: EditorState, tags: readonly Tag[], scope?: NodeType): string | null;
780
+ /**
781
+ The type of object used in
782
+ [`HighlightStyle.define`](https://codemirror.net/6/docs/ref/#language.HighlightStyle^define).
783
+ Assigns a style to one or more highlighting
784
+ [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag), which can either be a fixed class name
785
+ (which must be defined elsewhere), or a set of CSS properties, for
786
+ which the library will define an anonymous class.
787
+ */
788
+ interface TagStyle {
789
+ /**
790
+ The tag or tags to target.
791
+ */
792
+ tag: Tag | readonly Tag[];
793
+ /**
794
+ If given, this maps the tags to a fixed class name.
795
+ */
796
+ class?: string;
797
+ /**
798
+ Any further properties (if `class` isn't given) will be
799
+ interpreted as in style objects given to
800
+ [style-mod](https://github.com/marijnh/style-mod#documentation).
801
+ (The type here is `any` because of TypeScript limitations.)
802
+ */
803
+ [styleProperty: string]: any;
804
+ }
805
+ /**
806
+ A default highlight style (works well with light themes).
807
+ */
808
+ declare const defaultHighlightStyle: HighlightStyle;
809
+
810
+ interface Config {
811
+ /**
812
+ Whether the bracket matching should look at the character after
813
+ the cursor when matching (if the one before isn't a bracket).
814
+ Defaults to true.
815
+ */
816
+ afterCursor?: boolean;
817
+ /**
818
+ The bracket characters to match, as a string of pairs. Defaults
819
+ to `"()[]{}"`. Note that these are only used as fallback when
820
+ there is no [matching
821
+ information](https://lezer.codemirror.net/docs/ref/#common.NodeProp^closedBy)
822
+ in the syntax tree.
823
+ */
824
+ brackets?: string;
825
+ /**
826
+ The maximum distance to scan for matching brackets. This is only
827
+ relevant for brackets not encoded in the syntax tree. Defaults
828
+ to 10 000.
829
+ */
830
+ maxScanDistance?: number;
831
+ /**
832
+ Can be used to configure the way in which brackets are
833
+ decorated. The default behavior is to add the
834
+ `cm-matchingBracket` class for matching pairs, and
835
+ `cm-nonmatchingBracket` for mismatched pairs or single brackets.
836
+ */
837
+ renderMatch?: (match: MatchResult, state: EditorState) => readonly Range<Decoration>[];
838
+ }
839
+ /**
840
+ Create an extension that enables bracket matching. Whenever the
841
+ cursor is next to a bracket, that bracket and the one it matches
842
+ are highlighted. Or, when no matching bracket is found, another
843
+ highlighting style is used to indicate this.
844
+ */
845
+ declare function bracketMatching(config?: Config): Extension;
846
+ /**
847
+ The result returned from `matchBrackets`.
848
+ */
849
+ interface MatchResult {
850
+ /**
851
+ The extent of the bracket token found.
852
+ */
853
+ start: {
854
+ from: number;
855
+ to: number;
856
+ };
857
+ /**
858
+ The extent of the matched token, if any was found.
859
+ */
860
+ end?: {
861
+ from: number;
862
+ to: number;
863
+ };
864
+ /**
865
+ Whether the tokens match. This can be false even when `end` has
866
+ a value, if that token doesn't match the opening token.
867
+ */
868
+ matched: boolean;
869
+ }
870
+ /**
871
+ Find the matching bracket for the token at `pos`, scanning
872
+ direction `dir`. Only the `brackets` and `maxScanDistance`
873
+ properties are used from `config`, if given. Returns null if no
874
+ bracket was found at `pos`, or a match result otherwise.
875
+ */
876
+ declare function matchBrackets(state: EditorState, pos: number, dir: -1 | 1, config?: Config): MatchResult | null;
877
+
878
+ /**
879
+ Encapsulates a single line of input. Given to stream syntax code,
880
+ which uses it to tokenize the content.
881
+ */
882
+ declare class StringStream {
883
+ /**
884
+ The line.
885
+ */
886
+ string: string;
887
+ private tabSize;
888
+ /**
889
+ The current indent unit size.
890
+ */
891
+ indentUnit: number;
892
+ /**
893
+ The current position on the line.
894
+ */
895
+ pos: number;
896
+ /**
897
+ The start position of the current token.
898
+ */
899
+ start: number;
900
+ private lastColumnPos;
901
+ private lastColumnValue;
902
+ /**
903
+ True if we are at the end of the line.
904
+ */
905
+ eol(): boolean;
906
+ /**
907
+ True if we are at the start of the line.
908
+ */
909
+ sol(): boolean;
910
+ /**
911
+ Get the next code unit after the current position, or undefined
912
+ if we're at the end of the line.
913
+ */
914
+ peek(): string | undefined;
915
+ /**
916
+ Read the next code unit and advance `this.pos`.
917
+ */
918
+ next(): string | void;
919
+ /**
920
+ Match the next character against the given string, regular
921
+ expression, or predicate. Consume and return it if it matches.
922
+ */
923
+ eat(match: string | RegExp | ((ch: string) => boolean)): string | void;
924
+ /**
925
+ Continue matching characters that match the given string,
926
+ regular expression, or predicate function. Return true if any
927
+ characters were consumed.
928
+ */
929
+ eatWhile(match: string | RegExp | ((ch: string) => boolean)): boolean;
930
+ /**
931
+ Consume whitespace ahead of `this.pos`. Return true if any was
932
+ found.
933
+ */
934
+ eatSpace(): boolean;
935
+ /**
936
+ Move to the end of the line.
937
+ */
938
+ skipToEnd(): void;
939
+ /**
940
+ Move to directly before the given character, if found on the
941
+ current line.
942
+ */
943
+ skipTo(ch: string): boolean | void;
944
+ /**
945
+ Move back `n` characters.
946
+ */
947
+ backUp(n: number): void;
948
+ /**
949
+ Get the column position at `this.pos`.
950
+ */
951
+ column(): number;
952
+ /**
953
+ Get the indentation column of the current line.
954
+ */
955
+ indentation(): number;
956
+ /**
957
+ Match the input against the given string or regular expression
958
+ (which should start with a `^`). Return true or the regexp match
959
+ if it matches.
960
+
961
+ Unless `consume` is set to `false`, this will move `this.pos`
962
+ past the matched text.
963
+
964
+ When matching a string `caseInsensitive` can be set to true to
965
+ make the match case-insensitive.
966
+ */
967
+ match(pattern: string | RegExp, consume?: boolean, caseInsensitive?: boolean): boolean | RegExpMatchArray | null;
968
+ /**
969
+ Get the current token.
970
+ */
971
+ current(): string;
972
+ }
973
+
974
+ /**
975
+ A stream parser parses or tokenizes content from start to end,
976
+ emitting tokens as it goes over it. It keeps a mutable (but
977
+ copyable) object with state, in which it can store information
978
+ about the current context.
979
+ */
980
+ interface StreamParser<State> {
981
+ /**
982
+ Produce a start state for the parser.
983
+ */
984
+ startState?(indentUnit: number): State;
985
+ /**
986
+ Read one token, advancing the stream past it, and returning a
987
+ string indicating the token's style tag—either the name of one
988
+ of the tags in
989
+ [`tags`](https://lezer.codemirror.net/docs/ref#highlight.tags),
990
+ or such a name suffixed by one or more tag
991
+ [modifier](https://lezer.codemirror.net/docs/ref#highlight.Tag^defineModifier)
992
+ names, separated by periods. For example `"keyword"` or
993
+ "`variableName.constant"`.
994
+
995
+ It is okay to return a zero-length token, but only if that
996
+ updates the state so that the next call will return a non-empty
997
+ token again.
998
+ */
999
+ token(stream: StringStream, state: State): string | null;
1000
+ /**
1001
+ This notifies the parser of a blank line in the input. It can
1002
+ update its state here if it needs to.
1003
+ */
1004
+ blankLine?(state: State, indentUnit: number): void;
1005
+ /**
1006
+ Copy a given state. By default, a shallow object copy is done
1007
+ which also copies arrays held at the top level of the object.
1008
+ */
1009
+ copyState?(state: State): State;
1010
+ /**
1011
+ Compute automatic indentation for the line that starts with the
1012
+ given state and text.
1013
+ */
1014
+ indent?(state: State, textAfter: string, context: IndentContext): number | null;
1015
+ /**
1016
+ Default [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) to
1017
+ attach to this language.
1018
+ */
1019
+ languageData?: {
1020
+ [name: string]: any;
1021
+ };
1022
+ /**
1023
+ Extra tokens to use in this parser. When the tokenizer returns a
1024
+ token name that exists as a property in this object, the
1025
+ corresponding tag will be assigned to the token.
1026
+ */
1027
+ tokenTable?: {
1028
+ [name: string]: Tag;
1029
+ };
1030
+ }
1031
+ /**
1032
+ A [language](https://codemirror.net/6/docs/ref/#language.Language) class based on a CodeMirror
1033
+ 5-style [streaming parser](https://codemirror.net/6/docs/ref/#language.StreamParser).
1034
+ */
1035
+ declare class StreamLanguage<State> extends Language {
1036
+ private constructor();
1037
+ /**
1038
+ Define a stream language.
1039
+ */
1040
+ static define<State>(spec: StreamParser<State>): StreamLanguage<State>;
1041
+ private getIndent;
1042
+ get allowsNesting(): boolean;
1043
+ }
611
1044
 
612
- export { IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, ParseContext, TreeIndentContext, continuedIndent, defineLanguageFacet, delimitedIndent, ensureSyntaxTree, flatIndent, foldInside, foldNodeProp, foldService, foldable, getIndentUnit, getIndentation, indentNodeProp, indentOnInput, indentService, indentString, indentUnit, language, languageDataProp, syntaxParserRunning, syntaxTree, syntaxTreeAvailable };
1045
+ export { Config, HighlightStyle, IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, MatchResult, ParseContext, StreamLanguage, StreamParser, StringStream, TagStyle, TreeIndentContext, bracketMatching, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, ensureSyntaxTree, flatIndent, foldAll, foldCode, foldEffect, foldGutter, foldInside, foldKeymap, foldNodeProp, foldService, foldable, foldedRanges, forceParsing, getIndentUnit, getIndentation, highlightingFor, indentNodeProp, indentOnInput, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, syntaxHighlighting, syntaxParserRunning, syntaxTree, syntaxTreeAvailable, unfoldAll, unfoldCode, unfoldEffect };