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/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/resolution_accessors.dart'; |
8 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
9 import 'package:analyzer/src/dart/resolver/scope.dart'; | 10 import 'package:analyzer/src/dart/resolver/scope.dart'; |
10 | 11 |
11 /** | 12 /** |
12 * Returns the [Element] exported from the given [LibraryElement]. | 13 * Returns the [Element] exported from the given [LibraryElement]. |
13 */ | 14 */ |
14 Element getExportedElement(LibraryElement library, String name) { | 15 Element getExportedElement(LibraryElement library, String name) { |
15 if (library == null) { | 16 if (library == null) { |
16 return null; | 17 return null; |
17 } | 18 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 /** | 135 /** |
135 * Returns the [ImportElementInfo] with the [ImportElement] that is referenced | 136 * Returns the [ImportElementInfo] with the [ImportElement] that is referenced |
136 * by [prefixNode] with a [PrefixElement], maybe `null`. | 137 * by [prefixNode] with a [PrefixElement], maybe `null`. |
137 */ | 138 */ |
138 ImportElementInfo internal_getImportElementInfo(SimpleIdentifier prefixNode) { | 139 ImportElementInfo internal_getImportElementInfo(SimpleIdentifier prefixNode) { |
139 ImportElementInfo info = new ImportElementInfo(); | 140 ImportElementInfo info = new ImportElementInfo(); |
140 // prepare environment | 141 // prepare environment |
141 AstNode parent = prefixNode.parent; | 142 AstNode parent = prefixNode.parent; |
142 CompilationUnit unit = | 143 CompilationUnit unit = |
143 prefixNode.getAncestor((node) => node is CompilationUnit); | 144 prefixNode.getAncestor((node) => node is CompilationUnit); |
144 LibraryElement libraryElement = unit.element.library; | 145 LibraryElement libraryElement = elementForCompilationUnit(unit).library; |
145 // prepare used element | 146 // prepare used element |
146 Element usedElement = null; | 147 Element usedElement = null; |
147 if (parent is PrefixedIdentifier) { | 148 if (parent is PrefixedIdentifier) { |
148 PrefixedIdentifier prefixed = parent; | 149 PrefixedIdentifier prefixed = parent; |
149 if (prefixed.prefix == prefixNode) { | 150 if (prefixed.prefix == prefixNode) { |
150 usedElement = prefixed.staticElement; | 151 usedElement = prefixed.staticElement; |
151 info.periodEnd = prefixed.period.end; | 152 info.periodEnd = prefixed.period.end; |
152 } | 153 } |
153 } | 154 } |
154 if (parent is MethodInvocation) { | 155 if (parent is MethodInvocation) { |
(...skipping 19 matching lines...) Expand all Loading... |
174 } | 175 } |
175 | 176 |
176 /** | 177 /** |
177 * Information about [ImportElement] and place where it is referenced using | 178 * Information about [ImportElement] and place where it is referenced using |
178 * [PrefixElement]. | 179 * [PrefixElement]. |
179 */ | 180 */ |
180 class ImportElementInfo { | 181 class ImportElementInfo { |
181 ImportElement element; | 182 ImportElement element; |
182 int periodEnd; | 183 int periodEnd; |
183 } | 184 } |
OLD | NEW |