path.ts ×7

Frontier kind: Joint frontier

unlabeled · c_166f53382523

1 test · 3727 LOC · 18 files · introduces 1 test · 104 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
7 ranges104 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
537 ranges3727 lines · 18 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

Introduced files, introduced tests, and structurally relevant concept specializationpath.ts ×2 · 6 introduced LOCpath.ts ×2path.ts ×1 · 2 introduced LOCpath.ts ×1path.ts ×1 · 4 introduced LOCpath.ts ×1path.ts ×8 · 101 introduced LOCpath.ts ×8path.ts ×2 · 14 introduced LOCpath.ts ×2path.ts ×1 · 5 introduced LOCpath.ts ×1path.ts ×3 · 4 introduced LOCpath.ts ×3path.ts ×3 · 4 introduced LOCpath.ts ×3path.ts ×3 · 15 introduced LOCpath.ts ×3path.ts ×3 · 28 introduced LOCpath.ts ×3path.ts ×1 · 2 introduced LOCpath.ts ×1path.ts ×3 · 9 introduced LOCpath.ts ×3path.ts ×1 · 2 introduced LOCpath.ts ×1path.ts ×1 · 1 introduced LOCpath.ts ×1path.ts ×2 · 3 introduced LOCpath.ts ×2path.ts ×1 · 3 introduced LOCpath.ts ×1uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3path.ts ×1 · 2 introduced LOCpath.ts ×1path.ts ×3 · 10 introduced LOCpath.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2path.ts ×1 · 1 introduced LOCpath.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1path.ts ×6 · 24 introduced LOCpath.ts ×6lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1path.ts ×2 · 3 introduced LOCpath.ts ×2lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/nls.ts · 244 LOCvs/nls.tscharCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…path.test|title=Paths (Node Implementation) relative|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) relative|occurrence=1path.test|title=Paths (N…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…Focused concept · path.ts ×7 · 104 introduced LOCpath.ts ×7

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.

1 test introduced at this concept.

Introduced code

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

1 file ranked by introduced lines: 104 introduced LOC across 7 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/path.ts 104 introduced LOC · 7 ranges

Open complete file

543 // The output of the function should be: '..\\..\\impl\\bbb'
544 relative(from: string, to: string): string {
545 > validateString(from, 'from'); path.ts
546 > validateString(to, 'to');
547 >
548 > if (from === to) {
549 > return '';
550 > }
551 >
552 > const fromOrig = win32.resolve(from);
553 > const toOrig = win32.resolve(to);
554 >
555 > if (fromOrig === toOrig) {
556 return '';
557 }
558 > path.ts
559 > from = fromOrig.toLowerCase();
560 > to = toOrig.toLowerCase();
561 >
562 > if (from === to) {
563 > return '';
564 > }
565 >
566 > if (fromOrig.length !== from.length || toOrig.length !== to.length) {
567 const fromSplit = fromOrig.split('\\');
568 const toSplit = toOrig.split('\\');
599 return '..\\'.repeat(fromLen - i) + toSplit.slice(i).join('\\');
600 }
601 > path.ts
602 > // Trim any leading backslashes
603 > let fromStart = 0;
604 > while (fromStart < from.length &&
605 > from.charCodeAt(fromStart) === CHAR_BACKWARD_SLASH) {
606 > fromStart++;
607 > }
608 > // Trim trailing backslashes (applicable to UNC paths only)
609 > let fromEnd = from.length;
610 > while (fromEnd - 1 > fromStart &&
611 > from.charCodeAt(fromEnd - 1) === CHAR_BACKWARD_SLASH) {
612 > fromEnd--;
613 > }
614 > const fromLen = fromEnd - fromStart;
615 >
616 > // Trim any leading backslashes
617 > let toStart = 0;
618 > while (toStart < to.length &&
619 > to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
620 > toStart++;
621 > }
622 > // Trim trailing backslashes (applicable to UNC paths only)
623 > let toEnd = to.length;
624 > while (toEnd - 1 > toStart &&
625 > to.charCodeAt(toEnd - 1) === CHAR_BACKWARD_SLASH) {
626 > toEnd--;
627 > }
628 > const toLen = toEnd - toStart;
629 >
630 > // Compare paths to find the longest common path from root
631 > const length = fromLen < toLen ? fromLen : toLen;
632 > let lastCommonSep = -1;
633 > let i = 0;
634 > for (; i < length; i++) {
635 > const fromCode = from.charCodeAt(fromStart + i);
636 > if (fromCode !== to.charCodeAt(toStart + i)) {
637 > break;
638 > } else if (fromCode === CHAR_BACKWARD_SLASH) {
639 > lastCommonSep = i;
640 > }
641 > }
642 >
643 > // We found a mismatch before the first common path separator was seen, so
644 > // return the original `to`.
645 > if (i !== length) {
646 > if (lastCommonSep === -1) {
647 > return toOrig;
648 > }
649 > } else {
650 > if (toLen > length) {
651 > if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
652 > // We get here if `from` is the exact base path for `to`.
653 > // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
654 > return toOrig.slice(toStart + i + 1);
655 > }
656 > if (i === 2) {
657 // We get here if `from` is the device root.
658 // For example: from='C:\\'; to='C:\\foo'
659 return toOrig.slice(toStart + i);
660 }
661 > } path.ts
662 > if (fromLen > length) {
663 > if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
664 > // We get here if `to` is the exact base path for `from`.
665 > // For example: from='C:\\foo\\bar'; to='C:\\foo'
666 > lastCommonSep = i;
667 > } else if (i === 2) {
668 // We get here if `to` is the device root.
669 // For example: from='C:\\foo\\bar'; to='C:\\'
670 lastCommonSep = 3;
671 }
672 > } path.ts
673 > if (lastCommonSep === -1) {
674 lastCommonSep = 0;
675 }
676 > } path.ts
677 >
678 > let out = '';
679 > // Generate the relative path based on the path difference between `to` and
680 > // `from`
681 > for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
682 > if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
683 > out += out.length === 0 ? '..' : '\\..';
684 > }
685 > }
686 >
687 > toStart += lastCommonSep;
688 >
689 > // Lastly, append the rest of the destination (`to`) path that comes after
690 > // the common path parts
691 > if (out.length > 0) {
692 > return `${out}${toOrig.slice(toStart, toEnd)}`;
693 > }
694
695 if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
698
699 return toOrig.slice(toStart, toEnd);
700 > }, path.ts
701
702 toNamespacedPath(path: string): string {