| 1 | package org.egothor.methodatlas.command; | |
| 2 | ||
| 3 | import java.nio.file.Path; | |
| 4 | ||
| 5 | /** | |
| 6 | * Path helpers for reporting source locations relative to the scan root. | |
| 7 | */ | |
| 8 | /* default */ final class SourcePaths { | |
| 9 | ||
| 10 | private SourcePaths() { | |
| 11 | } | |
| 12 | ||
| 13 | /** | |
| 14 | * Derives the forward-slash path of {@code file} relative to the scan {@code root}. | |
| 15 | * | |
| 16 | * @param root scan root; must not be {@code null} | |
| 17 | * @param file source file of a discovered method; may be {@code null} | |
| 18 | * @return root-relative path with {@code /} separators, or {@code null} when {@code file} | |
| 19 | * is {@code null} or lies outside {@code root} (callers then fall back to a | |
| 20 | * synthesised path) | |
| 21 | */ | |
| 22 | /* default */ static String relativeSourcePath(Path root, Path file) { | |
| 23 |
2
1. relativeSourcePath : removed conditional - replaced equality check with true → KILLED 2. relativeSourcePath : removed conditional - replaced equality check with false → KILLED |
if (file == null) { |
| 24 |
1
1. relativeSourcePath : replaced return value with "" for org/egothor/methodatlas/command/SourcePaths::relativeSourcePath → KILLED |
return null; |
| 25 | } | |
| 26 | try { | |
| 27 | Path rel = root.toAbsolutePath().normalize().relativize(file.toAbsolutePath().normalize()); | |
| 28 |
2
1. relativeSourcePath : removed conditional - replaced equality check with false → KILLED 2. relativeSourcePath : removed conditional - replaced equality check with true → KILLED |
if (rel.startsWith("..")) { |
| 29 |
1
1. relativeSourcePath : replaced return value with "" for org/egothor/methodatlas/command/SourcePaths::relativeSourcePath → KILLED |
return null; |
| 30 | } | |
| 31 |
1
1. relativeSourcePath : replaced return value with "" for org/egothor/methodatlas/command/SourcePaths::relativeSourcePath → KILLED |
return rel.toString().replace('\\', '/'); |
| 32 | } catch (IllegalArgumentException e) { | |
| 33 | // Different drive/root on Windows: not relativisable. | |
| 34 |
1
1. relativeSourcePath : replaced return value with "" for org/egothor/methodatlas/command/SourcePaths::relativeSourcePath → NO_COVERAGE |
return null; |
| 35 | } | |
| 36 | } | |
| 37 | } | |
Mutations | ||
| 23 |
1.1 2.2 |
|
| 24 |
1.1 |
|
| 28 |
1.1 2.2 |
|
| 29 |
1.1 |
|
| 31 |
1.1 |
|
| 34 |
1.1 |