Skip to content

Commit

Permalink
fix changes missed in merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sandersn committed Mar 7, 2023
1 parent 9427037 commit c91de88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
21 changes: 10 additions & 11 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8606,10 +8606,6 @@ namespace Parser {
}
loop: while (true) {
switch (token()) {
case SyntaxKind.JSDocCommentTextToken:
state = JSDocState.SavingComments;
pushComment(scanner.getTokenValue());
break;
case SyntaxKind.AtToken:
removeTrailingWhitespace(comments);
if (!commentsPos) commentsPos = getNodePos();
Expand Down Expand Up @@ -8650,6 +8646,10 @@ namespace Parser {
break;
case SyntaxKind.EndOfFileToken:
break loop;
case SyntaxKind.JSDocCommentTextToken:
state = JSDocState.SavingComments;
pushComment(scanner.getTokenValue());
break;
case SyntaxKind.OpenBraceToken:
state = JSDocState.SavingComments;
const commentEnd = scanner.getTokenFullStart();
Expand Down Expand Up @@ -8882,20 +8882,13 @@ namespace Parser {
let tok = token() as JSDocSyntaxKind | SyntaxKind.JSDocCommentTextToken;
loop: while (true) {
switch (tok) {
case SyntaxKind.JSDocCommentTextToken:
if (state !== JSDocState.SavingBackticks) {
state = JSDocState.SavingComments; // leading identifiers start recording as well
}
pushComment(scanner.getTokenValue());
break;
case SyntaxKind.NewLineTrivia:
state = JSDocState.BeginningOfLine;
// don't use pushComment here because we want to keep the margin unchanged
comments.push(scanner.getTokenText());
indent = 0;
break;
case SyntaxKind.AtToken:
scanner.setTextPos(scanner.getTextPos() - 1);
scanner.resetTokenState(scanner.getTokenEnd() - 1);
break loop;
case SyntaxKind.EndOfFileToken:
Expand Down Expand Up @@ -8935,6 +8928,12 @@ namespace Parser {
}
pushComment(scanner.getTokenText());
break;
case SyntaxKind.JSDocCommentTextToken:
if (state !== JSDocState.SavingBackticks) {
state = JSDocState.SavingComments; // leading identifiers start recording as well
}
pushComment(scanner.getTokenValue());
break;
case SyntaxKind.AsteriskToken:
if (state === JSDocState.BeginningOfLine) {
// leading asterisks start recording on the *next* (non-whitespace) token
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2471,7 +2471,7 @@ export function createScanner(languageVersion: ScriptTarget,
}

function scanJSDocCommentTextToken(inBackticks: boolean): JSDocSyntaxKind | SyntaxKind.JSDocCommentTextToken {
startPos = tokenPos = pos;
fullStartPos = tokenStart = pos;
tokenFlags = TokenFlags.None;
if (pos >= end) {
return token = SyntaxKind.EndOfFileToken;
Expand All @@ -2491,10 +2491,10 @@ export function createScanner(languageVersion: ScriptTarget,
}
}
}
if (pos === tokenPos) {
if (pos === tokenStart) {
return scanJsDocToken();
}
tokenValue = text.substring(tokenPos, pos);
tokenValue = text.substring(tokenStart, pos);
return token = SyntaxKind.JSDocCommentTextToken;
}

Expand Down

0 comments on commit c91de88

Please sign in to comment.