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

Side by Side Diff: pkg/analyzer/lib/src/fasta/resolution_storer.dart

Issue 2980053002: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart' ; 5 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart' ;
6 import 'package:kernel/ast.dart'; 6 import 'package:kernel/ast.dart';
7 7
8 /// Type inference listener that records inferred types and file offsets for 8 /// Type inference listener that records inferred types and file offsets for
9 /// later use by [ValidatingResolutionApplier]. 9 /// later use by [ValidatingResolutionApplier].
10 class InstrumentedResolutionStorer extends ResolutionStorer { 10 class InstrumentedResolutionStorer extends ResolutionStorer {
11 final List<int> _typeOffsets; 11 final List<int> _typeOffsets;
12 12
13 InstrumentedResolutionStorer(List<DartType> types, this._typeOffsets) 13 InstrumentedResolutionStorer(List<DartType> types, this._typeOffsets)
14 : super(types); 14 : super(types);
15 15
16 @override 16 @override
17 void genericExpressionExit( 17 void _recordType(DartType type, int offset) {
18 String expressionType, Expression expression, DartType inferredType) {
19 assert(_types.length == _typeOffsets.length); 18 assert(_types.length == _typeOffsets.length);
20 this._typeOffsets.add(expression.fileOffset); 19 _typeOffsets.add(offset);
21 super.genericExpressionExit(expressionType, expression, inferredType); 20 super._recordType(type, offset);
22 } 21 }
23 } 22 }
24 23
25 /// Type inference listener that records inferred types for later use by 24 /// Type inference listener that records inferred types for later use by
26 /// [ResolutionApplier]. 25 /// [ResolutionApplier].
27 class ResolutionStorer extends TypeInferenceListener { 26 class ResolutionStorer extends TypeInferenceListener {
28 final List<DartType> _types; 27 final List<DartType> _types;
29 28
30 ResolutionStorer(this._types); 29 ResolutionStorer(this._types);
31 30
32 @override 31 @override
33 bool genericExpressionEnter( 32 bool genericExpressionEnter(
34 String expressionType, Expression expression, DartType typeContext) { 33 String expressionType, Expression expression, DartType typeContext) {
35 super.genericExpressionEnter(expressionType, expression, typeContext); 34 super.genericExpressionEnter(expressionType, expression, typeContext);
36 return true; 35 return true;
37 } 36 }
38 37
39 @override 38 @override
40 void genericExpressionExit( 39 void genericExpressionExit(
41 String expressionType, Expression expression, DartType inferredType) { 40 String expressionType, Expression expression, DartType inferredType) {
42 _types.add(inferredType); 41 _recordType(inferredType, expression.fileOffset);
43 super.genericExpressionExit(expressionType, expression, inferredType); 42 super.genericExpressionExit(expressionType, expression, inferredType);
44 } 43 }
44
45 @override
46 void variableDeclarationEnter(VariableDeclaration statement) {
47 _recordType(statement.type, statement.fileOffset);
48 super.variableDeclarationEnter(statement);
49 }
50
51 void _recordType(DartType type, int offset) {
52 _types.add(type);
53 }
45 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698