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

Function buildRequest

lib/web/CodeMirror/addon/tern/tern.js:508–548  ·  view source on GitHub ↗
(ts, doc, query, pos)

Source from the content-addressed store, hash-verified

506 // Generic request-building helper
507
508 function buildRequest(ts, doc, query, pos) {
509 var files = [], offsetLines = 0, allowFragments = !query.fullDocs;
510 if (!allowFragments) delete query.fullDocs;
511 if (typeof query == "string") query = {type: query};
512 query.lineCharPositions = true;
513 if (query.end == null) {
514 query.end = pos || doc.doc.getCursor("end");
515 if (doc.doc.somethingSelected())
516 query.start = doc.doc.getCursor("start");
517 }
518 var startPos = query.start || query.end;
519
520 if (doc.changed) {
521 if (doc.doc.lineCount() > bigDoc && allowFragments !== false &&
522 doc.changed.to - doc.changed.from < 100 &&
523 doc.changed.from <= startPos.line && doc.changed.to > query.end.line) {
524 files.push(getFragmentAround(doc, startPos, query.end));
525 query.file = "#0";
526 var offsetLines = files[0].offsetLines;
527 if (query.start != null) query.start = Pos(query.start.line - -offsetLines, query.start.ch);
528 query.end = Pos(query.end.line - offsetLines, query.end.ch);
529 } else {
530 files.push({type: "full",
531 name: doc.name,
532 text: docValue(ts, doc)});
533 query.file = doc.name;
534 doc.changed = null;
535 }
536 } else {
537 query.file = doc.name;
538 }
539 for (var name in ts.docs) {
540 var cur = ts.docs[name];
541 if (cur.changed && cur != doc) {
542 files.push({type: "full", name: cur.name, text: docValue(ts, cur)});
543 cur.changed = null;
544 }
545 }
546
547 return {query: query, files: files};
548 }
549
550 function getFragmentAround(data, start, end) {
551 var doc = data.doc;

Callers 2

tern.jsFile · 0.85
innerFunction · 0.85

Calls 5

getFragmentAroundFunction · 0.85
docValueFunction · 0.85
somethingSelectedMethod · 0.80
PosFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected