UNPKG

1.76 kBTypeScriptView Raw
1import { ParserContext } from './ParserContext';
2import { Token } from './Token';
3import { TextRange } from './TextRange';
4/**
5 * Constructor parameters for {@link TokenSequence}
6 */
7export interface ITokenSequenceParameters {
8 parserContext: ParserContext;
9 startIndex: number;
10 endIndex: number;
11}
12/**
13 * Represents a sequence of tokens extracted from `ParserContext.tokens`.
14 * This sequence is defined by a starting index and ending index into that array.
15 */
16export declare class TokenSequence {
17 /**
18 * The associated parser context that the tokens come from.
19 */
20 readonly parserContext: ParserContext;
21 private _startIndex;
22 private _endIndex;
23 constructor(parameters: ITokenSequenceParameters);
24 /**
25 * Constructs a TokenSequence object with no tokens.
26 */
27 static createEmpty(parserContext: ParserContext): TokenSequence;
28 /**
29 * The starting index into the associated `ParserContext.tokens` list.
30 */
31 get startIndex(): number;
32 /**
33 * The (non-inclusive) ending index into the associated `ParserContext.tokens` list.
34 */
35 get endIndex(): number;
36 get tokens(): ReadonlyArray<Token>;
37 /**
38 * Constructs a TokenSequence that corresponds to a different range of tokens,
39 * e.g. a subrange.
40 */
41 getNewSequence(startIndex: number, endIndex: number): TokenSequence;
42 /**
43 * Returns a TextRange that includes all tokens in the sequence (including any additional
44 * characters between doc comment lines).
45 */
46 getContainingTextRange(): TextRange;
47 isEmpty(): boolean;
48 /**
49 * Returns the concatenated text of all the tokens.
50 */
51 toString(): string;
52 private _validateBounds;
53}
54//# sourceMappingURL=TokenSequence.d.ts.map
\No newline at end of file