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

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

Issue 2875323002: Remove unintentional dependency on analysis_server (Closed)
Patch Set: Created 3 years, 7 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 1c38cbf60fafd6ed3d3bfe81bb7faa353ff8b2a4..f7fb39e7652ac7cc2566ee79e6f919a816d55f6e 100644
--- a/pkg/analysis_server/lib/src/services/correction/strings.dart
+++ b/pkg/analysis_server/lib/src/services/correction/strings.dart
@@ -2,10 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library services.src.correction.strings;
-
import 'dart:math';
+import 'package:analyzer_plugin/src/utilities/string_utilities.dart';
+
/**
* "$"
*/
@@ -159,46 +159,6 @@ int findCommonSuffix(String a, String b) {
}
/**
- * Returns a list of words for the given camel case string.
- *
- * 'getCamelWords' => ['get', 'Camel', 'Words']
- * 'getHTMLText' => ['get', 'HTML', 'Text']
- */
-List<String> getCamelWords(String str) {
- if (str == null || str.isEmpty) {
- return <String>[];
- }
- List<String> parts = <String>[];
- bool wasLowerCase = false;
- bool wasUpperCase = false;
- int wordStart = 0;
- for (int i = 0; i < str.length; i++) {
- int c = str.codeUnitAt(i);
- var newLowerCase = isLowerCase(c);
- var newUpperCase = isUpperCase(c);
- // myWord
- // | ^
- if (wasLowerCase && newUpperCase) {
- parts.add(str.substring(wordStart, i));
- wordStart = i;
- }
- // myHTMLText
- // | ^
- if (wasUpperCase &&
- newUpperCase &&
- i + 1 < str.length &&
- isLowerCase(str.codeUnitAt(i + 1))) {
- parts.add(str.substring(wordStart, i));
- wordStart = i;
- }
- wasLowerCase = newLowerCase;
- wasUpperCase = newUpperCase;
- }
- parts.add(str.substring(wordStart));
- return parts;
-}
-
-/**
* Checks if [str] is `null`, empty or is whitespace.
*/
bool isBlank(String str) {
@@ -215,10 +175,6 @@ bool isDigit(int c) {
return c >= 0x30 && c <= 0x39;
}
-bool isEmpty(String str) {
- return str == null || str.isEmpty;
-}
-
bool isEOL(int c) {
return c == 0x0D || c == 0x0A;
}
@@ -231,16 +187,8 @@ bool isLetterOrDigit(int c) {
return isLetter(c) || isDigit(c);
}
-bool isLowerCase(int c) {
- return c >= 0x61 && c <= 0x7A;
-}
-
bool isSpace(int c) => c == 0x20 || c == 0x09;
-bool isUpperCase(int c) {
- return c >= 0x41 && c <= 0x5A;
-}
-
bool isWhitespace(int c) {
return isSpace(c) || isEOL(c);
}
@@ -262,16 +210,6 @@ String removeEnd(String str, String remove) {
return str;
}
-String removeStart(String str, String remove) {
- if (isEmpty(str) || isEmpty(remove)) {
- return str;
- }
- if (str.startsWith(remove)) {
- return str.substring(remove.length);
- }
- 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