| 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 80b98d8b6e59efb751377834662814a6464c27b3..991ca5f3098e38ed3c4bead367b8f2b2b1346120 100644
|
| --- a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
|
| +++ b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
|
| @@ -504,8 +504,7 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
|
| if (_isEntityPrevTokenSynthetic()) {
|
| // Actual: if (var v i^)
|
| // Parsed: if (v) i^;
|
| - } else if (identical(
|
| - entity, node.condition)) {
|
| + } else if (identical(entity, node.condition)) {
|
| optype.includeReturnValueSuggestions = true;
|
| optype.includeTypeNameSuggestions = true;
|
| } else if (identical(entity, node.thenStatement) ||
|
| @@ -622,6 +621,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 &&
|
| @@ -848,8 +857,7 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
|
|
|
| bool _isEntityPrevTokenSynthetic() {
|
| Object entity = this.entity;
|
| - if (entity is AstNode && entity.beginToken.previous?.isSynthetic ??
|
| - false) {
|
| + if (entity is AstNode && entity.beginToken.previous?.isSynthetic ?? false) {
|
| return true;
|
| }
|
| return false;
|
|
|