(token)
| 130519 | result.push(type); |
| 130520 | } |
| 130521 | function classifyLeadingTriviaAndGetTokenStart(token) { |
| 130522 | triviaScanner.setTextPos(token.pos); |
| 130523 | while (true) { |
| 130524 | var start = triviaScanner.getTextPos(); |
| 130525 | // only bother scanning if we have something that could be trivia. |
| 130526 | if (!ts.couldStartTrivia(sourceFile.text, start)) { |
| 130527 | return start; |
| 130528 | } |
| 130529 | var kind = triviaScanner.scan(); |
| 130530 | var end = triviaScanner.getTextPos(); |
| 130531 | var width = end - start; |
| 130532 | // The moment we get something that isn't trivia, then stop processing. |
| 130533 | if (!ts.isTrivia(kind)) { |
| 130534 | return start; |
| 130535 | } |
| 130536 | switch (kind) { |
| 130537 | case 4 /* SyntaxKind.NewLineTrivia */: |
| 130538 | case 5 /* SyntaxKind.WhitespaceTrivia */: |
| 130539 | // Don't bother with newlines/whitespace. |
| 130540 | continue; |
| 130541 | case 2 /* SyntaxKind.SingleLineCommentTrivia */: |
| 130542 | case 3 /* SyntaxKind.MultiLineCommentTrivia */: |
| 130543 | // Only bother with the trivia if it at least intersects the span of interest. |
| 130544 | classifyComment(token, kind, start, width); |
| 130545 | // Classifying a comment might cause us to reuse the trivia scanner |
| 130546 | // (because of jsdoc comments). So after we classify the comment make |
| 130547 | // sure we set the scanner position back to where it needs to be. |
| 130548 | triviaScanner.setTextPos(end); |
| 130549 | continue; |
| 130550 | case 7 /* SyntaxKind.ConflictMarkerTrivia */: |
| 130551 | var text = sourceFile.text; |
| 130552 | var ch = text.charCodeAt(start); |
| 130553 | // for the <<<<<<< and >>>>>>> markers, we just add them in as comments |
| 130554 | // in the classification stream. |
| 130555 | if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { |
| 130556 | pushClassification(start, width, 1 /* ClassificationType.comment */); |
| 130557 | continue; |
| 130558 | } |
| 130559 | // for the ||||||| and ======== markers, add a comment for the first line, |
| 130560 | // and then lex all subsequent lines up until the end of the conflict marker. |
| 130561 | ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); |
| 130562 | classifyDisabledMergeCode(text, start, end); |
| 130563 | break; |
| 130564 | case 6 /* SyntaxKind.ShebangTrivia */: |
| 130565 | // TODO: Maybe we should classify these. |
| 130566 | break; |
| 130567 | default: |
| 130568 | ts.Debug.assertNever(kind); |
| 130569 | } |
| 130570 | } |
| 130571 | } |
| 130572 | function classifyComment(token, kind, start, width) { |
| 130573 | if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { |
| 130574 | // See if this is a doc comment. If so, we'll classify certain portions of it |
no test coverage detected