Skip to content

Commit d444088

Browse files
authored
Codetf output for pom files now consider target lines instead of source (#454)
\close #work
1 parent 6b7e74c commit d444088

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

plugins/codemodder-plugin-maven/src/main/java/io/codemodder/plugins/maven/DefaultArtifactInjectionPositionFinder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ public int find(final List<AbstractDelta<String>> deltas, final String artifactI
1818
if (hasArtifactId && hasVersion) {
1919
// if it has the artifact and version, it could be the <dependencyManagement> section, which
2020
// is 2nd preference
21-
backupPosition = 1 + delta.getSource().getPosition();
21+
backupPosition = 1 + delta.getTarget().getPosition();
2222
} else if (hasArtifactId) {
2323
// if it has the artifact but not the version, it could be the <dependencies> section, which
2424
// is preferred
25-
return 1 + delta.getSource().getPosition();
25+
return 1 + delta.getTarget().getPosition();
2626
}
2727
}
2828
if (backupPosition != null) {
2929
return backupPosition;
3030
}
3131
// the fallback is to just use the first change to the file
32-
return 1 + deltas.get(0).getSource().getPosition();
32+
return 1 + deltas.get(0).getTarget().getPosition();
3333
}
3434
}

plugins/codemodder-plugin-maven/src/test/java/io/codemodder/plugins/maven/MavenProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ private static Stream<Arguments> expectedChangeDescriptionLocations() {
172172
Arguments.of(simplePom, 7), // injects all new text in one delta
173173
Arguments.of(
174174
simplePomWithExistingSections,
175-
16), // already has both sections, record at dependencies section
175+
17), // already has both sections, record at dependencies section
176176
Arguments.of(
177177
webgoatPomThatJustNeedsUpgrades,
178178
151), // just updating the version number here in the properties
179-
Arguments.of(webgoatPom, 413) // add to the end of the dependencies section
179+
Arguments.of(webgoatPom, 419) // add to the end of the dependencies section
180180
);
181181
}
182182

0 commit comments

Comments
 (0)