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

Side by Side Diff: pkg/analysis_server/lib/src/operation/operation_analysis.dart

Issue 1303033010: Navigation extension point. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: tweaks 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
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 operation.analysis; 5 library operation.analysis;
6 6
7 import 'package:analysis_server/src/analysis_server.dart'; 7 import 'package:analysis_server/src/analysis_server.dart';
8 import 'package:analysis_server/src/computer/computer_highlights.dart'; 8 import 'package:analysis_server/src/computer/computer_highlights.dart';
9 import 'package:analysis_server/src/computer/computer_highlights2.dart'; 9 import 'package:analysis_server/src/computer/computer_highlights2.dart';
10 import 'package:analysis_server/src/computer/computer_navigation.dart';
11 import 'package:analysis_server/src/computer/computer_occurrences.dart'; 10 import 'package:analysis_server/src/computer/computer_occurrences.dart';
12 import 'package:analysis_server/src/computer/computer_outline.dart'; 11 import 'package:analysis_server/src/computer/computer_outline.dart';
13 import 'package:analysis_server/src/computer/computer_overrides.dart'; 12 import 'package:analysis_server/src/computer/computer_overrides.dart';
13 import 'package:analysis_server/src/domains/analysis/navigation.dart';
14 import 'package:analysis_server/src/operation/operation.dart'; 14 import 'package:analysis_server/src/operation/operation.dart';
15 import 'package:analysis_server/src/protocol_server.dart' as protocol; 15 import 'package:analysis_server/src/protocol_server.dart' as protocol;
16 import 'package:analysis_server/src/services/dependencies/library_dependencies.d art'; 16 import 'package:analysis_server/src/services/dependencies/library_dependencies.d art';
17 import 'package:analysis_server/src/services/index/index.dart'; 17 import 'package:analysis_server/src/services/index/index.dart';
18 import 'package:analyzer/src/generated/ast.dart'; 18 import 'package:analyzer/src/generated/ast.dart';
19 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
20 import 'package:analyzer/src/generated/error.dart'; 20 import 'package:analyzer/src/generated/error.dart';
21 import 'package:analyzer/src/generated/html.dart'; 21 import 'package:analyzer/src/generated/html.dart';
22 import 'package:analyzer/src/generated/source.dart'; 22 import 'package:analyzer/src/generated/source.dart';
23 23
(...skipping 22 matching lines...) Expand all
46 AnalysisContext context, CompilationUnit dartUnit) { 46 AnalysisContext context, CompilationUnit dartUnit) {
47 if (server.index != null) { 47 if (server.index != null) {
48 server.addOperation(new _DartIndexOperation(context, file, dartUnit)); 48 server.addOperation(new _DartIndexOperation(context, file, dartUnit));
49 } 49 }
50 } 50 }
51 51
52 /** 52 /**
53 * Schedules sending notifications for the given [file] using the resolved 53 * Schedules sending notifications for the given [file] using the resolved
54 * [resolvedDartUnit]. 54 * [resolvedDartUnit].
55 */ 55 */
56 void scheduleNotificationOperations(AnalysisServer server, String file, 56 void scheduleNotificationOperations(
57 LineInfo lineInfo, AnalysisContext context, CompilationUnit parsedDartUnit, 57 AnalysisServer server,
58 CompilationUnit resolvedDartUnit, List<AnalysisError> errors) { 58 String file,
59 LineInfo lineInfo,
60 AnalysisContext context,
61 CompilationUnit parsedDartUnit,
62 CompilationUnit resolvedDartUnit,
63 List<AnalysisError> errors) {
59 // If the file belongs to any analysis root, check whether we're in it now. 64 // If the file belongs to any analysis root, check whether we're in it now.
60 AnalysisContext containingContext = server.getContainingContext(file); 65 AnalysisContext containingContext = server.getContainingContext(file);
61 if (containingContext != null && context != containingContext) { 66 if (containingContext != null && context != containingContext) {
62 return; 67 return;
63 } 68 }
64 // Dart 69 // Dart
65 CompilationUnit dartUnit = 70 CompilationUnit dartUnit =
66 resolvedDartUnit != null ? resolvedDartUnit : parsedDartUnit; 71 resolvedDartUnit != null ? resolvedDartUnit : parsedDartUnit;
67 if (resolvedDartUnit != null) { 72 if (resolvedDartUnit != null) {
68 if (server.hasAnalysisSubscription( 73 if (server.hasAnalysisSubscription(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 regions = new DartUnitHighlightsComputer2(dartUnit).compute(); 160 regions = new DartUnitHighlightsComputer2(dartUnit).compute();
156 } else { 161 } else {
157 regions = new DartUnitHighlightsComputer(dartUnit).compute(); 162 regions = new DartUnitHighlightsComputer(dartUnit).compute();
158 } 163 }
159 var params = new protocol.AnalysisHighlightsParams(file, regions); 164 var params = new protocol.AnalysisHighlightsParams(file, regions);
160 server.sendNotification(params.toNotification()); 165 server.sendNotification(params.toNotification());
161 }); 166 });
162 } 167 }
163 168
164 void sendAnalysisNotificationNavigation( 169 void sendAnalysisNotificationNavigation(
165 AnalysisServer server, String file, CompilationUnit dartUnit) { 170 AnalysisServer server, AnalysisContext context, Source source) {
166 _sendNotification(server, () { 171 _sendNotification(server, () {
167 var computer = new DartUnitNavigationComputer(); 172 NavigationHolderImpl holder =
168 computer.compute(dartUnit); 173 computeNavigation(server, context, source, null, null);
174 String file = source.fullName;
169 var params = new protocol.AnalysisNavigationParams( 175 var params = new protocol.AnalysisNavigationParams(
170 file, computer.regions, computer.targets, computer.files); 176 file, holder.regions, holder.targets, holder.files);
171 server.sendNotification(params.toNotification()); 177 server.sendNotification(params.toNotification());
172 }); 178 });
173 } 179 }
174 180
175 void sendAnalysisNotificationOccurrences( 181 void sendAnalysisNotificationOccurrences(
176 AnalysisServer server, String file, CompilationUnit dartUnit) { 182 AnalysisServer server, String file, CompilationUnit dartUnit) {
177 _sendNotification(server, () { 183 _sendNotification(server, () {
178 var occurrences = new DartUnitOccurrencesComputer(dartUnit).compute(); 184 var occurrences = new DartUnitOccurrencesComputer(dartUnit).compute();
179 var params = new protocol.AnalysisOccurrencesParams(file, occurrences); 185 var params = new protocol.AnalysisOccurrencesParams(file, occurrences);
180 server.sendNotification(params.toNotification()); 186 server.sendNotification(params.toNotification());
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 380 }
375 } 381 }
376 382
377 class _DartNavigationOperation extends _DartNotificationOperation { 383 class _DartNavigationOperation extends _DartNotificationOperation {
378 _DartNavigationOperation( 384 _DartNavigationOperation(
379 AnalysisContext context, String file, CompilationUnit unit) 385 AnalysisContext context, String file, CompilationUnit unit)
380 : super(context, file, unit); 386 : super(context, file, unit);
381 387
382 @override 388 @override
383 void perform(AnalysisServer server) { 389 void perform(AnalysisServer server) {
384 sendAnalysisNotificationNavigation(server, file, unit); 390 Source source = unit.element.source;
391 sendAnalysisNotificationNavigation(server, context, source);
385 } 392 }
386 } 393 }
387 394
388 abstract class _DartNotificationOperation extends _SingleFileOperation { 395 abstract class _DartNotificationOperation extends _SingleFileOperation {
389 final CompilationUnit unit; 396 final CompilationUnit unit;
390 397
391 _DartNotificationOperation(AnalysisContext context, String file, this.unit) 398 _DartNotificationOperation(AnalysisContext context, String file, this.unit)
392 : super(context, file); 399 : super(context, file);
393 400
394 @override 401 @override
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 abstract class _SingleFileOperation extends SourceSensitiveOperation { 479 abstract class _SingleFileOperation extends SourceSensitiveOperation {
473 final String file; 480 final String file;
474 481
475 _SingleFileOperation(AnalysisContext context, this.file) : super(context); 482 _SingleFileOperation(AnalysisContext context, this.file) : super(context);
476 483
477 @override 484 @override
478 bool shouldBeDiscardedOnSourceChange(Source source) { 485 bool shouldBeDiscardedOnSourceChange(Source source) {
479 return source.fullName == file; 486 return source.fullName == file;
480 } 487 }
481 } 488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698