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

Unified Diff: pkg/analyzer/lib/src/fasta/resolution_applier.dart

Issue 2987503003: Further integration of front end type inference into analyzer. (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « pkg/analyzer/lib/src/fasta/ast_builder.dart ('k') | pkg/analyzer/lib/src/fasta/resolution_storer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/fasta/resolution_applier.dart
diff --git a/pkg/analyzer/lib/src/fasta/resolution_applier.dart b/pkg/analyzer/lib/src/fasta/resolution_applier.dart
index 9abe09d6866ae0293483cb184b3ec781b0ab08cc..1f273c11c37fe637485b22a9e4efae748d8b50d9 100644
--- a/pkg/analyzer/lib/src/fasta/resolution_applier.dart
+++ b/pkg/analyzer/lib/src/fasta/resolution_applier.dart
@@ -39,18 +39,33 @@ class ResolutionApplier extends GeneralizingAstVisitor {
@override
void visitVariableDeclarationList(VariableDeclarationList node) {
- if (node.variables.length != 1) {
- // TODO(paulberry): handle this case
- throw new UnimplementedError('Multiple variables in one declaration');
+ if (node.parent is TopLevelVariableDeclaration) {
+ node.variables.accept(this);
+ } else {
+ if (node.variables.length != 1) {
+ // TODO(paulberry): handle this case
+ throw new UnimplementedError('Multiple variables in one declaration');
+ }
+ if (node.metadata.isNotEmpty) {
+ // TODO(paulberry): handle this case
+ throw new UnimplementedError('Metadata on a variable declaration list');
+ }
+ node.variables.accept(this);
+ if (node.type != null) {
+ _applyToTypeAnnotation(node.variables[0].name.staticType, node.type);
+ }
}
- if (node.metadata.isNotEmpty) {
- // TODO(paulberry): handle this case
- throw new UnimplementedError('Metadata on a variable declaration list');
- }
- node.variables.accept(this);
- if (node.type != null) {
- _applyToTypeAnnotation(node.variables[0].name.staticType, node.type);
+ }
+
+ @override
+ void visitVariableDeclaration(VariableDeclaration node) {
+ if (node.parent is VariableDeclarationList &&
+ node.parent.parent is TopLevelVariableDeclaration) {
+ // Don't visit the name; resolution for it will come from the outline.
+ } else {
+ node.name.accept(this);
}
+ node.initializer?.accept(this);
}
void _applyToTypeAnnotation(DartType type, TypeAnnotation typeAnnotation) {
@@ -87,8 +102,8 @@ class ValidatingResolutionApplier extends ResolutionApplier {
if (_debug) print('Getting type for $node');
if (node.offset != _typeOffsets[_typeIndex]) {
throw new StateError(
- 'Expected a type for offset ${node.offset}; got one for '
- '${_typeOffsets[_typeIndex]}');
+ 'Expected a type for analyzer offset ${node.offset}; got one for '
+ 'kernel offset ${_typeOffsets[_typeIndex]}');
}
return super._getTypeFor(node);
}
« no previous file with comments | « pkg/analyzer/lib/src/fasta/ast_builder.dart ('k') | pkg/analyzer/lib/src/fasta/resolution_storer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698