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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/optype.dart

Issue 1989393002: Code completion improvement. Recommend all 'E.x' where E is an enum, also, filter out only the cor… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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/completion/dart/optype.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
index 3ddc75dbf2f69eee9a7ec984a1e096db833e4327..3a5608c856cbf96ea93e7c24f9976d170a1eca13 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
@@ -641,6 +641,16 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
optype.includeReturnValueSuggestions = true;
optype.returnValueSuggestionsFilter = (DartType dartType, int relevance) {
DartType type = node.element?.type;
+ bool isEnum = type != null &&
+ type.element is ClassElement &&
+ (type.element as ClassElement).isEnum;
+ if (isEnum) {
+ if (type == dartType) {
+ return relevance + DART_RELEVANCE_INCREMENT;
+ } else {
+ return null;
+ }
+ }
if (type != null &&
dartType != null &&
!type.isDynamic &&

Powered by Google App Engine
This is Rietveld 408576698