Skip to content

Commit 46505e8

Browse files
committed
Polish
1 parent 092a169 commit 46505e8

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

spring-shell-core/src/main/java/org/springframework/shell/component/PathSearch.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private void updateSelectorList(String path, PathSearchContext context) {
235235
if (!StringUtils.hasText(text)) {
236236
text = ".";
237237
}
238-
PartsText partsText = PathSearchContext.ofNameMatchPartsx(text, positions);
238+
PartsText partsText = PathSearchContext.ofPositions(text, positions);
239239
PathViewItem item = new PathViewItem(scoredPath.getPath(), partsText, false);
240240
return item;
241241
})
@@ -438,13 +438,13 @@ public PartsText getPartsText() {
438438
* @param positions the positions array, expected to be ordered and no duplicates
439439
* @return parts text
440440
*/
441-
public static PartsText ofNameMatchPartsx(String text, int[] positions) {
441+
public static PartsText ofPositions(String text, int[] positions) {
442442
List<PartText> parts = new ArrayList<>();
443443
if (positions.length == 0) {
444-
parts.addAll(nameMatchPartsx(text, -1));
444+
parts.addAll(ofPosition(text, -1));
445445
}
446446
else if (positions.length == 1 && positions[0] == text.length()) {
447-
parts.addAll(nameMatchPartsx(text, text.length() - 1));
447+
parts.addAll(ofPosition(text, text.length() - 1));
448448
}
449449
else {
450450
int sidx = 0;
@@ -453,22 +453,22 @@ else if (positions.length == 1 && positions[0] == text.length()) {
453453
eidx = positions[i];
454454
if (sidx < text.length()) {
455455
String partText = text.substring(sidx, eidx + 1);
456-
parts.addAll(nameMatchPartsx(partText, eidx - sidx));
456+
parts.addAll(ofPosition(partText, eidx - sidx));
457457
}
458458
else {
459-
parts.addAll(nameMatchPartsx(String.valueOf(text.charAt(text.length() - 1)), 0));
459+
parts.addAll(ofPosition(String.valueOf(text.charAt(text.length() - 1)), 0));
460460
}
461461
sidx = eidx + 1;
462462
}
463463
if (sidx < text.length()) {
464464
String partText = text.substring(sidx, text.length());
465-
parts.addAll(nameMatchPartsx(partText, -1));
465+
parts.addAll(ofPosition(partText, -1));
466466
}
467467
}
468468
return PartsText.of(parts);
469469
}
470470

471-
static List<PartText> nameMatchPartsx(String text, int position) {
471+
static List<PartText> ofPosition(String text, int position) {
472472
List<PartText> parts = new ArrayList<>();
473473
if (position < 0) {
474474
parts.add(PartText.of(text, false));

spring-shell-core/src/test/java/org/springframework/shell/component/PathSearchTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
public class PathSearchTests {
3333

34-
static Stream<Arguments> testOfNameMatchParts() {
34+
static Stream<Arguments> testParts() {
3535
return Stream.of(
3636
Arguments.of("0", new int[] { 0 },
3737
Arrays.asList(PartText.of("0", true))),
@@ -95,9 +95,9 @@ static Stream<Arguments> testOfNameMatchParts() {
9595

9696
@ParameterizedTest
9797
@MethodSource
98-
void testOfNameMatchParts(String text, int[] positions, List<PartText> parts) {
99-
PartsText ofNameMatchPartsx = PathSearchContext.ofNameMatchPartsx(text, positions);
100-
List<PartText> res = ofNameMatchPartsx.getParts();
98+
void testParts(String text, int[] positions, List<PartText> parts) {
99+
PartsText partsText = PathSearchContext.ofPositions(text, positions);
100+
List<PartText> res = partsText.getParts();
101101
assertThat(res).hasSize(parts.size());
102102
for (int i = 0; i < parts.size(); i++) {
103103
assertThat(res.get(i).getText()).isEqualTo(parts.get(i).getText());

0 commit comments

Comments
 (0)