promptFileParser.ts ×7

Frontier kind: Code frontier

unlabeled · c_4b70edcb28a4

58 tests · 6869 LOC · 35 files · introduces 0 tests · 47 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges47 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1044 ranges6869 lines · 35 files · Browse complete extent
All tests (intent)
58 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 47 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/promptSyntax/promptFileParser.ts 39 introduced LOC · 7 ranges

Open complete file

416
417 private getParsedBody(): ParsedBody {
418 > if (this._parsed === undefined) { promptFileParser.ts
419 > const markdownLinkRanges: Range[] = [];
420 > const fileReferences: IBodyFileReference[] = [];
421 > const variableReferences: IBodyVariableReference[] = [];
422 > const bodyOffset = Iterable.reduce(Iterable.slice(this.linesWithEOL, 0, this.range.startLineNumber - 1), (len, line) => line.length + len, 0);
423 > let inFencedCodeBlock = false;
424 > let fencedCodeBlockFenceChar: string | undefined;
425 > let fencedCodeBlockFenceLength = 0;
426 > for (let i = this.range.startLineNumber - 1, lineStartOffset = bodyOffset; i < this.range.endLineNumber - 1; i++) {
427 > const line = this.linesWithEOL[i];
428 > const trimmedLine = line.trimStart();
429 >
430 > // Detect fenced code block lines (``` or ~~~, 3 or more chars)
431 > const fenceMatch = /^(?<fence>(`{3,}|~{3,}))/u.exec(trimmedLine);
432 > if (fenceMatch) {
433 const fence = fenceMatch.groups!.fence;
434 const fenceChar = fence[0];
455 }
456 }
458 > // Skip all lines inside fenced code blocks
459 > if (inFencedCodeBlock) {
460 lineStartOffset += line.length;
461 continue;
462 }
464 > // Collect inline code spans (backtick-delimited) to exclude from matching
465 > const inlineCodeRanges: { start: number; end: number }[] = [];
466 > for (const inlineMatch of line.matchAll(/`[^`]+`/g)) {
467 inlineCodeRanges.push({ start: inlineMatch.index, end: inlineMatch.index + inlineMatch[0].length });
468 }
470 > const isInsideInlineCode = (offset: number) => {
471 return inlineCodeRanges.some(r => offset >= r.start && offset < r.end);
472 };
474 > // Match markdown links: [text](link)
475 > const linkMatch = line.matchAll(/\[(.*?)\]\((.+?)\)/g);
476 > for (const match of linkMatch) {
477 if (match.index > 0 && line[match.index - 1] === '!') {
478 continue; // skip image links
487 markdownLinkRanges.push(new Range(i + 1, match.index + 1, i + 1, match.index + match[0].length + 1));
488 }
489 > // Match #file:<filePath> and #tool:<toolName> promptFileParser.ts
490 > // Regarding the <toolName> pattern below, see also the variableReg regex in chatRequestParser.ts.
491 > const reg = /#file:(?<filePath>[^\s#]+)|#tool:(?<toolName>[\w_\-\.\/]+)/gi;
492 > const matches = line.matchAll(reg);
493 > for (const match of matches) {
494 const fullMatch = match[0];
495 const fullRange = new Range(i + 1, match.index + 1, i + 1, match.index + fullMatch.length + 1);
513 }
514 }
515 > lineStartOffset += line.length; promptFileParser.ts
516 > }
517 > this._parsed = { fileReferences: fileReferences.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range)), variableReferences, bodyOffset };
518 > }
519 > return this._parsed;
520 > }
521
522 public getContent(): string {
src/vs/base/common/iterator.ts 8 introduced LOC · 6 ranges

Open complete file

133 */
134 export function* slice<T>(arr: ReadonlyArray<T>, from: number, to = arr.length): Iterable<T> {
135 > if (from < -arr.length) { iterator.ts
136 from = 0;
137 }
138 > if (from < 0) { iterator.ts
139 from += arr.length;
140 }
141 > iterator.ts
142 > if (to < 0) {
143 to += arr.length;
144 > } else if (to > arr.length) { iterator.ts
145 to = arr.length;
146 }
147 > iterator.ts
148 > for (; from < to; from++) {
149 yield arr[from];
150 }
151 > } iterator.ts
152
153 /**