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

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

Issue 1916893002: Code completion progress part two of fix to https://github.com/dart-lang/sdk/issues/24254, addition… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge with bleeding_edge Created 4 years, 8 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/name_suggestion.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/name_suggestion.dart b/pkg/analysis_server/lib/src/services/correction/name_suggestion.dart
index c28dae5519f95b8ca3387ee32a066c495e09afaa..12d8c2950a6c619afc0b74602111887abc63c7b4 100644
--- a/pkg/analysis_server/lib/src/services/correction/name_suggestion.dart
+++ b/pkg/analysis_server/lib/src/services/correction/name_suggestion.dart
@@ -12,6 +12,21 @@ import 'package:analyzer/dart/element/type.dart';
List<String> _KNOWN_METHOD_NAME_PREFIXES = ['get', 'is', 'to'];
/**
+ * Returns all variants of names by removing leading words one by one.
+ */
+List<String> getCamelWordCombinations(String name) {
+ List<String> result = [];
+ List<String> parts = getCamelWords(name);
+ for (int i = 0; i < parts.length; i++) {
+ var s1 = parts[i].toLowerCase();
+ var s2 = parts.skip(i + 1).join();
+ String suggestion = '$s1$s2';
+ result.add(suggestion);
+ }
+ return result;
+}
+
+/**
* Returns possible names for a variable with the given expected type and
* expression assigned.
*/
@@ -23,12 +38,12 @@ List<String> getVariableNameSuggestionsForExpression(DartType expectedType,
String nameFromExpression = _getBaseNameFromExpression(assignedExpression);
if (nameFromExpression != null) {
nameFromExpression = removeStart(nameFromExpression, '_');
- _addAll(excluded, res, _getCamelWordCombinations(nameFromExpression));
+ _addAll(excluded, res, getCamelWordCombinations(nameFromExpression));
}
String nameFromParent =
_getBaseNameFromLocationInParent(assignedExpression);
if (nameFromParent != null) {
- _addAll(excluded, res, _getCamelWordCombinations(nameFromParent));
+ _addAll(excluded, res, getCamelWordCombinations(nameFromParent));
}
}
// use type
@@ -41,7 +56,7 @@ List<String> getVariableNameSuggestionsForExpression(DartType expectedType,
} else if ('String' == typeName) {
_addSingleCharacterName(excluded, res, 0x73);
} else {
- _addAll(excluded, res, _getCamelWordCombinations(typeName));
+ _addAll(excluded, res, getCamelWordCombinations(typeName));
}
res.remove(typeName);
}
@@ -80,7 +95,7 @@ List<String> getVariableNameSuggestionsForText(
}
// split camel-case into separate suggested names
Set<String> res = new Set();
- _addAll(excluded, res, _getCamelWordCombinations(text));
+ _addAll(excluded, res, getCamelWordCombinations(text));
return new List.from(res);
}
@@ -200,18 +215,3 @@ String _getBaseNameFromLocationInParent(Expression expression) {
// unknown
return null;
}
-
-/**
- * Returns all variants of names by removing leading words one by one.
- */
-List<String> _getCamelWordCombinations(String name) {
- List<String> result = [];
- List<String> parts = getCamelWords(name);
- for (int i = 0; i < parts.length; i++) {
- var s1 = parts[i].toLowerCase();
- var s2 = parts.skip(i + 1).join();
- String suggestion = '$s1$s2';
- result.add(suggestion);
- }
- return result;
-}

Powered by Google App Engine
This is Rietveld 408576698