OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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:collection'; | 5 import 'dart:collection'; |
6 | 6 |
7 import 'package:analysis_server/plugin/analysis/navigation/navigation_core.dart'
; | 7 import 'package:analysis_server/plugin/analysis/navigation/navigation_core.dart'
; |
8 import 'package:analysis_server/src/analysis_server.dart'; | |
9 import 'package:analysis_server/src/collections.dart'; | 8 import 'package:analysis_server/src/collections.dart'; |
10 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 9 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
11 import 'package:analyzer/exception/exception.dart'; | 10 import 'package:analyzer/src/generated/source.dart' show SourceRange; |
12 import 'package:analyzer/src/generated/engine.dart' | |
13 show AnalysisContext, AnalysisEngine; | |
14 import 'package:analyzer/src/generated/source.dart' show Source, SourceRange; | |
15 | |
16 /** | |
17 * Compute all known navigation information for the given part of [source]. | |
18 */ | |
19 NavigationCollectorImpl computeNavigation(AnalysisServer server, | |
20 AnalysisContext context, Source source, int offset, int length) { | |
21 NavigationCollectorImpl collector = new NavigationCollectorImpl(); | |
22 List<NavigationContributor> contributors = | |
23 server.serverPlugin.navigationContributors; | |
24 for (NavigationContributor contributor in contributors) { | |
25 try { | |
26 contributor.computeNavigation(collector, context, source, offset, length); | |
27 } catch (exception, stackTrace) { | |
28 AnalysisEngine.instance.logger.logError( | |
29 'Exception from navigation contributor: ${contributor.runtimeType}', | |
30 new CaughtException(exception, stackTrace)); | |
31 } | |
32 } | |
33 collector.createRegions(); | |
34 return collector; | |
35 } | |
36 | 11 |
37 /** | 12 /** |
38 * A concrete implementation of [NavigationCollector]. | 13 * A concrete implementation of [NavigationCollector]. |
39 */ | 14 */ |
40 class NavigationCollectorImpl implements NavigationCollector { | 15 class NavigationCollectorImpl implements NavigationCollector { |
41 /** | 16 /** |
42 * A list of navigation regions. | 17 * A list of navigation regions. |
43 */ | 18 */ |
44 final List<protocol.NavigationRegion> regions = <protocol.NavigationRegion>[]; | 19 final List<protocol.NavigationRegion> regions = <protocol.NavigationRegion>[]; |
45 final Map<SourceRange, List<int>> regionMap = | 20 final Map<SourceRange, List<int>> regionMap = |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 location.offset, | 83 location.offset, |
109 location.length, | 84 location.length, |
110 location.startLine, | 85 location.startLine, |
111 location.startColumn); | 86 location.startColumn); |
112 targets.add(target); | 87 targets.add(target); |
113 targetMap[pair] = index; | 88 targetMap[pair] = index; |
114 } | 89 } |
115 return index; | 90 return index; |
116 } | 91 } |
117 } | 92 } |
OLD | NEW |