MCPcopy Create free account
hub / github.com/TruthHun/BookStack / hint

Function hint

static/editor.md/lib/codemirror/addon/tern/tern.js:204–237  ·  view source on GitHub ↗
(ts, cm, c)

Source from the content-addressed store, hash-verified

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

Callers 1

tern.jsFile · 0.85

Calls 5

typeToIconFunction · 0.85
makeTooltipFunction · 0.85
showErrorFunction · 0.70
removeFunction · 0.70
cFunction · 0.50

Tested by

no test coverage detected