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

Function buildRename

lib/tern.js:1168–1186  ·  view source on GitHub ↗
(srv, query, file)

Source from the content-addressed store, hash-verified

1166 }
1167
1168 function buildRename(srv, query, file) {
1169 if (typeof query.newName != "string") throw ternError(".query.newName should be a string");
1170 var expr = findExprOrThrow(file, query);
1171 if (!expr || expr.node.type != "Identifier") throw ternError("Not at a variable.");
1172
1173 var data = findRefsToVariable(srv, query, file, expr, query.newName), refs = data.refs;
1174 delete data.refs;
1175 data.files = srv.files.map(function(f){return f.name;});
1176
1177 var changes = data.changes = [];
1178 for (var i = 0; i < refs.length; ++i) {
1179 var use = refs[i];
1180 if (use.isShorthand) use.text = expr.node.name + ": " + query.newName;
1181 else use.text = query.newName;
1182 changes.push(use);
1183 }
1184
1185 return data;
1186 }
1187
1188 function listFiles(srv) {
1189 return {files: srv.files.map(function(f){return f.name;})};

Callers

nothing calls this directly

Calls 3

ternErrorFunction · 0.85
findExprOrThrowFunction · 0.85
findRefsToVariableFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…