Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: pkg/analysis_server/lib/src/services/correction/strings.dart

Issue 489973002: Initial 'Extract Local' implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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++) {

Powered by Google App Engine
This is Rietveld 408576698