-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to avoid breaking change; prompt the user instead of pass do…
…wn option; add tests and fixtures
- Loading branch information
1 parent
1711752
commit 552c00c
Showing
7 changed files
with
132 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test_fixtures/functional/after_overlapping_patches_skip/file1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dove 1 | ||
line 2 | ||
line 3 |
3 changes: 3 additions & 0 deletions
3
test_fixtures/functional/after_overlapping_patches_skip/file2.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dove 1 | ||
line 2 | ||
line 3 |
1 change: 1 addition & 0 deletions
1
test_fixtures/functional/after_overlapping_patches_skip/skip.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
skip |
19 changes: 19 additions & 0 deletions
19
test_fixtures/functional/before/codemod_overlapping_patches.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:codemod/codemod.dart'; | ||
import 'package:source_span/source_span.dart'; | ||
|
||
void main(List<String> args) { | ||
exitCode = runInteractiveCodemod(FileQuery.dir(pathFilter: (path) => path.endsWith('.txt')), OverlappingPatchSuggestor(), args: args); | ||
} | ||
|
||
class OverlappingPatchSuggestor implements Suggestor { | ||
@override | ||
bool shouldSkip(String sourceFileContents) => false; | ||
|
||
@override | ||
Iterable<Patch> generatePatches(SourceFile sourceFile) sync* { | ||
yield Patch(sourceFile, sourceFile.span(0, 3), 'dov'); | ||
yield Patch(sourceFile, sourceFile.span(1, 3), 'overlap'); | ||
} | ||
} |