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

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

Issue 672013002: Issue 21375. Fix for FunctionTypeAliasElement-based FunctionType source. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/pubspec.yaml » ('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/src/protocol.dart' show SourceChange, 9 import 'package:analysis_server/src/protocol.dart' show SourceChange,
10 SourceEdit; 10 SourceEdit;
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 */ 881 */
882 String getText(int offset, int length) { 882 String getText(int offset, int length) {
883 return _buffer.substring(offset, offset + length); 883 return _buffer.substring(offset, offset + length);
884 } 884 }
885 885
886 /** 886 /**
887 * Returns the source to reference [type] in this [CompilationUnit]. 887 * Returns the source to reference [type] in this [CompilationUnit].
888 */ 888 */
889 String getTypeSource(DartType type) { 889 String getTypeSource(DartType type) {
890 StringBuffer sb = new StringBuffer(); 890 StringBuffer sb = new StringBuffer();
891 // just some Function, maybe find Function Type Alias later 891 // just a Function, not FunctionTypeAliasElement
892 if (type is FunctionType) { 892 if (type is FunctionType && type.element is! FunctionTypeAliasElement) {
893 return "Function"; 893 return "Function";
894 } 894 }
895 // prepare element 895 // prepare element
896 Element element = type.element; 896 Element element = type.element;
897 if (element == null) { 897 if (element == null) {
898 String source = type.toString(); 898 String source = type.toString();
899 source = source.replaceAll('<dynamic>', ''); 899 source = source.replaceAll('<dynamic>', '');
900 source = source.replaceAll('<dynamic, dynamic>', ''); 900 source = source.replaceAll('<dynamic, dynamic>', '');
901 return source; 901 return source;
902 } 902 }
903 // append prefix 903 // append prefix
904 { 904 {
905 ImportElement imp = _getImportElement(element); 905 ImportElement imp = _getImportElement(element);
906 if (imp != null && imp.prefix != null) { 906 if (imp != null && imp.prefix != null) {
907 sb.write(imp.prefix.displayName); 907 sb.write(imp.prefix.displayName);
908 sb.write("."); 908 sb.write(".");
909 } 909 }
910 } 910 }
911 // append simple name 911 // append simple name
912 String name = element.displayName; 912 String name = element.displayName;
913 sb.write(name); 913 sb.write(name);
914 // may be type arguments 914 // may be type arguments
915 if (type is InterfaceType) { 915 if (type is ParameterizedType) {
916 InterfaceType interfaceType = type; 916 List<DartType> arguments = type.typeArguments;
917 List<DartType> arguments = interfaceType.typeArguments;
918 // check if has arguments 917 // check if has arguments
919 bool hasArguments = false; 918 bool hasArguments = false;
920 for (DartType argument in arguments) { 919 for (DartType argument in arguments) {
921 if (!argument.isDynamic) { 920 if (!argument.isDynamic) {
922 hasArguments = true; 921 hasArguments = true;
923 break; 922 break;
924 } 923 }
925 } 924 }
926 // append type arguments 925 // append type arguments
927 if (hasArguments) { 926 if (hasArguments) {
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 1400
1402 @override 1401 @override
1403 Object visitExpression(Expression node) { 1402 Object visitExpression(Expression node) {
1404 if (node is BinaryExpression && node.operator.type == groupOperatorType) { 1403 if (node is BinaryExpression && node.operator.type == groupOperatorType) {
1405 return super.visitNode(node); 1404 return super.visitNode(node);
1406 } 1405 }
1407 operands.add(node); 1406 operands.add(node);
1408 return null; 1407 return null;
1409 } 1408 }
1410 } 1409 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698