Skip to content

Commit bf9d2c4

Browse files
committed
Updated comments for iterateCommentRanges
1 parent b896aae commit bf9d2c4

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

src/compiler/scanner.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -584,15 +584,24 @@ namespace ts {
584584
}
585585

586586
/**
587-
* Extract comments from text prefixing the token closest following `pos`.
588-
* The return value is an array containing a TextRange for each comment.
589-
* Single-line comment ranges include the beginning '//' characters but not the ending line break.
590-
* Multi - line comment ranges include the beginning '/* and ending '<asterisk>/' characters.
591-
* The return value is undefined if no comments were found.
592-
* @param trailing
593-
* If false, whitespace is skipped until the first line break and comments between that location
594-
* and the next token are returned.
595-
* If true, comments occurring between the given position and the next line break are returned.
587+
* Invokes a callback for each comment range following the provided position.
588+
*
589+
* Single-line comment ranges include the leading double-slash characters but not the ending
590+
* line break. Multi-line comment ranges include the leading slash-asterisk and trailing
591+
* asterisk-slash characters.
592+
*
593+
* @param reduce If true, accumulates the result of calling the callback in a fashion similar
594+
* to reduceLeft. If false, iteration stops when the callback returns a truthy value.
595+
* @param text The source text to scan.
596+
* @param pos The position at which to start scanning.
597+
* @param trailing If false, whitespace is skipped until the first line break and comments
598+
* between that location and the next token are returned. If true, comments occurring
599+
* between the given position and the next line break are returned.
600+
* @param cb The callback to execute as each comment range is encountered.
601+
* @param state A state value to pass to each iteration of the callback.
602+
* @param initial An initial value to pass when accumulating results (when "reduce" is true).
603+
* @returns If "reduce" is true, the accumulated value. If "reduce" is false, the first truthy
604+
* return value of the callback.
596605
*/
597606
function iterateCommentRanges<T, U>(reduce: boolean, text: string, pos: number, trailing: boolean, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial?: U): U {
598607
let pendingPos: number;

0 commit comments

Comments
 (0)