You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JSDoc: Start SavingComments 1 more case in the parser
When whitespace crosses an earlier indent margin, that is, when a line
is indented further than a previous one, we have to slice that
whitespace, but we also know that subsequent text will be comment text,
so can switch to SavingComments.
Copy file name to clipboardExpand all lines: src/compiler/parser.ts
+4-2
Original file line number
Diff line number
Diff line change
@@ -8886,7 +8886,7 @@ namespace Parser {
8886
8886
if (state !== JSDocState.SavingBackticks) {
8887
8887
state = JSDocState.SavingComments; // leading identifiers start recording as well
8888
8888
}
8889
-
pushComment(scanner.getTokenValue()); // getTokenValue gets the already-sliced identifier text (TODO: the scanner only pre-slices Identifiers, nothing else)
8889
+
pushComment(scanner.getTokenValue());
8890
8890
break;
8891
8891
case SyntaxKind.NewLineTrivia:
8892
8892
state = JSDocState.BeginningOfLine;
@@ -8901,13 +8901,15 @@ namespace Parser {
8901
8901
// Done
8902
8902
break loop;
8903
8903
case SyntaxKind.WhitespaceTrivia:
8904
+
// TODO: This could simplify somewhat if the scanner could also parse leading whitespace-asterisk sequences
8904
8905
Debug.assert(state !== JSDocState.SavingComments && state !== JSDocState.SavingBackticks, "whitespace shouldn't come from the scanner while saving comment text")
8905
8906
const whitespace = scanner.getTokenText();
8906
8907
// if the whitespace crosses the margin, take only the whitespace that passes the margin
indent += whitespace.length; // TODO: What happens if we start saving comments here? We don't support margins like | <margin here> * text text | do we?
0 commit comments