Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: pkg/analysis_server/lib/src/domains/analysis/navigation.dart

Issue 1323243008: Sort navigation regions after gathering results from all of the contributors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
(...skipping 14 matching lines...) Expand all
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(holder, 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 return holder; 36 return holder;
36 } 37 }
37 38
38 /** 39 /**
39 * A concrete implementation of [NavigationHolder]. 40 * A concrete implementation of [NavigationHolder].
40 */ 41 */
41 class NavigationHolderImpl implements NavigationHolder { 42 class NavigationHolderImpl implements NavigationHolder {
42 /** 43 /**
43 * A list of navigation regions. 44 * A list of navigation regions.
44 */ 45 */
(...skipping 14 matching lines...) Expand all
59 60
60 @override 61 @override
61 void addRegion(int offset, int length, protocol.ElementKind targetKind, 62 void addRegion(int offset, int length, protocol.ElementKind targetKind,
62 protocol.Location targetLocation) { 63 protocol.Location targetLocation) {
63 int targetIndex = _addTarget(targetKind, targetLocation); 64 int targetIndex = _addTarget(targetKind, targetLocation);
64 protocol.NavigationRegion region = 65 protocol.NavigationRegion region =
65 new protocol.NavigationRegion(offset, length, <int>[targetIndex]); 66 new protocol.NavigationRegion(offset, length, <int>[targetIndex]);
66 regions.add(region); 67 regions.add(region);
67 } 68 }
68 69
70 void sortRegions() {
71 regions.sort((a, b) {
72 return a.offset - b.offset;
73 });
74 }
75
69 int _addFile(String file) { 76 int _addFile(String file) {
70 int index = fileMap[file]; 77 int index = fileMap[file];
71 if (index == null) { 78 if (index == null) {
72 index = files.length; 79 index = files.length;
73 files.add(file); 80 files.add(file);
74 fileMap[file] = index; 81 fileMap[file] = index;
75 } 82 }
76 return index; 83 return index;
77 } 84 }
78 85
(...skipping 11 matching lines...) Expand all
90 location.offset, 97 location.offset,
91 location.length, 98 location.length,
92 location.startLine, 99 location.startLine,
93 location.startColumn); 100 location.startColumn);
94 targets.add(target); 101 targets.add(target);
95 targetMap[pair] = index; 102 targetMap[pair] = index;
96 } 103 }
97 return index; 104 return index;
98 } 105 }
99 } 106 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698