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

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

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Address review comments Created 4 years 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 132c8235799d3a2aaba80375d8be4d4030f90615..0591ae2c28679e1453025b223c5c99d5bf8acb9e 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
@@ -8,6 +8,7 @@ import 'package:analysis_server/src/protocol_server.dart' hide Element;
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
import 'package:analysis_server/src/provisional/completion/dart/completion_target.dart';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -567,7 +568,9 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
if (node.parent is VariableDeclaration) {
VariableDeclaration varDeclaration =
node.parent as VariableDeclaration;
- localTypeAssertion = varDeclaration.element?.type;
+ localTypeAssertion = resolutionMap
+ .elementDeclaredByVariableDeclaration(varDeclaration)
+ ?.type;
} else if (node.parent is AssignmentExpression) {
AssignmentExpression assignmentExpression =
node.parent as AssignmentExpression;
@@ -653,7 +656,7 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
if (identical(entity, node.expression)) {
optype.includeReturnValueSuggestions = true;
optype.returnValueSuggestionsFilter = (DartType dartType, int relevance) {
- DartType type = node.element?.type;
+ DartType type = resolutionMap.elementForNamedExpression(node)?.type;
bool isEnum = type != null &&
type.element is ClassElement &&
(type.element as ClassElement).isEnum;

Powered by Google App Engine
This is Rietveld 408576698