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

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

Issue 1431673003: Compute covering offsets/lengths. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/correction/util.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c2ea6cbcb49b5395005f10e9132241192df26b74..1689c7c5727e95c537ada39923431340529f342e 100644
--- a/pkg/analysis_server/lib/src/services/correction/strings.dart
+++ b/pkg/analysis_server/lib/src/services/correction/strings.dart
@@ -41,6 +41,17 @@ int compareStrings(String a, String b) {
return a.compareTo(b);
}
+int countLeadingWhitespaces(String str) {
+ int i = 0;
+ for (; i < str.length; i++) {
+ int c = str.codeUnitAt(i);
+ if (!isWhitespace(c)) {
+ break;
+ }
+ }
+ return i;
+}
+
/**
* Counts how many times [sub] appears in [str].
*/
@@ -57,6 +68,17 @@ int countMatches(String str, String sub) {
return count;
}
+int countTrailingWhitespaces(String str) {
+ int i = 0;
+ for (; i < str.length; i++) {
+ int c = str.codeUnitAt(str.length - 1 - i);
+ if (!isWhitespace(c)) {
+ break;
+ }
+ }
+ return i;
+}
+
/**
* Returns the number of characters common to the end of [a] and the start
* of [b].
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/correction/util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698