| 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 import 'dart:math' show max; | 9 import 'dart:math' show max; |
| 10 | 10 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 /** | 328 /** |
| 329 * There was an error related to the socket from which requests are being | 329 * There was an error related to the socket from which requests are being |
| 330 * read. | 330 * read. |
| 331 */ | 331 */ |
| 332 void error(argument) { | 332 void error(argument) { |
| 333 running = false; | 333 running = false; |
| 334 } | 334 } |
| 335 | 335 |
| 336 /** | 336 /** |
| 337 * Performs all scheduled analysis operations. |
| 338 */ |
| 339 void test_performAllAnalysisOperations() { |
| 340 while (true) { |
| 341 ServerOperation operation = operationQueue.takeIf((operation) { |
| 342 return operation is PerformAnalysisOperation; |
| 343 }); |
| 344 if (operation == null) { |
| 345 break; |
| 346 } |
| 347 operation.perform(this); |
| 348 } |
| 349 } |
| 350 |
| 351 /** |
| 337 * If the given notice applies to a file contained within an analysis root, | 352 * If the given notice applies to a file contained within an analysis root, |
| 338 * notify interested parties that the file has been (at least partially) | 353 * notify interested parties that the file has been (at least partially) |
| 339 * analyzed. | 354 * analyzed. |
| 340 */ | 355 */ |
| 341 void fileAnalyzed(ChangeNotice notice) { | 356 void fileAnalyzed(ChangeNotice notice) { |
| 342 if (contextDirectoryManager.isInAnalysisRoot(notice.source.fullName)) { | 357 if (contextDirectoryManager.isInAnalysisRoot(notice.source.fullName)) { |
| 343 _onFileAnalyzedController.add(notice); | 358 _onFileAnalyzedController.add(notice); |
| 344 } | 359 } |
| 345 } | 360 } |
| 346 | 361 |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 dartEntry.flushAstStructures(); | 955 dartEntry.flushAstStructures(); |
| 941 } | 956 } |
| 942 } | 957 } |
| 943 | 958 |
| 944 /** | 959 /** |
| 945 * Implementation for `analysis.updateContent`. | 960 * Implementation for `analysis.updateContent`. |
| 946 */ | 961 */ |
| 947 void updateContent(String id, Map<String, dynamic> changes) { | 962 void updateContent(String id, Map<String, dynamic> changes) { |
| 948 changes.forEach((file, change) { | 963 changes.forEach((file, change) { |
| 949 Source source = getSource(file); | 964 Source source = getSource(file); |
| 965 operationQueue.sourceAboutToChange(source); |
| 966 // Prepare the new contents. |
| 950 String oldContents = _overlayState.getContents(source); | 967 String oldContents = _overlayState.getContents(source); |
| 951 String newContents; | 968 String newContents; |
| 952 if (change is AddContentOverlay) { | 969 if (change is AddContentOverlay) { |
| 953 newContents = change.content; | 970 newContents = change.content; |
| 954 } else if (change is ChangeContentOverlay) { | 971 } else if (change is ChangeContentOverlay) { |
| 955 if (oldContents == null) { | 972 if (oldContents == null) { |
| 956 // The client may only send a ChangeContentOverlay if there is | 973 // The client may only send a ChangeContentOverlay if there is |
| 957 // already an existing overlay for the source. | 974 // already an existing overlay for the source. |
| 958 throw new RequestFailure( | 975 throw new RequestFailure( |
| 959 new Response( | 976 new Response( |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 new DateTime.now().millisecondsSinceEpoch - | 1278 new DateTime.now().millisecondsSinceEpoch - |
| 1262 request.clientRequestTime; | 1279 request.clientRequestTime; |
| 1263 requestLatency += latency; | 1280 requestLatency += latency; |
| 1264 maxLatency = max(maxLatency, latency); | 1281 maxLatency = max(maxLatency, latency); |
| 1265 if (latency > 150) { | 1282 if (latency > 150) { |
| 1266 ++slowRequestCount; | 1283 ++slowRequestCount; |
| 1267 } | 1284 } |
| 1268 } | 1285 } |
| 1269 } | 1286 } |
| 1270 } | 1287 } |
| OLD | NEW |