Skip to content

Commit de9b91f

Browse files
ajafffweswigham
authored andcommitted
simplify pragma comment parsing (#31144)
* simplify pragma parsing * use emptyArray
1 parent 7e135e7 commit de9b91f

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7782,24 +7782,9 @@ namespace ts {
77827782

77837783
/*@internal*/
77847784
export function processCommentPragmas(context: PragmaContext, sourceText: string): void {
7785-
const triviaScanner = createScanner(context.languageVersion, /*skipTrivia*/ false, LanguageVariant.Standard, sourceText);
77867785
const pragmas: PragmaPseudoMapEntry[] = [];
77877786

7788-
// Keep scanning all the leading trivia in the file until we get to something that
7789-
// isn't trivia. Any single line comment will be analyzed to see if it is a
7790-
// reference comment.
7791-
while (true) {
7792-
const kind = triviaScanner.scan();
7793-
if (!isTrivia(kind)) {
7794-
break;
7795-
}
7796-
7797-
const range = {
7798-
kind: <SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia>triviaScanner.getToken(),
7799-
pos: triviaScanner.getTokenPos(),
7800-
end: triviaScanner.getTextPos(),
7801-
};
7802-
7787+
for (const range of getLeadingCommentRanges(sourceText, 0) || emptyArray) {
78037788
const comment = sourceText.substring(range.pos, range.end);
78047789
extractPragmas(pragmas, range, comment);
78057790
}

0 commit comments

Comments
 (0)