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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analysis_server/src/protocol_server.dart' hide Element; | 7 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
8 import 'package:analysis_server/src/services/correction/status.dart'; | 8 import 'package:analysis_server/src/services/correction/status.dart'; |
9 import 'package:analysis_server/src/services/correction/util.dart'; | 9 import 'package:analysis_server/src/services/correction/util.dart'; |
10 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 10 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; |
11 import 'package:analysis_server/src/services/refactoring/refactoring_internal.da
rt'; | 11 import 'package:analysis_server/src/services/refactoring/refactoring_internal.da
rt'; |
12 import 'package:analysis_server/src/services/search/search_engine.dart'; | 12 import 'package:analysis_server/src/services/search/search_engine.dart'; |
13 import 'package:analyzer/dart/element/element.dart'; | 13 import 'package:analyzer/dart/element/element.dart'; |
14 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
15 import 'package:analyzer/src/generated/java_core.dart'; | 15 import 'package:analyzer/src/generated/java_core.dart'; |
16 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
17 import 'package:analyzer_plugin/utilities/range_factory.dart'; | 17 import 'package:analyzer_plugin/utilities/range_factory.dart'; |
18 import 'package:path/path.dart' as pathos; | 18 import 'package:path/path.dart' as pathos; |
19 | 19 |
20 /** | 20 /** |
21 * Returns `true` if two given [Element]s are [LocalElement]s and have | |
22 * intersecting with visibility ranges. | |
23 */ | |
24 bool haveIntersectingRanges(LocalElement localElement, Element element) { | |
25 if (element is! LocalElement) { | |
26 return false; | |
27 } | |
28 LocalElement localElement2 = element as LocalElement; | |
29 Source localSource = localElement.source; | |
30 Source localSource2 = localElement2.source; | |
31 SourceRange localRange = localElement.visibleRange; | |
32 SourceRange localRange2 = localElement2.visibleRange; | |
33 return localSource2 == localSource && | |
34 localRange != null && | |
35 localRange2 != null && | |
36 localRange2.intersects(localRange); | |
37 } | |
38 | |
39 /** | |
40 * Checks if [element] is defined in the library containing [source]. | 21 * Checks if [element] is defined in the library containing [source]. |
41 */ | 22 */ |
42 bool isDefinedInLibrary( | 23 bool isDefinedInLibrary( |
43 Element element, AnalysisContext context, Source source) { | 24 Element element, AnalysisContext context, Source source) { |
44 // should be the same AnalysisContext | 25 // should be the same AnalysisContext |
45 if (!isInContext(element, context)) { | 26 if (!isInContext(element, context)) { |
46 return false; | 27 return false; |
47 } | 28 } |
48 // private elements are visible only in their library | 29 // private elements are visible only in their library |
49 List<Source> librarySourcesOfSource = context.getLibrariesContaining(source); | 30 List<Source> librarySourcesOfSource = context.getLibrariesContaining(source); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (element is ImportElement) { | 197 if (element is ImportElement) { |
217 PrefixElement prefix = element.prefix; | 198 PrefixElement prefix = element.prefix; |
218 if (prefix != null) { | 199 if (prefix != null) { |
219 return prefix.displayName; | 200 return prefix.displayName; |
220 } | 201 } |
221 return ''; | 202 return ''; |
222 } | 203 } |
223 return element.displayName; | 204 return element.displayName; |
224 } | 205 } |
225 } | 206 } |
OLD | NEW |