| 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 analysis.server; | 5 library analysis.server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| 11 import 'package:analysis_server/src/analysis_logger.dart'; | 11 import 'package:analysis_server/src/analysis_logger.dart'; |
| 12 import 'package:analysis_server/src/channel.dart'; | 12 import 'package:analysis_server/src/channel.dart'; |
| 13 import 'package:analysis_server/src/constants.dart'; | 13 import 'package:analysis_server/src/constants.dart'; |
| 14 import 'package:analysis_server/src/context_manager.dart'; | 14 import 'package:analysis_server/src/context_manager.dart'; |
| 15 import 'package:analysis_server/src/domain_analysis.dart'; | |
| 16 import 'package:analysis_server/src/operation/operation_analysis.dart'; | 15 import 'package:analysis_server/src/operation/operation_analysis.dart'; |
| 17 import 'package:analysis_server/src/operation/operation.dart'; | 16 import 'package:analysis_server/src/operation/operation.dart'; |
| 18 import 'package:analysis_server/src/operation/operation_queue.dart'; | 17 import 'package:analysis_server/src/operation/operation_queue.dart'; |
| 19 import 'package:analysis_server/src/package_map_provider.dart'; | 18 import 'package:analysis_server/src/package_map_provider.dart'; |
| 20 import 'package:analysis_server/src/protocol.dart'; | 19 import 'package:analysis_server/src/protocol.dart'; |
| 21 import 'package:analysis_server/src/protocol2.dart' show AnalysisService, | 20 import 'package:analysis_server/src/protocol2.dart' show AnalysisService, |
| 22 ServerService; | 21 ServerService, AddContentOverlay, ChangeContentOverlay, |
| 22 RemoveContentOverlay; |
| 23 import 'package:analyzer/source/package_map_resolver.dart'; | 23 import 'package:analyzer/source/package_map_resolver.dart'; |
| 24 import 'package:analyzer/src/generated/ast.dart'; | 24 import 'package:analyzer/src/generated/ast.dart'; |
| 25 import 'package:analyzer/src/generated/engine.dart'; | 25 import 'package:analyzer/src/generated/engine.dart'; |
| 26 import 'package:analyzer/src/generated/source.dart'; | 26 import 'package:analyzer/src/generated/source.dart'; |
| 27 import 'package:analyzer/src/generated/sdk.dart'; | 27 import 'package:analyzer/src/generated/sdk.dart'; |
| 28 import 'package:analyzer/src/generated/source_io.dart'; | 28 import 'package:analyzer/src/generated/source_io.dart'; |
| 29 import 'package:analyzer/src/generated/java_engine.dart'; | 29 import 'package:analyzer/src/generated/java_engine.dart'; |
| 30 import 'package:analysis_server/src/services/correction/change.dart'; | 30 import 'package:analysis_server/src/services/correction/change.dart'; |
| 31 import 'package:analysis_server/src/services/index/index.dart'; | 31 import 'package:analysis_server/src/services/index/index.dart'; |
| 32 import 'package:analysis_server/src/services/search/search_engine.dart'; | 32 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } on UnimplementedError catch (e) { | 471 } on UnimplementedError catch (e) { |
| 472 throw new RequestFailure( | 472 throw new RequestFailure( |
| 473 new Response.unsupportedFeature( | 473 new Response.unsupportedFeature( |
| 474 requestId, e.message)); | 474 requestId, e.message)); |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 | 477 |
| 478 /** | 478 /** |
| 479 * Implementation for `analysis.updateContent`. | 479 * Implementation for `analysis.updateContent`. |
| 480 */ | 480 */ |
| 481 void updateContent(Map<String, ContentChange> changes) { | 481 void updateContent(Map<String, dynamic> changes) { |
| 482 changes.forEach((file, change) { | 482 changes.forEach((file, change) { |
| 483 AnalysisContext analysisContext = getAnalysisContext(file); | 483 AnalysisContext analysisContext = getAnalysisContext(file); |
| 484 // TODO(paulberry): handle the case where a file is referred to by more | 484 // TODO(paulberry): handle the case where a file is referred to by more |
| 485 // than one context (e.g package A depends on package B using a local | 485 // than one context (e.g package A depends on package B using a local |
| 486 // path, user has both packages open for editing in separate contexts, | 486 // path, user has both packages open for editing in separate contexts, |
| 487 // and user modifies a file in package B). | 487 // and user modifies a file in package B). |
| 488 if (analysisContext != null) { | 488 if (analysisContext != null) { |
| 489 Source source = getSource(file); | 489 Source source = getSource(file); |
| 490 switch (change.type) { | 490 if (change is AddContentOverlay) { |
| 491 case ADD: | 491 analysisContext.setContents(source, change.content); |
| 492 analysisContext.setContents(source, change.content); | 492 } else if (change is ChangeContentOverlay) { |
| 493 break; | 493 // TODO(paulberry): an error should be generated if source is not |
| 494 case CHANGE: | 494 // currently in the content cache. |
| 495 // TODO(paulberry): an error should be generated if source is not | 495 TimestampedData<String> oldContents = analysisContext.getContents( |
| 496 // currently in the content cache. | 496 source); |
| 497 TimestampedData<String> oldContents = analysisContext.getContents( | 497 String newContents = applySequence(oldContents.data, change.edits); |
| 498 source); | 498 // TODO(paulberry): to aid in incremental processing it would be |
| 499 String newContents = Edit.applySequence(oldContents.data, change.cha
nges); | 499 // better to use setChangedContents. |
| 500 // TODO(paulberry): to aid in incremental processing it would be | 500 analysisContext.setContents(source, newContents); |
| 501 // better to use setChangedContents. | 501 } else if (change is RemoveContentOverlay) { |
| 502 analysisContext.setContents(source, newContents); | 502 analysisContext.setContents(source, null); |
| 503 break; | 503 } else { |
| 504 case REMOVE: | 504 // Protocol parsing should have ensured that we never get here. |
| 505 analysisContext.setContents(source, null); | 505 throw new AnalysisException('Illegal change type'); |
| 506 break; | |
| 507 } | 506 } |
| 508 schedulePerformAnalysisOperation(analysisContext); | 507 schedulePerformAnalysisOperation(analysisContext); |
| 509 } | 508 } |
| 510 }); | 509 }); |
| 511 } | 510 } |
| 512 | 511 |
| 513 /** | 512 /** |
| 514 * Implementation for `analysis.setSubscriptions`. | 513 * Implementation for `analysis.setSubscriptions`. |
| 515 */ | 514 */ |
| 516 void setAnalysisSubscriptions(Map<AnalysisService, Set<String>> subscriptions)
{ | 515 void setAnalysisSubscriptions(Map<AnalysisService, Set<String>> subscriptions)
{ |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 Notification notification = new Notification(SERVER_ERROR); | 808 Notification notification = new Notification(SERVER_ERROR); |
| 810 notification.setParameter(FATAL, true); | 809 notification.setParameter(FATAL, true); |
| 811 notification.setParameter(MESSAGE, exceptionString); | 810 notification.setParameter(MESSAGE, exceptionString); |
| 812 notification.setParameter(STACK_TRACE, stackTraceString); | 811 notification.setParameter(STACK_TRACE, stackTraceString); |
| 813 channel.sendNotification(notification); | 812 channel.sendNotification(notification); |
| 814 } | 813 } |
| 815 } | 814 } |
| 816 | 815 |
| 817 | 816 |
| 818 typedef void OptionUpdater(AnalysisOptionsImpl options); | 817 typedef void OptionUpdater(AnalysisOptionsImpl options); |
| OLD | NEW |