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

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

Issue 1098423002: Issue 23271. Check target.staticElement for null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 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
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698