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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4
5 library analysis_server.test.stress.utilities.server;
6
7 import 'dart:async';
8 import 'dart:collection';
9
10 import 'package:analysis_server/plugin/protocol/protocol.dart';
11
12 import '../../integration/integration_test_methods.dart';
13 import '../../integration/integration_tests.dart' as base;
14
15 /**
16 * An interface for starting and communicating with an analysis server running
17 * in a separate process.
18 */
19 class Server extends base.Server with IntegrationTestMixin {
20 /**
21 * A list containing the paths of files for which an overlay has been created.
22 */
23 List<String> filesWithOverlays = <String>[];
24
25 /**
26 * A table mapping the absolute paths of files to the most recent set of
27 * errors received for that file.
28 */
29 Map<String, List<AnalysisError>> _errorMap =
30 new HashMap<String, List<AnalysisError>>();
31
32 /**
33 * Initialize a new analysis server. The analysis server is not running and
34 * must be started using [start].
35 */
36 Server() {
37 initializeInttestMixin();
38 onAnalysisErrors.listen(_recordErrors);
39 }
40
41 /**
42 * Return a table mapping the absolute paths of files to the most recent set
43 * of errors received for that file. The content of the map will not change
44 * when new sets of errors are received.
45 */
46 Map<String, List<AnalysisError>> get errorMap =>
47 new HashMap<String, List<AnalysisError>>.from(_errorMap);
48
49 @override
50 base.Server get server => this;
51
52 /**
53 * Remove any existing overlays.
54 */
55 Future<AnalysisUpdateContentResult> removeAllOverlays() {
56 Map<String, dynamic> files = new HashMap<String, dynamic>();
57 for (String path in filesWithOverlays) {
58 files[path] = new RemoveContentOverlay();
59 }
60 return sendAnalysisUpdateContent(files);
61 }
62
63 @override
64 Future<AnalysisUpdateContentResult> sendAnalysisUpdateContent(
65 Map<String, dynamic> files) {
66 files.forEach((String path, dynamic overlay) {
67 if (overlay is AddContentOverlay) {
68 filesWithOverlays.add(path);
69 } else if (overlay is RemoveContentOverlay) {
70 filesWithOverlays.remove(path);
71 }
72 });
73 return super.sendAnalysisUpdateContent(files);
74 }
75
76 /**
77 * Record the errors in the given [params].
78 */
79 void _recordErrors(AnalysisErrorsParams params) {
80 _errorMap[params.file] = params.errors;
81 }
82 }
OLDNEW
« 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