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 domains.analysis.navigation; | 5 library domains.analysis.navigation; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analysis_server/analysis/navigation/navigation_core.dart'; | 9 import 'package:analysis_server/analysis/navigation/navigation_core.dart'; |
10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
11 import 'package:analysis_server/src/collections.dart'; | 11 import 'package:analysis_server/src/collections.dart'; |
12 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 12 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
13 import 'package:analyzer/src/generated/engine.dart' | 13 import 'package:analyzer/src/generated/engine.dart' |
14 show AnalysisContext, AnalysisEngine; | 14 show AnalysisContext, AnalysisEngine; |
15 import 'package:analyzer/src/generated/java_engine.dart' show CaughtException; | 15 import 'package:analyzer/src/generated/java_engine.dart' show CaughtException; |
16 import 'package:analyzer/src/generated/source.dart' show Source; | 16 import 'package:analyzer/src/generated/source.dart' show Source; |
17 | 17 |
18 /** | 18 /** |
19 * Compute all known navigation information for the given part of [source]. | 19 * Compute all known navigation information for the given part of [source]. |
20 */ | 20 */ |
21 NavigationHolderImpl computeNavigation(AnalysisServer server, | 21 NavigationCollectorImpl computeNavigation(AnalysisServer server, |
22 AnalysisContext context, Source source, int offset, int length) { | 22 AnalysisContext context, Source source, int offset, int length) { |
23 NavigationHolderImpl holder = new NavigationHolderImpl(); | 23 NavigationCollectorImpl collector = new NavigationCollectorImpl(); |
24 List<NavigationContributor> contributors = | 24 List<NavigationContributor> contributors = |
25 server.serverPlugin.navigationContributors; | 25 server.serverPlugin.navigationContributors; |
26 for (NavigationContributor contributor in contributors) { | 26 for (NavigationContributor contributor in contributors) { |
27 try { | 27 try { |
28 contributor.computeNavigation(holder, context, source, offset, length); | 28 contributor.computeNavigation(collector, context, source, offset, length); |
29 } catch (exception, stackTrace) { | 29 } catch (exception, stackTrace) { |
30 AnalysisEngine.instance.logger.logError( | 30 AnalysisEngine.instance.logger.logError( |
31 'Exception from navigation contributor: ${contributor.runtimeType}', | 31 'Exception from navigation contributor: ${contributor.runtimeType}', |
32 new CaughtException(exception, stackTrace)); | 32 new CaughtException(exception, stackTrace)); |
33 } | 33 } |
34 } | 34 } |
35 holder.sortRegions(); | 35 collector.sortRegions(); |
36 return holder; | 36 return collector; |
37 } | 37 } |
38 | 38 |
39 /** | 39 /** |
40 * A concrete implementation of [NavigationHolder]. | 40 * A concrete implementation of [NavigationCollector]. |
41 */ | 41 */ |
42 class NavigationHolderImpl implements NavigationHolder { | 42 class NavigationCollectorImpl implements NavigationCollector { |
43 /** | 43 /** |
44 * A list of navigation regions. | 44 * A list of navigation regions. |
45 */ | 45 */ |
46 final List<protocol.NavigationRegion> regions = <protocol.NavigationRegion>[]; | 46 final List<protocol.NavigationRegion> regions = <protocol.NavigationRegion>[]; |
47 | 47 |
48 /** | 48 /** |
49 * All the unique targets referenced by [regions]. | 49 * All the unique targets referenced by [regions]. |
50 */ | 50 */ |
51 final List<protocol.NavigationTarget> targets = <protocol.NavigationTarget>[]; | 51 final List<protocol.NavigationTarget> targets = <protocol.NavigationTarget>[]; |
52 final Map<Pair<protocol.ElementKind, protocol.Location>, int> targetMap = | 52 final Map<Pair<protocol.ElementKind, protocol.Location>, int> targetMap = |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 location.offset, | 97 location.offset, |
98 location.length, | 98 location.length, |
99 location.startLine, | 99 location.startLine, |
100 location.startColumn); | 100 location.startColumn); |
101 targets.add(target); | 101 targets.add(target); |
102 targetMap[pair] = index; | 102 targetMap[pair] = index; |
103 } | 103 } |
104 return index; | 104 return index; |
105 } | 105 } |
106 } | 106 } |
OLD | NEW |