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

Function hint

lib/web/CodeMirror/addon/tern/tern.js:207–240  ·  view source on GitHub ↗
(ts, cm, c)

Source from the content-addressed store, hash-verified

205 // Completion
206
207 function hint(ts, cm, c) {
208 ts.request(cm, {type: "completions", types: true, docs: true, urls: true}, function(error, data) {
209 if (error) return showError(ts, cm, error);
210 var completions = [], after = "";
211 var from = data.start, to = data.end;
212 if (cm.getRange(Pos(from.line, from.ch - 2), from) == "[\"" &&
213 cm.getRange(to, Pos(to.line, to.ch + 2)) != "\"]")
214 after = "\"]";
215
216 for (var i = 0; i < data.completions.length; ++i) {
217 var completion = data.completions[i], className = typeToIcon(completion.type);
218 if (data.guess) className += " " + cls + "guess";
219 completions.push({text: completion.name + after,
220 displayText: completion.displayName || completion.name,
221 className: className,
222 data: completion});
223 }
224
225 var obj = {from: from, to: to, list: completions};
226 var tooltip = null;
227 CodeMirror.on(obj, "close", function() { remove(tooltip); });
228 CodeMirror.on(obj, "update", function() { remove(tooltip); });
229 CodeMirror.on(obj, "select", function(cur, node) {
230 remove(tooltip);
231 var content = ts.options.completionTip ? ts.options.completionTip(cur.data) : cur.data.doc;
232 if (content) {
233 tooltip = makeTooltip(node.parentNode.getBoundingClientRect().right + window.pageXOffset,
234 node.getBoundingClientRect().top + window.pageYOffset, content, cm);
235 tooltip.className += " " + cls + "hint-doc";
236 }
237 });
238 c(obj);
239 });
240 }
241
242 function typeToIcon(type) {
243 var suffix;

Callers 2

tern.jsFile · 0.85
fetchHintsFunction · 0.85

Calls 9

showErrorFunction · 0.85
typeToIconFunction · 0.85
makeTooltipFunction · 0.85
removeFunction · 0.70
PosFunction · 0.50
cFunction · 0.50
getRangeMethod · 0.45
pushMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected