Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 analysis_server.src.services.correction.fix_internal; | 5 library analysis_server.src.services.correction.fix_internal; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:core'; | 9 import 'dart:core'; |
| 10 | 10 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 } | 358 } |
| 359 if (errorCode == StaticTypeWarningCode.UNDEFINED_SETTER) { | 359 if (errorCode == StaticTypeWarningCode.UNDEFINED_SETTER) { |
| 360 _addFix_undefinedClassAccessor_useSimilar(); | 360 _addFix_undefinedClassAccessor_useSimilar(); |
| 361 _addFix_createField(); | 361 _addFix_createField(); |
| 362 } | 362 } |
| 363 // lints | 363 // lints |
| 364 if (errorCode is LintCode) { | 364 if (errorCode is LintCode) { |
| 365 if (errorCode.name == LintNames.annotate_overrides) { | 365 if (errorCode.name == LintNames.annotate_overrides) { |
| 366 _addLintFixAddOverrideAnnotation(); | 366 _addLintFixAddOverrideAnnotation(); |
| 367 } | 367 } |
| 368 if (errorCode.name == LintNames.unnecessary_brace_in_string_interp) { | |
| 369 _addLintRemoveInterpolationBraces(); | |
| 370 } | |
| 368 } | 371 } |
| 369 // done | 372 // done |
| 370 return fixes; | 373 return fixes; |
| 371 } | 374 } |
| 372 | 375 |
| 373 /** | 376 /** |
| 374 * Adds a new [SourceEdit] to [change]. | 377 * Adds a new [SourceEdit] to [change]. |
| 375 */ | 378 */ |
| 376 void _addEdit(Element target, SourceEdit edit) { | 379 void _addEdit(Element target, SourceEdit edit) { |
| 377 if (target == null) { | 380 if (target == null) { |
| (...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2282 if (token is CommentToken) { | 2285 if (token is CommentToken) { |
| 2283 token = (token as CommentToken).parent; | 2286 token = (token as CommentToken).parent; |
| 2284 } | 2287 } |
| 2285 | 2288 |
| 2286 exitPosition = new Position(file, token.offset - 1); | 2289 exitPosition = new Position(file, token.offset - 1); |
| 2287 String indent = utils.getIndent(1); | 2290 String indent = utils.getIndent(1); |
| 2288 _addReplaceEdit(rf.rangeStartLength(token, 0), '@override$eol$indent'); | 2291 _addReplaceEdit(rf.rangeStartLength(token, 0), '@override$eol$indent'); |
| 2289 _addFix(DartFixKind.LINT_ADD_OVERRIDE, []); | 2292 _addFix(DartFixKind.LINT_ADD_OVERRIDE, []); |
| 2290 } | 2293 } |
| 2291 | 2294 |
| 2295 void _addLintRemoveInterpolationBraces() { | |
|
Brian Wilkerson
2016/10/07 18:57:56
Remove "Lint" from the name? I don't think it adds
| |
| 2296 AstNode node = this.node; | |
| 2297 if (node is InterpolationExpression) { | |
| 2298 Token right = node.rightBracket; | |
| 2299 if (node.expression != null && right != null) { | |
| 2300 _addReplaceEdit(rf.rangeStartStart(node, node.expression), r'$'); | |
| 2301 _addRemoveEdit(rf.rangeToken(right)); | |
| 2302 _addFix(DartFixKind.LINT_REMOVE_INTERPOLATION_BRACES, []); | |
| 2303 } | |
| 2304 } | |
| 2305 } | |
| 2306 | |
| 2292 /** | 2307 /** |
| 2293 * Prepares proposal for creating function corresponding to the given | 2308 * Prepares proposal for creating function corresponding to the given |
| 2294 * [FunctionType]. | 2309 * [FunctionType]. |
| 2295 */ | 2310 */ |
| 2296 void _addProposal_createFunction( | 2311 void _addProposal_createFunction( |
| 2297 FunctionType functionType, | 2312 FunctionType functionType, |
| 2298 String name, | 2313 String name, |
| 2299 Source targetSource, | 2314 Source targetSource, |
| 2300 int insertOffset, | 2315 int insertOffset, |
| 2301 bool isStatic, | 2316 bool isStatic, |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2898 } | 2913 } |
| 2899 return false; | 2914 return false; |
| 2900 } | 2915 } |
| 2901 } | 2916 } |
| 2902 | 2917 |
| 2903 /** | 2918 /** |
| 2904 * An enumeration of lint names. | 2919 * An enumeration of lint names. |
| 2905 */ | 2920 */ |
| 2906 class LintNames { | 2921 class LintNames { |
| 2907 static const String annotate_overrides = 'annotate_overrides'; | 2922 static const String annotate_overrides = 'annotate_overrides'; |
| 2923 static const String unnecessary_brace_in_string_interp = | |
| 2924 'unnecessary_brace_in_string_interp'; | |
| 2908 } | 2925 } |
| 2909 | 2926 |
| 2910 /** | 2927 /** |
| 2911 * Helper for finding [Element] with name closest to the given. | 2928 * Helper for finding [Element] with name closest to the given. |
| 2912 */ | 2929 */ |
| 2913 class _ClosestElementFinder { | 2930 class _ClosestElementFinder { |
| 2914 final String _targetName; | 2931 final String _targetName; |
| 2915 final ElementPredicate _predicate; | 2932 final ElementPredicate _predicate; |
| 2916 | 2933 |
| 2917 Element _element = null; | 2934 Element _element = null; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2928 } | 2945 } |
| 2929 } | 2946 } |
| 2930 } | 2947 } |
| 2931 | 2948 |
| 2932 void _updateList(Iterable<Element> elements) { | 2949 void _updateList(Iterable<Element> elements) { |
| 2933 for (Element element in elements) { | 2950 for (Element element in elements) { |
| 2934 _update(element); | 2951 _update(element); |
| 2935 } | 2952 } |
| 2936 } | 2953 } |
| 2937 } | 2954 } |
| OLD | NEW |