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

Unified Diff: pkg/analysis_server/lib/src/services/correction/util.dart

Issue 1655353002: Issue 25616. Support for extracting methods with function-typed parameters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/analysis_server/lib/src/services/refactoring/extract_method.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/correction/util.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart
index 63aefd964ef13af869e17bbc7db7d17c69625546..c69bf694ff65ca8b2b67e91a408e21daff6f1896 100644
--- a/pkg/analysis_server/lib/src/services/correction/util.dart
+++ b/pkg/analysis_server/lib/src/services/correction/util.dart
@@ -1033,7 +1033,8 @@ class CorrectionUtils {
* Fills [librariesToImport] with [LibraryElement]s whose elements are
* used by the generated source, but not imported.
*/
- String getTypeSource(DartType type, Set<LibraryElement> librariesToImport) {
+ String getTypeSource(DartType type, Set<LibraryElement> librariesToImport,
+ {StringBuffer parametersBuffer}) {
StringBuffer sb = new StringBuffer();
// type parameter
if (!_isTypeVisible(type)) {
@@ -1041,7 +1042,21 @@ class CorrectionUtils {
}
// just a Function, not FunctionTypeAliasElement
if (type is FunctionType && type.element is! FunctionTypeAliasElement) {
- return "Function";
+ if (parametersBuffer == null) {
+ return "Function";
+ }
+ parametersBuffer.write('(');
+ for (ParameterElement parameter in type.parameters) {
+ String parameterType = getTypeSource(parameter.type, librariesToImport);
+ if (parametersBuffer.length != 1) {
+ parametersBuffer.write(', ');
+ }
+ parametersBuffer.write(parameterType);
+ parametersBuffer.write(' ');
+ parametersBuffer.write(parameter.name);
+ }
+ parametersBuffer.write(')');
+ return getTypeSource(type.returnType, librariesToImport);
}
// BottomType
if (type.isBottom) {
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/refactoring/extract_method.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698