MCPcopy Index your code
hub / github.com/ternjs/tern / postInfer

Function postInfer

plugin/doc_comment.js:60–133  ·  view source on GitHub ↗
(ast, scope)

Source from the content-addressed store, hash-verified

58 }
59
60 function postInfer(ast, scope) {
61 jsdocParseTypedefs(ast.sourceFile.text, scope);
62
63 walk.simple(ast, {
64 VariableDeclaration: function(node, scope) {
65 var decl = node.declarations[0].id;
66 if (node.commentsBefore && decl.type == "Identifier")
67 interpretComments(node, node.commentsBefore, scope,
68 scope.getProp(node.declarations[0].id.name));
69 },
70 FunctionDeclaration: function(node, scope) {
71 if (node.commentsBefore)
72 interpretComments(node, node.commentsBefore, scope,
73 scope.getProp(node.id.name),
74 node.scope.fnType);
75 },
76 ClassDeclaration: function(node, scope) {
77 if (node.commentsBefore)
78 interpretComments(node, node.commentsBefore, scope,
79 scope.getProp(node.id.name),
80 node.objType);
81 },
82 AssignmentExpression: function(node, scope) {
83 if (node.commentsBefore)
84 interpretComments(node, node.commentsBefore, scope,
85 infer.expressionType({node: node.left, state: scope}));
86 },
87 ObjectExpression: function(node, scope) {
88 for (var i = 0; i < node.properties.length; ++i) {
89 var prop = node.properties[i];
90 if (prop.type == 'SpreadElement') { continue; }
91 var name = infer.propName(prop);
92 if (name != "<i>" && prop.commentsBefore)
93 interpretComments(prop, prop.commentsBefore, scope, node.objType.getProp(name));
94 }
95 },
96 Class: function(node, scope) {
97 if (!node.objType) return;
98 var proto = node.objType.getProp("prototype").getObjType();
99 if (!proto) return;
100 for (var i = 0; i < node.body.body.length; i++) {
101 var method = node.body.body[i], name;
102 if (!method.commentsBefore) continue;
103 if (method.kind == "constructor")
104 interpretComments(method, method.commentsBefore, scope, node.objType);
105 else if ((name = infer.propName(method)) != "<i>")
106 interpretComments(method, method.commentsBefore, scope, proto.getProp(name));
107 }
108 },
109 CallExpression: function(node, scope) {
110 if (node.commentsBefore && isDefinePropertyCall(node)) {
111 var type = infer.expressionType({node: node.arguments[0], state: scope}).getObjType();
112 if (type && type instanceof infer.Obj) {
113 var prop = type.props[node.arguments[1].value];
114 if (prop) interpretComments(node, node.commentsBefore, scope, prop);
115 }
116 }
117 },

Callers

nothing calls this directly

Calls 3

jsdocParseTypedefsFunction · 0.85
interpretCommentsFunction · 0.85
isDefinePropertyCallFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…