| 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 services.src.correction.namespace; | 5 library services.src.correction.namespace; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/resolver.dart'; | 9 import 'package:analyzer/src/generated/resolver.dart'; |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 PrefixedIdentifier prefixed = parent; | 145 PrefixedIdentifier prefixed = parent; |
| 146 if (prefixed.prefix == prefixNode) { | 146 if (prefixed.prefix == prefixNode) { |
| 147 usedElement = prefixed.staticElement; | 147 usedElement = prefixed.staticElement; |
| 148 info.periodEnd = prefixed.period.end; | 148 info.periodEnd = prefixed.period.end; |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 if (parent is MethodInvocation) { | 151 if (parent is MethodInvocation) { |
| 152 MethodInvocation invocation = parent; | 152 MethodInvocation invocation = parent; |
| 153 if (invocation.target == prefixNode) { | 153 if (invocation.target == prefixNode) { |
| 154 usedElement = invocation.methodName.staticElement; | 154 usedElement = invocation.methodName.staticElement; |
| 155 info.periodEnd = invocation.period.end; | 155 info.periodEnd = invocation.operator.end; |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 // we need used Element | 158 // we need used Element |
| 159 if (usedElement == null) { | 159 if (usedElement == null) { |
| 160 return null; | 160 return null; |
| 161 } | 161 } |
| 162 // find ImportElement | 162 // find ImportElement |
| 163 String prefix = prefixNode.name; | 163 String prefix = prefixNode.name; |
| 164 Map<ImportElement, Set<Element>> importElementsMap = {}; | 164 Map<ImportElement, Set<Element>> importElementsMap = {}; |
| 165 info.element = internal_getImportElement( | 165 info.element = internal_getImportElement( |
| 166 libraryElement, prefix, usedElement, importElementsMap); | 166 libraryElement, prefix, usedElement, importElementsMap); |
| 167 if (info.element == null) { | 167 if (info.element == null) { |
| 168 return null; | 168 return null; |
| 169 } | 169 } |
| 170 return info; | 170 return info; |
| 171 } | 171 } |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * Information about [ImportElement] and place where it is referenced using | 174 * Information about [ImportElement] and place where it is referenced using |
| 175 * [PrefixElement]. | 175 * [PrefixElement]. |
| 176 */ | 176 */ |
| 177 class ImportElementInfo { | 177 class ImportElementInfo { |
| 178 ImportElement element; | 178 ImportElement element; |
| 179 int periodEnd; | 179 int periodEnd; |
| 180 } | 180 } |
| OLD | NEW |