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 3c097f155cafdb8fbb9fd4d3dcd60ca1dac8c2b7..aa383c06054bf0ad74bfef5ab5ba8576d2d79eee 100644 |
--- a/pkg/analyzer/lib/src/kernel/resynthesize.dart |
+++ b/pkg/analyzer/lib/src/kernel/resynthesize.dart |
@@ -384,6 +384,73 @@ class _KernelLibraryResynthesizerContextImpl |
_KernelLibraryResynthesizerContextImpl(this._resynthesizer, this.library); |
@override |
+ UnitExplicitTopLevelAccessors buildTopLevelAccessors( |
+ CompilationUnitElementImpl unit) { |
+ var accessorsData = new UnitExplicitTopLevelAccessors(); |
+ var implicitVariables = <String, TopLevelVariableElementImpl>{}; |
+ // Build explicit property accessors and implicit fields. |
+ for (var k in library.procedures) { |
Brian Wilkerson
2017/07/26 18:17:11
"k" --> "procedure"? ("k" seems like a strange nam
|
+ bool isGetter = k.kind == kernel.ProcedureKind.Getter; |
+ bool isSetter = k.kind == kernel.ProcedureKind.Setter; |
+ if (isGetter || isSetter) { |
+ var accessor = new PropertyAccessorElementImpl.forKernel(unit, k); |
+ accessorsData.accessors.add(accessor); |
+ |
+ // Create or update the implicit variable. |
+ String name = accessor.displayName; |
+ TopLevelVariableElementImpl variable = implicitVariables[name]; |
+ if (variable == null) { |
+ variable = new TopLevelVariableElementImpl(name, -1); |
+ implicitVariables[name] = variable; |
+ variable.enclosingElement = unit; |
+ variable.isSynthetic = true; |
+ variable.isFinal = isGetter; |
+ } else { |
+ variable.isFinal = false; |
+ } |
+ |
+ // Attach the accessor to the variable. |
+ accessor.variable = variable; |
+ if (isGetter) { |
+ variable.getter = accessor; |
+ } else { |
+ variable.setter = accessor; |
+ } |
+ } |
+ } |
+ accessorsData.implicitVariables.addAll(implicitVariables.values); |
+ return accessorsData; |
+ } |
+ |
+ @override |
+ UnitExplicitTopLevelVariables buildTopLevelVariables( |
+ CompilationUnitElementImpl unit) { |
+ int numberOfVariables = library.fields.length; |
+ var variablesData = new UnitExplicitTopLevelVariables(numberOfVariables); |
+ for (int i = 0; i < numberOfVariables; i++) { |
+ kernel.Field kField = library.fields[i]; |
Brian Wilkerson
2017/07/26 18:17:11
"kField" --> "field"?
|
+ |
+ // Add the explicit variables. |
+ TopLevelVariableElementImpl variable; |
+ if (kField.isConst && kField.initializer != null) { |
+ variable = new ConstTopLevelVariableElementImpl.forKernel(unit, kField); |
+ } else { |
+ variable = new TopLevelVariableElementImpl.forKernel(unit, kField); |
+ } |
+ variablesData.variables[i] = variable; |
+ |
+ // Add the implicit accessors. |
+ variablesData.implicitAccessors |
+ .add(new PropertyAccessorElementImpl_ImplicitGetter(variable)); |
+ if (!(variable.isConst || variable.isFinal)) { |
+ variablesData.implicitAccessors |
+ .add(new PropertyAccessorElementImpl_ImplicitSetter(variable)); |
+ } |
+ } |
+ return variablesData; |
+ } |
+ |
+ @override |
ConstructorInitializer getConstructorInitializer( |
ConstructorElementImpl constructor, kernel.Initializer k) { |
if (k is kernel.LocalInitializer || |