| Index: pkg/analysis_server/lib/src/services/correction/strings.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/correction/strings.dart b/pkg/analysis_server/lib/src/services/correction/strings.dart
|
| index a72b6f6837bc3dbdd5e47bb23bfb4df03b3e3c6c..ff5c49584d492648e089a36aee3fed70f2c61572 100644
|
| --- a/pkg/analysis_server/lib/src/services/correction/strings.dart
|
| +++ b/pkg/analysis_server/lib/src/services/correction/strings.dart
|
| @@ -42,6 +42,22 @@ int compareStrings(String a, String b) {
|
| }
|
|
|
| /**
|
| + * Counts how many times [sub] appears in [str].
|
| + */
|
| +int countMatches(String str, String sub) {
|
| + if (isEmpty(str) || isEmpty(sub)) {
|
| + return 0;
|
| + }
|
| + int count = 0;
|
| + int idx = 0;
|
| + while ((idx = str.indexOf(sub, idx)) != -1) {
|
| + count++;
|
| + idx += sub.length;
|
| + }
|
| + return count;
|
| +}
|
| +
|
| +/**
|
| * Checks if [str] is `null`, empty or is whitespace.
|
| */
|
| bool isBlank(String str) {
|
| @@ -101,6 +117,7 @@ String removeStart(String str, String remove) {
|
| return str;
|
| }
|
|
|
| +
|
| String repeat(String s, int n) {
|
| StringBuffer sb = new StringBuffer();
|
| for (int i = 0; i < n; i++) {
|
|
|