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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 472613002: Update analysis server and integration tests to match new ChangeContentOverlay. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/domain_analysis.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 4264fec049b412116bb304f90ae513f35fa08bbd..8c092db7592f449ab7d89268d15417d67f81333e 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -26,6 +26,7 @@ import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analysis_services/constants.dart';
+import 'package:analysis_services/correction/change.dart';
import 'package:analysis_services/index/index.dart';
import 'package:analysis_services/search/search_engine.dart';
import 'package:analyzer/src/generated/element.dart';
@@ -484,18 +485,23 @@ class AnalysisServer {
// and user modifies a file in package B).
if (analysisContext != null) {
Source source = getSource(file);
- if (change.offset == null) {
- analysisContext.setContents(source, change.contentOrReplacement);
- } else {
- // TODO(paulberry): an error should be generated if source is not
- // currently in the content cache.
- TimestampedData<String> oldContents = analysisContext.getContents(
- source);
- int offsetEnd = change.offset + change.length;
- String newContents = oldContents.data.substring(0, change.offset) +
- change.contentOrReplacement + oldContents.data.substring(offsetEnd);
- analysisContext.setChangedContents(source, newContents, change.offset,
- change.length, change.contentOrReplacement.length);
+ switch (change.type) {
+ case ADD:
+ analysisContext.setContents(source, change.content);
+ break;
+ case CHANGE:
+ // TODO(paulberry): an error should be generated if source is not
+ // currently in the content cache.
+ TimestampedData<String> oldContents = analysisContext.getContents(
+ source);
+ String newContents = Edit.applySequence(oldContents.data, change.changes);
+ // TODO(paulberry): to aid in incremental processing it would be
+ // better to use setChangedContents.
+ analysisContext.setContents(source, newContents);
+ break;
+ case REMOVE:
+ analysisContext.setContents(source, null);
+ break;
}
schedulePerformAnalysisOperation(analysisContext);
}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/domain_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698