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

Unified Diff: pkg/analyzer/lib/src/kernel/resynthesize.dart

Issue 3002633002: Resynthesize assert constructor initializers and parameter references. (Closed)
Patch Set: Created 3 years, 4 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 | « no previous file | pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/kernel/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/kernel/resynthesize.dart b/pkg/analyzer/lib/src/kernel/resynthesize.dart
index 189128029e9e84c8a167dd0e7564dde886a42130..3d1c8753d3c6c931a6d2357852b83c997e512f46 100644
--- a/pkg/analyzer/lib/src/kernel/resynthesize.dart
+++ b/pkg/analyzer/lib/src/kernel/resynthesize.dart
@@ -229,6 +229,19 @@ class _ExprBuilder {
return AstTestFactory.propertyAccess(target, identifier);
}
+ if (expr is kernel.VariableGet) {
+ String name = expr.variable.name;
+ Element contextConstructor = _contextElement;
+ if (contextConstructor is ConstructorElement) {
+ SimpleIdentifier identifier = AstTestFactory.identifier3(name);
+ ParameterElement parameter = contextConstructor.parameters.firstWhere(
+ (parameter) => parameter.name == name,
+ orElse: () => null);
+ identifier.staticElement = parameter;
+ return identifier;
+ }
+ }
+
if (expr is kernel.ConditionalExpression) {
var condition = build(expr.condition);
var then = build(expr.then);
@@ -321,6 +334,23 @@ class _ExprBuilder {
return initializer;
}
+ if (k is kernel.LocalInitializer) {
+ var invocation = k.variable.initializer;
+ if (invocation is kernel.MethodInvocation) {
+ var receiver = invocation.receiver;
+ if (receiver is kernel.FunctionExpression &&
+ invocation.name.name == 'call') {
+ var body = receiver.function.body;
+ if (body is kernel.AssertStatement) {
+ var condition = build(body.condition);
+ var message = body.message != null ? build(body.message) : null;
+ return AstTestFactory.assertInitializer(condition, message);
+ }
+ }
+ }
+ return null;
Paul Berry 2017/08/15 16:54:39 Do we ever expect to reach this? Does the caller
scheglov 2017/08/23 17:06:27 Done.
+ }
+
if (k is kernel.RedirectingInitializer) {
ConstructorElementImpl redirect = _getElement(k.targetReference);
var arguments = _toArguments(k.arguments);
@@ -654,8 +684,7 @@ class _KernelUnitResynthesizerContextImpl
@override
ConstructorInitializer getConstructorInitializer(
ConstructorElementImpl constructor, kernel.Initializer k) {
- if (k is kernel.LocalInitializer ||
- k is kernel.FieldInitializer && k.isSynthetic ||
+ if (k is kernel.FieldInitializer && k.isSynthetic ||
k is kernel.SuperInitializer && k.isSynthetic) {
return null;
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698