| 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'; |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 AnalysisContext analysisContext = getAnalysisContext(file); | 476 AnalysisContext analysisContext = getAnalysisContext(file); |
| 477 // TODO(paulberry): handle the case where a file is referred to by more | 477 // TODO(paulberry): handle the case where a file is referred to by more |
| 478 // than one context (e.g package A depends on package B using a local | 478 // than one context (e.g package A depends on package B using a local |
| 479 // path, user has both packages open for editing in separate contexts, | 479 // path, user has both packages open for editing in separate contexts, |
| 480 // and user modifies a file in package B). | 480 // and user modifies a file in package B). |
| 481 if (analysisContext != null) { | 481 if (analysisContext != null) { |
| 482 Source source = getSource(file); | 482 Source source = getSource(file); |
| 483 if (change.offset == null) { | 483 if (change.offset == null) { |
| 484 analysisContext.setContents(source, change.content); | 484 analysisContext.setContents(source, change.content); |
| 485 } else { | 485 } else { |
| 486 analysisContext.setChangedContents(source, change.content, | 486 // TODO(paulberry): an error should be generated if source is not |
| 487 change.offset, change.oldLength, change.newLength); | 487 // currently in the content cache. |
| 488 TimestampedData<String> oldContents = analysisContext.getContents( |
| 489 source); |
| 490 int offsetEnd = change.offset + change.oldLength; |
| 491 String newContents = oldContents.data.substring(0, change.offset) + |
| 492 change.content + oldContents.data.substring(offsetEnd); |
| 493 analysisContext.setChangedContents(source, newContents, change.offset, |
| 494 change.oldLength, change.content.length); |
| 488 } | 495 } |
| 489 schedulePerformAnalysisOperation(analysisContext); | 496 schedulePerformAnalysisOperation(analysisContext); |
| 490 } | 497 } |
| 491 }); | 498 }); |
| 492 } | 499 } |
| 493 | 500 |
| 494 /** | 501 /** |
| 495 * Implementation for `analysis.setSubscriptions`. | 502 * Implementation for `analysis.setSubscriptions`. |
| 496 */ | 503 */ |
| 497 void setAnalysisSubscriptions(Map<AnalysisService, Set<String>> subscriptions)
{ | 504 void setAnalysisSubscriptions(Map<AnalysisService, Set<String>> subscriptions)
{ |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 /** | 822 /** |
| 816 * An enumeration of the services provided by the server domain. | 823 * An enumeration of the services provided by the server domain. |
| 817 */ | 824 */ |
| 818 class ServerService extends Enum2<ServerService> { | 825 class ServerService extends Enum2<ServerService> { |
| 819 static const ServerService STATUS = const ServerService('STATUS', 0); | 826 static const ServerService STATUS = const ServerService('STATUS', 0); |
| 820 | 827 |
| 821 static const List<ServerService> VALUES = const [STATUS]; | 828 static const List<ServerService> VALUES = const [STATUS]; |
| 822 | 829 |
| 823 const ServerService(String name, int ordinal) : super(name, ordinal); | 830 const ServerService(String name, int ordinal) : super(name, ordinal); |
| 824 } | 831 } |
| OLD | NEW |