-
-
Save mysticatea/b15211db22f2a318b04462f90c8f60da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Predicate { | |
(token: Token|Comment): boolean | |
} | |
interface SkipOptions { | |
includeComments?: boolean | |
skip?: number | |
filter?: Predicate | |
} | |
interface CountOptions { | |
includeComments?: boolean | |
count?: number | |
filter?: Predicate | |
} | |
interface TokenStore { | |
constructor(tokens: Token[], comments: Comment[]) | |
//-------------------------------------------------------------------------- | |
// Methods which return single token. | |
//-------------------------------------------------------------------------- | |
getTokenByRangeStart(startOffset: number): Token|null | |
// Tokens only (If the options argument is a number, it's current API.) | |
getFirstToken(node: Node, options?: number|Predicate|SkipOptions): Token|Comment|null | |
getLastToken(node: Node, options?: number|Predicate|SkipOptions): Token|Comment|null | |
getTokenBefore(node: Node|Comment|Token, options?: number|Predicate|SkipOptions): Token|Comment|null | |
getTokenAfter(node: Node|Comment|Token, options?: number|Predicate|SkipOptions): Token|Comment|null | |
getFirstTokenBetween(left: Node|Comment|Token, right: Node|Comment|Token, options?: number|Predicate|SkipOptions): Token|Comment|null | |
getLastTokenBetween(left: Node|Comment|Token, right: Node|Comment|Token, options?: number|Predicate|SkipOptions): Token|Comment|null | |
// For backward compatibility. | |
getTokenOrCommentBefore(node: Node|Comment|Token, skip?: number): Token|Comment|null | |
getTokenOrCommentAfter(node: Node|Comment|Token, skip?: number): Token|Comment|null | |
//-------------------------------------------------------------------------- | |
// Methods which return multiple tokens. | |
//-------------------------------------------------------------------------- | |
// Tokens only (If the options argument is a number, it's current API.) | |
getFirstTokens(node: Node, options?: number|Predicate|CountOptions): (Token|Comment)[] | |
getLastTokens(node: Node, options?: number|Predicate|CountOptions): (Token|Comment)[] | |
getTokensBefore(node: Node|Comment|Token, options?: number|Predicate|CountOptions): (Token|Comment)[] | |
getTokensAfter(node: Node|Comment|Token, options?: number|Predicate|CountOptions): (Token|Comment)[] | |
getFirstTokensBetween(left: Node|Comment|Token, right: Node|Comment|Token, options?: number|Predicate|CountOptions): (Token|Comment)[] | |
getLastTokensBetween(left: Node|Comment|Token, right: Node|Comment|Token, options?: number|Predicate|CountOptions): (Token|Comment)[] | |
// For backward compatibility, those don't have count option but have padding options. | |
getTokens(node: Node, beforePadding?: number, afterPadding?: number): Token[] | |
getTokensBetween(left: Node|Comment|Token, right: Node|Comment|Token, padding?: number): Token[] | |
// Overloads of ↑ without paddings. | |
getTokens(node: Node, options: Predicate|CountOptions): (Token|Comment)[] | |
getTokensBetween(left: Node|Comment|Token, right: Node|Comment|Token, options: Predicate|CountOptions): (Token|Comment)[] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment