MCPcopy Index your code
hub / github.com/nodejs/node / classifyJSDocComment

Function classifyJSDocComment

test/fixtures/snapshot/typescript.js:130595–130683  ·  view source on GitHub ↗
(docComment)

Source from the content-addressed store, hash-verified

130593 pushClassification(start, width, 1 /* ClassificationType.comment */);
130594 }
130595 function classifyJSDocComment(docComment) {
130596 var _a, _b, _c, _d, _e, _f, _g;
130597 var pos = docComment.pos;
130598 if (docComment.tags) {
130599 for (var _i = 0, _h = docComment.tags; _i < _h.length; _i++) {
130600 var tag = _h[_i];
130601 // As we walk through each tag, classify the portion of text from the end of
130602 // the last tag (or the start of the entire doc comment) as 'comment'.
130603 if (tag.pos !== pos) {
130604 pushCommentRange(pos, tag.pos - pos);
130605 }
130606 pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@"
130607 pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param"
130608 pos = tag.tagName.end;
130609 var commentStart = tag.tagName.end;
130610 switch (tag.kind) {
130611 case 340 /* SyntaxKind.JSDocParameterTag */:
130612 var param = tag;
130613 processJSDocParameterTag(param);
130614 commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end;
130615 break;
130616 case 347 /* SyntaxKind.JSDocPropertyTag */:
130617 var prop = tag;
130618 commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end;
130619 break;
130620 case 344 /* SyntaxKind.JSDocTemplateTag */:
130621 processJSDocTemplateTag(tag);
130622 pos = tag.end;
130623 commentStart = tag.typeParameters.end;
130624 break;
130625 case 345 /* SyntaxKind.JSDocTypedefTag */:
130626 var type = tag;
130627 commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart;
130628 break;
130629 case 338 /* SyntaxKind.JSDocCallbackTag */:
130630 commentStart = tag.typeExpression.end;
130631 break;
130632 case 343 /* SyntaxKind.JSDocTypeTag */:
130633 processElement(tag.typeExpression);
130634 pos = tag.end;
130635 commentStart = tag.typeExpression.end;
130636 break;
130637 case 342 /* SyntaxKind.JSDocThisTag */:
130638 case 339 /* SyntaxKind.JSDocEnumTag */:
130639 commentStart = tag.typeExpression.end;
130640 break;
130641 case 341 /* SyntaxKind.JSDocReturnTag */:
130642 processElement(tag.typeExpression);
130643 pos = tag.end;
130644 commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart;
130645 break;
130646 case 346 /* SyntaxKind.JSDocSeeTag */:
130647 commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart;
130648 break;
130649 case 328 /* SyntaxKind.JSDocAugmentsTag */:
130650 case 329 /* SyntaxKind.JSDocImplementsTag */:
130651 commentStart = tag.class.end;
130652 break;

Callers 1

classifyCommentFunction · 0.85

Calls 5

pushCommentRangeFunction · 0.85
pushClassificationFunction · 0.85
processJSDocParameterTagFunction · 0.85
processJSDocTemplateTagFunction · 0.85
processElementFunction · 0.85

Tested by

no test coverage detected