MCPcopy
hub / github.com/ternjs/tern / jsdocParseTypedefs

Function jsdocParseTypedefs

plugin/doc_comment.js:463–481  ·  view source on GitHub ↗
(text, scope)

Source from the content-addressed store, hash-verified

461 }
462
463 function jsdocParseTypedefs(text, scope) {
464 var cx = infer.cx();
465
466 var re = /\s@typedef\s+(.*)/g, m;
467 while (m = re.exec(text)) {
468 var parsed = parseTypeOuter(scope, m[1]);
469 var name = parsed && m[1].slice(parsed.end).match(/^\s*(\S+)/);
470 if (name && parsed.type instanceof infer.Obj) {
471 var rest = text.slice(m.index + m[0].length);
472 while (m = /\s+@prop(?:erty)?\s+(.*)/.exec(rest)) {
473 var propType = parseTypeOuter(scope, m[1]), propName;
474 if (propType && (propName = m[1].slice(propType.end).match(/^\s*(\S+)/)))
475 propType.type.propagate(parsed.type.defProp(propName[1]));
476 rest = rest.slice(m[0].length);
477 }
478 cx.parent.mod.jsdocTypedefs[name[1]] = parsed.type;
479 }
480 }
481 }
482
483 function propagateWithWeight(type, target) {
484 var weight = infer.cx().parent.mod.docComment.weight;

Callers 1

postInferFunction · 0.85

Calls 1

parseTypeOuterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…