File tree Expand file tree Collapse file tree 4 files changed +23
-17
lines changed
core-codemods/src/main/java/io/codemodder/codemods Expand file tree Collapse file tree 4 files changed +23
-17
lines changed Original file line number Diff line number Diff line change @@ -47,11 +47,13 @@ private Optional<CodemodChange> onNodeFound(
4747 }
4848
4949 @ Override
50- public List < CodemodChange > visit (
50+ public CodemodFileScanningResult visit (
5151 final CodemodInvocationContext context , final CompilationUnit cu ) {
52- return cu .findAll (MethodCallExpr .class ).stream ()
53- .flatMap (mce -> onNodeFound (context , mce , cu ).stream ())
54- .collect (Collectors .toList ());
52+ List <CodemodChange > changes =
53+ cu .findAll (MethodCallExpr .class ).stream ()
54+ .flatMap (mce -> onNodeFound (context , mce , cu ).stream ())
55+ .collect (Collectors .toList ());
56+ return CodemodFileScanningResult .withOnlyChanges (changes );
5557 }
5658
5759 private static final String queryParameterNamePrefix = ":parameter" ;
Original file line number Diff line number Diff line change @@ -32,10 +32,12 @@ private Optional<CodemodChange> onNodeFound(final MethodCallExpr methodCallExpr)
3232 }
3333
3434 @ Override
35- public List < CodemodChange > visit (
35+ public CodemodFileScanningResult visit (
3636 final CodemodInvocationContext context , final CompilationUnit cu ) {
37- return cu .findAll (MethodCallExpr .class ).stream ()
38- .flatMap (mce -> onNodeFound (mce ).stream ())
39- .collect (Collectors .toList ());
37+ List <CodemodChange > changes =
38+ cu .findAll (MethodCallExpr .class ).stream ()
39+ .flatMap (mce -> onNodeFound (mce ).stream ())
40+ .collect (Collectors .toList ());
41+ return CodemodFileScanningResult .withOnlyChanges (changes );
4042 }
4143}
Original file line number Diff line number Diff line change 88import java .nio .file .Path ;
99import java .time .Duration ;
1010import java .util .ArrayList ;
11- import java .util .Collections ;
1211import java .util .List ;
1312import java .util .regex .Matcher ;
1413import java .util .regex .Pattern ;
@@ -48,12 +47,13 @@ public SpringAbsoluteCookieTimeoutCodemod(
4847 }
4948
5049 @ Override
51- public List <CodemodChange > visitFile (final CodemodInvocationContext context ) throws IOException {
50+ public CodemodFileScanningResult visitFile (final CodemodInvocationContext context )
51+ throws IOException {
5252 Path path = context .path ();
5353 if (!"application.properties" .equalsIgnoreCase (path .getFileName ().toString ())) {
54- return List . of ();
54+ return CodemodFileScanningResult . none ();
5555 } else if (!inExpectedDir (context .codeDirectory ().asPath ().relativize (path ))) {
56- return List . of ();
56+ return CodemodFileScanningResult . none ();
5757 }
5858
5959 List <CodemodChange > changes = new ArrayList <>();
@@ -93,9 +93,9 @@ public List<CodemodChange> visitFile(final CodemodInvocationContext context) thr
9393
9494 if (!changes .isEmpty ()) {
9595 Files .write (path , lines );
96- return Collections . unmodifiableList (changes );
96+ return CodemodFileScanningResult . withOnlyChanges (changes );
9797 }
98- return List . of ();
98+ return CodemodFileScanningResult . none ();
9999 }
100100
101101 private boolean inExpectedDir (final Path relativePath ) {
Original file line number Diff line number Diff line change @@ -34,13 +34,15 @@ public VerbTamperingCodemod(final XPathStreamProcessor processor) {
3434 }
3535
3636 @ Override
37- public List <CodemodChange > visitFile (final CodemodInvocationContext context ) throws IOException {
37+ public CodemodFileScanningResult visitFile (final CodemodInvocationContext context )
38+ throws IOException {
3839 Path file = context .path ();
3940 if (!"web.xml" .equalsIgnoreCase (file .getFileName ().toString ())) {
40- return List . of ();
41+ return CodemodFileScanningResult . none ();
4142 }
4243 try {
43- return processWebXml (context , file );
44+ List <CodemodChange > changes = processWebXml (context , file );
45+ return CodemodFileScanningResult .withOnlyChanges (changes );
4446 } catch (SAXException | DocumentException | XMLStreamException e ) {
4547 throw new IOException ("Problem transforming web.xml" , e );
4648 }
You can’t perform that action at this time.
0 commit comments