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

Unified Diff: pkg/analysis_server/test/stress/utilities/server.dart

Issue 1454813002: Add server utilities for the stress test (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/stress/utilities/server.dart
diff --git a/pkg/analysis_server/test/stress/utilities/server.dart b/pkg/analysis_server/test/stress/utilities/server.dart
new file mode 100644
index 0000000000000000000000000000000000000000..76aa4cbdf5d8ccf4d13aaf22419effad293159cb
--- /dev/null
+++ b/pkg/analysis_server/test/stress/utilities/server.dart
@@ -0,0 +1,82 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library analysis_server.test.stress.utilities.server;
+
+import 'dart:async';
+import 'dart:collection';
+
+import 'package:analysis_server/plugin/protocol/protocol.dart';
+
+import '../../integration/integration_test_methods.dart';
+import '../../integration/integration_tests.dart' as base;
+
+/**
+ * An interface for starting and communicating with an analysis server running
+ * in a separate process.
+ */
+class Server extends base.Server with IntegrationTestMixin {
+ /**
+ * A list containing the paths of files for which an overlay has been created.
+ */
+ List<String> filesWithOverlays = <String>[];
+
+ /**
+ * A table mapping the absolute paths of files to the most recent set of
+ * errors received for that file.
+ */
+ Map<String, List<AnalysisError>> _errorMap =
+ new HashMap<String, List<AnalysisError>>();
+
+ /**
+ * Initialize a new analysis server. The analysis server is not running and
+ * must be started using [start].
+ */
+ Server() {
+ initializeInttestMixin();
+ onAnalysisErrors.listen(_recordErrors);
+ }
+
+ /**
+ * Return a table mapping the absolute paths of files to the most recent set
+ * of errors received for that file. The content of the map will not change
+ * when new sets of errors are received.
+ */
+ Map<String, List<AnalysisError>> get errorMap =>
+ new HashMap<String, List<AnalysisError>>.from(_errorMap);
+
+ @override
+ base.Server get server => this;
+
+ /**
+ * Remove any existing overlays.
+ */
+ Future<AnalysisUpdateContentResult> removeAllOverlays() {
+ Map<String, dynamic> files = new HashMap<String, dynamic>();
+ for (String path in filesWithOverlays) {
+ files[path] = new RemoveContentOverlay();
+ }
+ return sendAnalysisUpdateContent(files);
+ }
+
+ @override
+ Future<AnalysisUpdateContentResult> sendAnalysisUpdateContent(
+ Map<String, dynamic> files) {
+ files.forEach((String path, dynamic overlay) {
+ if (overlay is AddContentOverlay) {
+ filesWithOverlays.add(path);
+ } else if (overlay is RemoveContentOverlay) {
+ filesWithOverlays.remove(path);
+ }
+ });
+ return super.sendAnalysisUpdateContent(files);
+ }
+
+ /**
+ * Record the errors in the given [params].
+ */
+ void _recordErrors(AnalysisErrorsParams params) {
+ _errorMap[params.file] = params.errors;
+ }
+}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698