src/vs/base/common/search.ts

48 LOC · 40 covered · 8 uncovered · 9 ranges · 22 concepts · 2 introducers · 8 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

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 related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesrc/vs/workbench/services/search/common/replace.ts · 284 LOCcommon/replace.tssearch.ts ×6 · 31 introduced LOCsearch.ts ×6replace.ts ×2 · 4 introduced LOCreplace.ts ×2replace.test|title=Replace Pattern test case operations and newline|occurrence=1 · 0 introduced LOCreplace.test|title=Repla…replace.ts ×1 · 3 introduced LOCreplace.ts ×1replace.ts ×1 · 3 introduced LOCreplace.ts ×1replace.ts ×8 · 45 introduced LOCreplace.ts ×8replace.ts ×9 · 33 introduced LOCreplace.ts ×9replace.test|title=Replace Pattern test get replace string if given text is a complete match|occurrence=1 · 0 introduced LOCreplace.test|title=Repla…replace.ts ×2 · 6 introduced LOCreplace.ts ×2replace.ts ×5 · 13 introduced LOCreplace.ts ×5replace.ts ×6 · 17 introduced LOCreplace.ts ×6replace.ts ×1 · 3 introduced LOCreplace.ts ×1replace.ts ×1 · 6 introduced LOCreplace.ts ×1replace.ts ×3 · 5 introduced LOCreplace.ts ×3replace.ts ×2 · 4 introduced LOCreplace.ts ×2replace.ts ×1 · 3 introduced LOCreplace.ts ×1replace.ts ×3 · 9 introduced LOCreplace.ts ×3replace.ts ×1 · 2 introduced LOCreplace.ts ×1replace.ts ×7 · 20 introduced LOCreplace.ts ×7replace.ts ×2 · 4 introduced LOCreplace.ts ×2replace.ts ×2 · 7 introduced LOCreplace.ts ×2replace.ts ×15 · 94 introduced LOCreplace.ts ×15replace.test|title=Replace Pattern test case operations - no false positive|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/search/test/common/replace.test|title=Replace Pattern test case operations - no false positive|occurrence=1replace.test|title=Repla…replace.test|title=Replace Pattern test case operations and newline|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/search/test/common/replace.test|title=Replace Pattern test case operations and newline|occurrence=1replace.test|title=Repla…replace.test|title=Replace Pattern test case operations|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/search/test/common/replace.test|title=Replace Pattern test case operations|occurrence=1replace.test|title=Repla…replace.test|title=Replace Pattern test create pattern by passing regExp|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/search/test/common/replace.test|title=Replace Pattern test create pattern by passing regExp|occurrence=1replace.test|title=Repla…replace.test|title=Replace Pattern test get replace string for no matches|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/search/test/common/replace.test|title=Replace Pattern test get replace string for no matches|occurrence=1replace.test|title=Repla…replace.test|title=Replace Pattern test get replace string if given text is a complete match|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/search/test/common/replace.test|title=Replace Pattern test get replace string if given text is a complete match|occurrence=1replace.test|title=Repla…replace.test|title=Replace Pattern test get replace string if match is sub-string of the text|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/search/test/common/replace.test|title=Replace Pattern test get replace string if match is sub-string of the text|occurrence=1replace.test|title=Repla…replace.test|title=Replace Pattern test parse replace string|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/search/test/common/replace.test|title=Replace Pattern test parse replace string|occurrence=1replace.test|title=Repla…Focused file · src/vs/base/common/search.ts · 48 LOCcommon/search.ts

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- replace.ts ×15
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import * as strings from './strings.js';
7 >
8 > export function buildReplaceStringWithCasePreserved(matches: string[] | null, pattern: string): string {
9 > if (matches && (matches[0] !== '')) { search.ts ×6
10 > const containsHyphens = validateSpecificSpecialCharacter(matches, pattern, '-');
11 > const containsUnderscores = validateSpecificSpecialCharacter(matches, pattern, '_');
12 > if (containsHyphens && !containsUnderscores) {
13 > return buildReplaceStringForSpecificSpecialCharacter(matches, pattern, '-');
14 > } else if (!containsHyphens && containsUnderscores) {
15 > return buildReplaceStringForSpecificSpecialCharacter(matches, pattern, '_');
16 > }
17 > if (matches[0].toUpperCase() === matches[0]) {
18 > return pattern.toUpperCase();
19 > } else if (matches[0].toLowerCase() === matches[0]) {
20 return pattern.toLowerCase();
21 > } else if (strings.containsUppercaseCharacter(matches[0][0]) && pattern.length > 0) { search.ts ×6
22 > return pattern[0].toUpperCase() + pattern.substr(1);
23 > } else if (matches[0][0].toUpperCase() !== matches[0][0] && pattern.length > 0) {
24 return pattern[0].toLowerCase() + pattern.substr(1);
25 } else {
26 // we don't understand its pattern yet.
27 return pattern;
28 }
29 > } else { search.ts ×6
30 return pattern;
31 }
32 > } search.ts ×6
34 > function validateSpecificSpecialCharacter(matches: string[], pattern: string, specialCharacter: string): boolean { search.ts ×6
35 > const doesContainSpecialCharacter = matches[0].indexOf(specialCharacter) !== -1 && pattern.indexOf(specialCharacter) !== -1;
36 > return doesContainSpecialCharacter && matches[0].split(specialCharacter).length === pattern.split(specialCharacter).length;
37 > }
39 > function buildReplaceStringForSpecificSpecialCharacter(matches: string[], pattern: string, specialCharacter: string): string { search.ts ×6
40 > const splitPatternAtSpecialCharacter = pattern.split(specialCharacter);
41 > const splitMatchAtSpecialCharacter = matches[0].split(specialCharacter);
42 > let replaceString: string = '';
43 > splitPatternAtSpecialCharacter.forEach((splitValue, index) => {
44 > replaceString += buildReplaceStringWithCasePreserved([splitMatchAtSpecialCharacter[index]], splitValue) + specialCharacter;
45 > });
46 >
47 > return replaceString.slice(0, -1);
48 > }