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

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

Issue 2992083002: Resynthesize typedefs from Kernel. (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
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 78aebc6d0fe4aa3cb8d69a7e17c5cf11c38e340c..95783ddaf55da4e4ec286df0d5f82ed0b9c2efb4 100644
--- a/pkg/analyzer/lib/src/kernel/resynthesize.dart
+++ b/pkg/analyzer/lib/src/kernel/resynthesize.dart
@@ -483,6 +483,27 @@ class _KernelLibraryResynthesizerContextImpl
}
@override
+ List<List<kernel.VariableDeclaration>> getFunctionTypeParameters(
+ kernel.FunctionType type) {
+ int positionalCount = type.positionalParameters.length;
+ var positionalParameters =
+ new List<kernel.VariableDeclaration>(positionalCount);
+ for (int i = 0; i < positionalCount; i++) {
+ String name = i < type.positionalParameterNames.length
+ ? type.positionalParameterNames[i]
+ : 'arg_$i';
+ positionalParameters[i] = new kernel.VariableDeclaration(name,
+ type: type.positionalParameters[i]);
+ }
+
+ var namedParameters = type.namedParameters
+ .map((k) => new kernel.VariableDeclaration(k.name, type: k.type))
+ .toList(growable: false);
+
+ return [positionalParameters, namedParameters];
+ }
+
+ @override
InterfaceType getInterfaceType(
ElementImpl context, kernel.Supertype kernelType) {
return _getInterfaceType(
@@ -540,15 +561,12 @@ class _KernelLibraryResynthesizerContextImpl
return new TypeParameterElementImpl.forKernel(functionElement, k);
}).toList(growable: false);
+ var parameters = getFunctionTypeParameters(kernelType);
functionElement.parameters = ParameterElementImpl.forKernelParameters(
functionElement,
kernelType.requiredParameterCount,
- kernelType.positionalParameters
- .map((t) => new kernel.VariableDeclaration(null, type: t))
- .toList(),
- kernelType.namedParameters
- .map((t) => new kernel.VariableDeclaration(t.name, type: t.type))
- .toList());
+ parameters[0],
+ parameters[1]);
functionElement.returnType =
getType(functionElement, kernelType.returnType);
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698