MCPcopy Index your code
hub / github.com/reactjs/react-rails / addComment

Function addComment

lib/assets/javascripts/JSXTransformer.js:2776–2804  ·  view source on GitHub ↗
(type, value, start, end, loc)

Source from the content-addressed store, hash-verified

2774 // 7.4 Comments
2775
2776 function addComment(type, value, start, end, loc) {
2777 var comment;
2778 assert(typeof start === 'number', 'Comment must have valid position');
2779
2780 // Because the way the actual token is scanned, often the comments
2781 // (if any) are skipped twice during the lexical analysis.
2782 // Thus, we need to skip adding a comment if the comment array already
2783 // handled it.
2784 if (state.lastCommentStart >= start) {
2785 return;
2786 }
2787 state.lastCommentStart = start;
2788
2789 comment = {
2790 type: type,
2791 value: value
2792 };
2793 if (extra.range) {
2794 comment.range = [start, end];
2795 }
2796 if (extra.loc) {
2797 comment.loc = loc;
2798 }
2799 extra.comments.push(comment);
2800 if (extra.attachComment) {
2801 extra.leadingComments.push(comment);
2802 extra.trailingComments.push(comment);
2803 }
2804 }
2805
2806 function skipSingleLineComment() {
2807 var start, loc, ch, comment;

Callers 2

skipSingleLineCommentFunction · 0.85
skipMultiLineCommentFunction · 0.85

Calls 1

assertFunction · 0.85

Tested by

no test coverage detected