| 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 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_outline.dart'; | 10 import 'package:analysis_server/src/computer/computer_outline.dart'; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 269 } |
| 270 | 270 |
| 271 /** | 271 /** |
| 272 * Runs the given notification producing function [f], catching exceptions. | 272 * Runs the given notification producing function [f], catching exceptions. |
| 273 */ | 273 */ |
| 274 void _sendNotification(AnalysisServer server, f()) { | 274 void _sendNotification(AnalysisServer server, f()) { |
| 275 ServerPerformanceStatistics.notices.makeCurrentWhile(() { | 275 ServerPerformanceStatistics.notices.makeCurrentWhile(() { |
| 276 try { | 276 try { |
| 277 f(); | 277 f(); |
| 278 } catch (exception, stackTrace) { | 278 } catch (exception, stackTrace) { |
| 279 server.sendServerErrorNotification(exception, stackTrace); | 279 server.sendServerErrorNotification( |
| 280 'Failed to send notification', exception, stackTrace); |
| 280 } | 281 } |
| 281 }); | 282 }); |
| 282 } | 283 } |
| 283 | 284 |
| 284 class NavigationOperation extends _NotificationOperation | 285 class NavigationOperation extends _NotificationOperation |
| 285 implements MergeableOperation { | 286 implements MergeableOperation { |
| 286 NavigationOperation(AnalysisContext context, Source source) | 287 NavigationOperation(AnalysisContext context, Source source) |
| 287 : super(context, source); | 288 : super(context, source); |
| 288 | 289 |
| 289 @override | 290 @override |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } | 412 } |
| 412 for (ChangeNotice notice in notices) { | 413 for (ChangeNotice notice in notices) { |
| 413 String file = notice.source.fullName; | 414 String file = notice.source.fullName; |
| 414 // Dart | 415 // Dart |
| 415 try { | 416 try { |
| 416 CompilationUnit dartUnit = notice.resolvedDartUnit; | 417 CompilationUnit dartUnit = notice.resolvedDartUnit; |
| 417 if (dartUnit != null) { | 418 if (dartUnit != null) { |
| 418 scheduleIndexOperation(server, file, dartUnit); | 419 scheduleIndexOperation(server, file, dartUnit); |
| 419 } | 420 } |
| 420 } catch (exception, stackTrace) { | 421 } catch (exception, stackTrace) { |
| 421 server.sendServerErrorNotification(exception, stackTrace); | 422 server.sendServerErrorNotification( |
| 423 'Failed to index Dart file: $file', exception, stackTrace); |
| 422 } | 424 } |
| 423 // HTML | 425 // HTML |
| 424 try { | 426 try { |
| 425 HtmlUnit htmlUnit = notice.resolvedHtmlUnit; | 427 HtmlUnit htmlUnit = notice.resolvedHtmlUnit; |
| 426 if (htmlUnit != null) { | 428 if (htmlUnit != null) { |
| 427 server.addOperation(new _HtmlIndexOperation(context, file, htmlUnit)); | 429 server.addOperation(new _HtmlIndexOperation(context, file, htmlUnit)); |
| 428 } | 430 } |
| 429 } catch (exception, stackTrace) { | 431 } catch (exception, stackTrace) { |
| 430 server.sendServerErrorNotification(exception, stackTrace); | 432 server.sendServerErrorNotification( |
| 433 'Failed to index HTML file: $file', exception, stackTrace); |
| 431 } | 434 } |
| 432 } | 435 } |
| 433 } | 436 } |
| 434 } | 437 } |
| 435 | 438 |
| 436 class _DartHighlightsOperation extends _DartNotificationOperation { | 439 class _DartHighlightsOperation extends _DartNotificationOperation { |
| 437 _DartHighlightsOperation( | 440 _DartHighlightsOperation( |
| 438 AnalysisContext context, String file, CompilationUnit unit) | 441 AnalysisContext context, String file, CompilationUnit unit) |
| 439 : super(context, file, unit); | 442 : super(context, file, unit); |
| 440 | 443 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 456 } | 459 } |
| 457 | 460 |
| 458 @override | 461 @override |
| 459 void perform(AnalysisServer server) { | 462 void perform(AnalysisServer server) { |
| 460 ServerPerformanceStatistics.indexOperation.makeCurrentWhile(() { | 463 ServerPerformanceStatistics.indexOperation.makeCurrentWhile(() { |
| 461 try { | 464 try { |
| 462 Index index = server.index; | 465 Index index = server.index; |
| 463 AnalysisContext context = unit.element.context; | 466 AnalysisContext context = unit.element.context; |
| 464 index.index(context, unit); | 467 index.index(context, unit); |
| 465 } catch (exception, stackTrace) { | 468 } catch (exception, stackTrace) { |
| 466 server.sendServerErrorNotification(exception, stackTrace); | 469 server.sendServerErrorNotification( |
| 470 'Failed to index: $file', exception, stackTrace); |
| 467 } | 471 } |
| 468 }); | 472 }); |
| 469 } | 473 } |
| 470 } | 474 } |
| 471 | 475 |
| 472 abstract class _DartNotificationOperation extends _SingleFileOperation { | 476 abstract class _DartNotificationOperation extends _SingleFileOperation { |
| 473 final CompilationUnit unit; | 477 final CompilationUnit unit; |
| 474 | 478 |
| 475 _DartNotificationOperation(AnalysisContext context, String file, this.unit) | 479 _DartNotificationOperation(AnalysisContext context, String file, this.unit) |
| 476 : super(context, file); | 480 : super(context, file); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 abstract class _SingleFileOperation extends SourceSensitiveOperation { | 566 abstract class _SingleFileOperation extends SourceSensitiveOperation { |
| 563 final String file; | 567 final String file; |
| 564 | 568 |
| 565 _SingleFileOperation(AnalysisContext context, this.file) : super(context); | 569 _SingleFileOperation(AnalysisContext context, this.file) : super(context); |
| 566 | 570 |
| 567 @override | 571 @override |
| 568 bool shouldBeDiscardedOnSourceChange(Source source) { | 572 bool shouldBeDiscardedOnSourceChange(Source source) { |
| 569 return source.fullName == file; | 573 return source.fullName == file; |
| 570 } | 574 } |
| 571 } | 575 } |
| OLD | NEW |