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

Side by Side 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, 10 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library services.src.correction.util; 5 library services.src.correction.util;
6 6
7 import 'dart:math'; 7 import 'dart:math';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart' 9 import 'package:analysis_server/plugin/protocol/protocol.dart'
10 show SourceChange, SourceEdit; 10 show SourceChange, SourceEdit;
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 String getText(int offset, int length) { 1026 String getText(int offset, int length) {
1027 return _buffer.substring(offset, offset + length); 1027 return _buffer.substring(offset, offset + length);
1028 } 1028 }
1029 1029
1030 /** 1030 /**
1031 * Returns the source to reference [type] in this [CompilationUnit]. 1031 * Returns the source to reference [type] in this [CompilationUnit].
1032 * 1032 *
1033 * Fills [librariesToImport] with [LibraryElement]s whose elements are 1033 * Fills [librariesToImport] with [LibraryElement]s whose elements are
1034 * used by the generated source, but not imported. 1034 * used by the generated source, but not imported.
1035 */ 1035 */
1036 String getTypeSource(DartType type, Set<LibraryElement> librariesToImport) { 1036 String getTypeSource(DartType type, Set<LibraryElement> librariesToImport,
1037 {StringBuffer parametersBuffer}) {
1037 StringBuffer sb = new StringBuffer(); 1038 StringBuffer sb = new StringBuffer();
1038 // type parameter 1039 // type parameter
1039 if (!_isTypeVisible(type)) { 1040 if (!_isTypeVisible(type)) {
1040 return 'dynamic'; 1041 return 'dynamic';
1041 } 1042 }
1042 // just a Function, not FunctionTypeAliasElement 1043 // just a Function, not FunctionTypeAliasElement
1043 if (type is FunctionType && type.element is! FunctionTypeAliasElement) { 1044 if (type is FunctionType && type.element is! FunctionTypeAliasElement) {
1044 return "Function"; 1045 if (parametersBuffer == null) {
1046 return "Function";
1047 }
1048 parametersBuffer.write('(');
1049 for (ParameterElement parameter in type.parameters) {
1050 String parameterType = getTypeSource(parameter.type, librariesToImport);
1051 if (parametersBuffer.length != 1) {
1052 parametersBuffer.write(', ');
1053 }
1054 parametersBuffer.write(parameterType);
1055 parametersBuffer.write(' ');
1056 parametersBuffer.write(parameter.name);
1057 }
1058 parametersBuffer.write(')');
1059 return getTypeSource(type.returnType, librariesToImport);
1045 } 1060 }
1046 // BottomType 1061 // BottomType
1047 if (type.isBottom) { 1062 if (type.isBottom) {
1048 return 'dynamic'; 1063 return 'dynamic';
1049 } 1064 }
1050 // prepare element 1065 // prepare element
1051 Element element = type.element; 1066 Element element = type.element;
1052 if (element == null) { 1067 if (element == null) {
1053 String source = type.toString(); 1068 String source = type.toString();
1054 source = source.replaceAll('<dynamic>', ''); 1069 source = source.replaceAll('<dynamic>', '');
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 _InvertedCondition expr, int newOperatorPrecedence) { 1516 _InvertedCondition expr, int newOperatorPrecedence) {
1502 if (expr._precedence < newOperatorPrecedence) { 1517 if (expr._precedence < newOperatorPrecedence) {
1503 return "(${expr._source})"; 1518 return "(${expr._source})";
1504 } 1519 }
1505 return expr._source; 1520 return expr._source;
1506 } 1521 }
1507 1522
1508 static _InvertedCondition _simple(String source) => 1523 static _InvertedCondition _simple(String source) =>
1509 new _InvertedCondition(2147483647, source); 1524 new _InvertedCondition(2147483647, source);
1510 } 1525 }
OLDNEW
« 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