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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/domain_analysis.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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'; 15 import 'package:analysis_server/src/domain_analysis.dart';
16 import 'package:analysis_server/src/operation/operation_analysis.dart'; 16 import 'package:analysis_server/src/operation/operation_analysis.dart';
17 import 'package:analysis_server/src/operation/operation.dart'; 17 import 'package:analysis_server/src/operation/operation.dart';
18 import 'package:analysis_server/src/operation/operation_queue.dart'; 18 import 'package:analysis_server/src/operation/operation_queue.dart';
19 import 'package:analysis_server/src/package_map_provider.dart'; 19 import 'package:analysis_server/src/package_map_provider.dart';
20 import 'package:analysis_server/src/protocol.dart'; 20 import 'package:analysis_server/src/protocol.dart';
21 import 'package:analyzer/source/package_map_resolver.dart'; 21 import 'package:analyzer/source/package_map_resolver.dart';
22 import 'package:analyzer/src/generated/ast.dart'; 22 import 'package:analyzer/src/generated/ast.dart';
23 import 'package:analyzer/src/generated/engine.dart'; 23 import 'package:analyzer/src/generated/engine.dart';
24 import 'package:analyzer/src/generated/source.dart'; 24 import 'package:analyzer/src/generated/source.dart';
25 import 'package:analyzer/src/generated/sdk.dart'; 25 import 'package:analyzer/src/generated/sdk.dart';
26 import 'package:analyzer/src/generated/source_io.dart'; 26 import 'package:analyzer/src/generated/source_io.dart';
27 import 'package:analyzer/src/generated/java_engine.dart'; 27 import 'package:analyzer/src/generated/java_engine.dart';
28 import 'package:analysis_services/constants.dart'; 28 import 'package:analysis_services/constants.dart';
29 import 'package:analysis_services/correction/change.dart';
29 import 'package:analysis_services/index/index.dart'; 30 import 'package:analysis_services/index/index.dart';
30 import 'package:analysis_services/search/search_engine.dart'; 31 import 'package:analysis_services/search/search_engine.dart';
31 import 'package:analyzer/src/generated/element.dart'; 32 import 'package:analyzer/src/generated/element.dart';
32 33
33 34
34 class ServerContextManager extends ContextManager { 35 class ServerContextManager extends ContextManager {
35 final AnalysisServer analysisServer; 36 final AnalysisServer analysisServer;
36 37
37 /** 38 /**
38 * The default options used to create new analysis contexts. 39 * The default options used to create new analysis contexts.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 */ 478 */
478 void updateContent(Map<String, ContentChange> changes) { 479 void updateContent(Map<String, ContentChange> changes) {
479 changes.forEach((file, change) { 480 changes.forEach((file, change) {
480 AnalysisContext analysisContext = getAnalysisContext(file); 481 AnalysisContext analysisContext = getAnalysisContext(file);
481 // TODO(paulberry): handle the case where a file is referred to by more 482 // TODO(paulberry): handle the case where a file is referred to by more
482 // than one context (e.g package A depends on package B using a local 483 // than one context (e.g package A depends on package B using a local
483 // path, user has both packages open for editing in separate contexts, 484 // path, user has both packages open for editing in separate contexts,
484 // and user modifies a file in package B). 485 // and user modifies a file in package B).
485 if (analysisContext != null) { 486 if (analysisContext != null) {
486 Source source = getSource(file); 487 Source source = getSource(file);
487 if (change.offset == null) { 488 switch (change.type) {
488 analysisContext.setContents(source, change.contentOrReplacement); 489 case ADD:
489 } else { 490 analysisContext.setContents(source, change.content);
490 // TODO(paulberry): an error should be generated if source is not 491 break;
491 // currently in the content cache. 492 case CHANGE:
492 TimestampedData<String> oldContents = analysisContext.getContents( 493 // TODO(paulberry): an error should be generated if source is not
493 source); 494 // currently in the content cache.
494 int offsetEnd = change.offset + change.length; 495 TimestampedData<String> oldContents = analysisContext.getContents(
495 String newContents = oldContents.data.substring(0, change.offset) + 496 source);
496 change.contentOrReplacement + oldContents.data.substring(offsetEnd ); 497 String newContents = Edit.applySequence(oldContents.data, change.cha nges);
497 analysisContext.setChangedContents(source, newContents, change.offset, 498 // TODO(paulberry): to aid in incremental processing it would be
498 change.length, change.contentOrReplacement.length); 499 // better to use setChangedContents.
500 analysisContext.setContents(source, newContents);
501 break;
502 case REMOVE:
503 analysisContext.setContents(source, null);
504 break;
499 } 505 }
500 schedulePerformAnalysisOperation(analysisContext); 506 schedulePerformAnalysisOperation(analysisContext);
501 } 507 }
502 }); 508 });
503 } 509 }
504 510
505 /** 511 /**
506 * Implementation for `analysis.setSubscriptions`. 512 * Implementation for `analysis.setSubscriptions`.
507 */ 513 */
508 void setAnalysisSubscriptions(Map<AnalysisService, Set<String>> subscriptions) { 514 void setAnalysisSubscriptions(Map<AnalysisService, Set<String>> subscriptions) {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 /** 832 /**
827 * An enumeration of the services provided by the server domain. 833 * An enumeration of the services provided by the server domain.
828 */ 834 */
829 class ServerService extends Enum2<ServerService> { 835 class ServerService extends Enum2<ServerService> {
830 static const ServerService STATUS = const ServerService('STATUS', 0); 836 static const ServerService STATUS = const ServerService('STATUS', 0);
831 837
832 static const List<ServerService> VALUES = const [STATUS]; 838 static const List<ServerService> VALUES = const [STATUS];
833 839
834 const ServerService(String name, int ordinal) : super(name, ordinal); 840 const ServerService(String name, int ordinal) : super(name, ordinal);
835 } 841 }
OLDNEW
« 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