Skip to content

Commit

Permalink
simplify pragma comment parsing (#31144)
Browse files Browse the repository at this point in the history
* simplify pragma parsing

* use emptyArray
  • Loading branch information
ajafff authored and weswigham committed Apr 29, 2019
1 parent 7e135e7 commit de9b91f
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7782,24 +7782,9 @@ namespace ts {

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

// Keep scanning all the leading trivia in the file until we get to something that
// isn't trivia. Any single line comment will be analyzed to see if it is a
// reference comment.
while (true) {
const kind = triviaScanner.scan();
if (!isTrivia(kind)) {
break;
}

const range = {
kind: <SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia>triviaScanner.getToken(),
pos: triviaScanner.getTokenPos(),
end: triviaScanner.getTextPos(),
};

for (const range of getLeadingCommentRanges(sourceText, 0) || emptyArray) {
const comment = sourceText.substring(range.pos, range.end);
extractPragmas(pragmas, range, comment);
}
Expand Down

0 comments on commit de9b91f

Please sign in to comment.