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