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

Side by Side Diff: pkg/analysis_server/lib/src/operation/operation_analysis.dart

Issue 1233003002: Only send "analysis.analyzedFiles" notification when the set of files changes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
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 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_navigation.dart'; 9 import 'package:analysis_server/src/computer/computer_navigation.dart';
10 import 'package:analysis_server/src/computer/computer_occurrences.dart'; 10 import 'package:analysis_server/src/computer/computer_occurrences.dart';
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 // errors 95 // errors
96 if (server.shouldSendErrorsNotificationFor(file)) { 96 if (server.shouldSendErrorsNotificationFor(file)) {
97 server.scheduleOperation( 97 server.scheduleOperation(
98 new _NotificationErrorsOperation(context, file, lineInfo, errors)); 98 new _NotificationErrorsOperation(context, file, lineInfo, errors));
99 } 99 }
100 } 100 }
101 101
102 void sendAnalysisNotificationAnalyzedFiles(AnalysisServer server) { 102 void sendAnalysisNotificationAnalyzedFiles(AnalysisServer server) {
103 _sendNotification(server, () { 103 _sendNotification(server, () {
104 // TODO(paulberry): if it proves to be too inefficient to recompute the set
105 // of analyzed files each time analysis is complete, consider modifying the
106 // analysis engine to update this set incrementally as analysis is
107 // performed.
104 LibraryDependencyCollector collector = 108 LibraryDependencyCollector collector =
105 new LibraryDependencyCollector(server.getAnalysisContexts().toList()); 109 new LibraryDependencyCollector(server.getAnalysisContexts().toList());
106 Set<String> directories = collector.collectLibraryDependencies(); 110 Set<String> analyzedFiles = collector.collectLibraryDependencies();
111 Set<String> prevAnalyzedFiles = server.prevAnalyzedFiles;
112 if (prevAnalyzedFiles != null &&
113 prevAnalyzedFiles.length == analyzedFiles.length &&
114 prevAnalyzedFiles.difference(analyzedFiles).isEmpty) {
115 // No change to the set of analyzed files. No need to send another
116 // notification.
117 return;
118 }
119 server.prevAnalyzedFiles = analyzedFiles;
107 protocol.AnalysisAnalyzedFilesParams params = 120 protocol.AnalysisAnalyzedFilesParams params =
108 new protocol.AnalysisAnalyzedFilesParams(directories.toList()); 121 new protocol.AnalysisAnalyzedFilesParams(analyzedFiles.toList());
109 server.sendNotification(params.toNotification()); 122 server.sendNotification(params.toNotification());
110 }); 123 });
111 } 124 }
112 125
113 void sendAnalysisNotificationErrors(AnalysisServer server, String file, 126 void sendAnalysisNotificationErrors(AnalysisServer server, String file,
114 LineInfo lineInfo, List<AnalysisError> errors) { 127 LineInfo lineInfo, List<AnalysisError> errors) {
115 _sendNotification(server, () { 128 _sendNotification(server, () {
116 if (errors == null) { 129 if (errors == null) {
117 errors = <AnalysisError>[]; 130 errors = <AnalysisError>[];
118 } 131 }
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 abstract class _SingleFileOperation extends SourceSensitiveOperation { 466 abstract class _SingleFileOperation extends SourceSensitiveOperation {
454 final String file; 467 final String file;
455 468
456 _SingleFileOperation(AnalysisContext context, this.file) : super(context); 469 _SingleFileOperation(AnalysisContext context, this.file) : super(context);
457 470
458 @override 471 @override
459 bool shouldBeDiscardedOnSourceChange(Source source) { 472 bool shouldBeDiscardedOnSourceChange(Source source) {
460 return source.fullName == file; 473 return source.fullName == file;
461 } 474 }
462 } 475 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698