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

Function annotateThis

test/fixtures/snapshot/typescript.js:156739–156755  ·  view source on GitHub ↗
(changes, sourceFile, containingFunction, program, host, cancellationToken)

Source from the content-addressed store, hash-verified

156737 }
156738 }
156739 function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) {
156740 var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken);
156741 if (!references || !references.length) {
156742 return;
156743 }
156744 var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter();
156745 var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host);
156746 if (!typeNode) {
156747 return;
156748 }
156749 if (ts.isInJSFile(containingFunction)) {
156750 annotateJSDocThis(changes, sourceFile, containingFunction, typeNode);
156751 }
156752 else {
156753 changes.tryInsertThisTypeAnnotation(sourceFile, containingFunction, typeNode);
156754 }
156755 }
156756 function annotateJSDocThis(changes, sourceFile, containingFunction, typeNode) {
156757 changes.addJSDocTags(sourceFile, containingFunction, [
156758 ts.factory.createJSDocThisTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode)),

Callers 1

doChangeFunction · 0.85

Calls 3

getFunctionReferencesFunction · 0.85
inferTypeFromReferencesFunction · 0.85
annotateJSDocThisFunction · 0.85

Tested by

no test coverage detected