MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / buildRename

Function buildRename

lib/web/tern/tern.js:1103–1121  ·  view source on GitHub ↗
(srv, query, file)

Source from the content-addressed store, hash-verified

1101 }
1102
1103 function buildRename(srv, query, file) {
1104 if (typeof query.newName != "string") throw ternError(".query.newName should be a string");
1105 var expr = findExprOrThrow(file, query);
1106 if (!expr || expr.node.type != "Identifier") throw ternError("Not at a variable.");
1107
1108 var data = findRefsToVariable(srv, query, file, expr, query.newName), refs = data.refs;
1109 delete data.refs;
1110 data.files = srv.files.map(function(f){return f.name;});
1111
1112 var changes = data.changes = [];
1113 for (var i = 0; i < refs.length; ++i) {
1114 var use = refs[i];
1115 if (use.isShorthand) use.text = expr.node.name + ": " + query.newName
1116 else use.text = query.newName;
1117 changes.push(use);
1118 }
1119
1120 return data;
1121 }
1122
1123 function listFiles(srv) {
1124 return {files: srv.files.map(function(f){return f.name;})};

Callers

nothing calls this directly

Calls 5

ternErrorFunction · 0.85
findExprOrThrowFunction · 0.85
findRefsToVariableFunction · 0.85
mapMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected