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:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analysis_server/edit/fix/fix_core.dart'; | 9 import 'package:analysis_server/edit/fix/fix_core.dart'; |
10 import 'package:analysis_server/edit/fix/fix_dart.dart'; | 10 import 'package:analysis_server/edit/fix/fix_dart.dart'; |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 // prepare target interface type | 714 // prepare target interface type |
715 DartType targetType = target.bestType; | 715 DartType targetType = target.bestType; |
716 if (targetType is! InterfaceType) { | 716 if (targetType is! InterfaceType) { |
717 return; | 717 return; |
718 } | 718 } |
719 targetClassElement = targetType.element; | 719 targetClassElement = targetType.element; |
720 // maybe static | 720 // maybe static |
721 if (target is Identifier) { | 721 if (target is Identifier) { |
722 Identifier targetIdentifier = target; | 722 Identifier targetIdentifier = target; |
723 Element targetElement = targetIdentifier.staticElement; | 723 Element targetElement = targetIdentifier.staticElement; |
724 if (targetElement == null) { | |
725 return; | |
Brian Wilkerson
2015/04/22 20:55:55
Given that we don't expect this case, and think th
| |
726 } | |
724 staticModifier = targetElement.kind == ElementKind.CLASS; | 727 staticModifier = targetElement.kind == ElementKind.CLASS; |
725 } | 728 } |
726 } else { | 729 } else { |
727 targetClassElement = getEnclosingClassElement(node); | 730 targetClassElement = getEnclosingClassElement(node); |
728 if (targetClassElement == null) { | 731 if (targetClassElement == null) { |
729 return; | 732 return; |
730 } | 733 } |
731 staticModifier = _inStaticContext(); | 734 staticModifier = _inStaticContext(); |
732 } | 735 } |
733 utils.targetClassElement = targetClassElement; | 736 utils.targetClassElement = targetClassElement; |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1179 _addInsertEdit(offset, importSource, libraryUnitElement); | 1182 _addInsertEdit(offset, importSource, libraryUnitElement); |
1180 // add proposal | 1183 // add proposal |
1181 _addFix(kind, [importPath]); | 1184 _addFix(kind, [importPath]); |
1182 } | 1185 } |
1183 | 1186 |
1184 void _addFix_importLibrary_withElement(String name, ElementKind kind) { | 1187 void _addFix_importLibrary_withElement(String name, ElementKind kind) { |
1185 // ignore if private | 1188 // ignore if private |
1186 if (name.startsWith('_')) { | 1189 if (name.startsWith('_')) { |
1187 return; | 1190 return; |
1188 } | 1191 } |
1189 | |
1190 // may be there is an existing import, | 1192 // may be there is an existing import, |
1191 // but it is with prefix and we don't use this prefix | 1193 // but it is with prefix and we don't use this prefix |
1192 for (ImportElement imp in unitLibraryElement.imports) { | 1194 for (ImportElement imp in unitLibraryElement.imports) { |
1193 // prepare element | 1195 // prepare element |
1194 LibraryElement libraryElement = imp.importedLibrary; | 1196 LibraryElement libraryElement = imp.importedLibrary; |
1195 Element element = getExportedElement(libraryElement, name); | 1197 Element element = getExportedElement(libraryElement, name); |
1196 if (element == null) { | 1198 if (element == null) { |
1197 continue; | 1199 continue; |
1198 } | 1200 } |
1199 if (element is PropertyAccessorElement) { | 1201 if (element is PropertyAccessorElement) { |
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2502 /** | 2504 /** |
2503 * Describes the location for a newly created [FieldDeclaration]. | 2505 * Describes the location for a newly created [FieldDeclaration]. |
2504 */ | 2506 */ |
2505 class _FieldLocation { | 2507 class _FieldLocation { |
2506 final String prefix; | 2508 final String prefix; |
2507 final int offset; | 2509 final int offset; |
2508 final String suffix; | 2510 final String suffix; |
2509 | 2511 |
2510 _FieldLocation(this.prefix, this.offset, this.suffix); | 2512 _FieldLocation(this.prefix, this.offset, this.suffix); |
2511 } | 2513 } |
OLD | NEW |