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

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

Issue 2981693002: Start copying resolution/inference data from front end to analyzer ASTs. (Closed)
Patch Set: Address code review comments. 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
Index: pkg/analyzer/lib/src/fasta/resolution_storer.dart
diff --git a/pkg/analyzer/lib/src/fasta/resolution_storer.dart b/pkg/analyzer/lib/src/fasta/resolution_storer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7ea096a3b1f4885ce2d574b1b1e34c59047537ea
--- /dev/null
+++ b/pkg/analyzer/lib/src/fasta/resolution_storer.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart';
+import 'package:kernel/ast.dart';
+
+/// Type inference listener that records inferred types and file offsets for
+/// later use by [ValidatingResolutionApplier].
+class InstrumentedResolutionStorer extends ResolutionStorer {
+ final List<int> _typeOffsets;
+
+ InstrumentedResolutionStorer(List<DartType> types, this._typeOffsets)
+ : super(types);
+
+ @override
+ void genericExpressionExit(
+ String expressionType, Expression expression, DartType inferredType) {
+ assert(_types.length == _typeOffsets.length);
+ this._typeOffsets.add(expression.fileOffset);
+ super.genericExpressionExit(expressionType, expression, inferredType);
+ }
+}
+
+/// Type inference listener that records inferred types for later use by
+/// [ResolutionApplier].
+class ResolutionStorer extends TypeInferenceListener {
+ final List<DartType> _types;
+
+ ResolutionStorer(this._types);
+
+ @override
+ bool genericExpressionEnter(
+ String expressionType, Expression expression, DartType typeContext) {
+ super.genericExpressionEnter(expressionType, expression, typeContext);
+ return true;
+ }
+
+ @override
+ void genericExpressionExit(
+ String expressionType, Expression expression, DartType inferredType) {
+ _types.add(inferredType);
+ super.genericExpressionExit(expressionType, expression, inferredType);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698