MCPcopy Index your code
hub / github.com/dchester/jsonpath / addComment

Function addComment

jsonpath.js:344–373  ·  view source on GitHub ↗
(type, value, start, end, loc)

Source from the content-addressed store, hash-verified

342 // 7.4 Comments
343
344 function addComment(type, value, start, end, loc) {
345 var comment, attacher;
346
347 assert(typeof start === 'number', 'Comment must have valid position');
348
349 // Because the way the actual token is scanned, often the comments
350 // (if any) are skipped twice during the lexical analysis.
351 // Thus, we need to skip adding a comment if the comment array already
352 // handled it.
353 if (state.lastCommentStart >= start) {
354 return;
355 }
356 state.lastCommentStart = start;
357
358 comment = {
359 type: type,
360 value: value
361 };
362 if (extra.range) {
363 comment.range = [start, end];
364 }
365 if (extra.loc) {
366 comment.loc = loc;
367 }
368 extra.comments.push(comment);
369 if (extra.attachComment) {
370 extra.leadingComments.push(comment);
371 extra.trailingComments.push(comment);
372 }
373 }
374
375 function skipSingleLineComment(offset) {
376 var start, loc, ch, comment;

Callers 2

skipSingleLineCommentFunction · 0.85
skipMultiLineCommentFunction · 0.85

Calls 1

assertFunction · 0.85

Tested by

no test coverage detected