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

Side by Side Diff: pkg/analysis_server/test/analysis_abstract.dart

Issue 2382033003: Revert "Remove unused option in server API" (Closed)
Patch Set: Created 4 years, 2 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 test.domain.analysis.abstract; 5 library test.domain.analysis.abstract;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 return length; 42 return length;
43 } 43 }
44 44
45 /** 45 /**
46 * An abstract base for all 'analysis' domain tests. 46 * An abstract base for all 'analysis' domain tests.
47 */ 47 */
48 class AbstractAnalysisTest { 48 class AbstractAnalysisTest {
49 MockServerChannel serverChannel; 49 MockServerChannel serverChannel;
50 MemoryResourceProvider resourceProvider; 50 MemoryResourceProvider resourceProvider;
51 MockPackageMapProvider packageMapProvider;
51 AnalysisServer server; 52 AnalysisServer server;
52 RequestHandler handler; 53 RequestHandler handler;
53 54
54 final List<ServerErrorParams> serverErrors = <ServerErrorParams>[]; 55 final List<ServerErrorParams> serverErrors = <ServerErrorParams>[];
55 final List<GeneralAnalysisService> generalServices = 56 final List<GeneralAnalysisService> generalServices =
56 <GeneralAnalysisService>[]; 57 <GeneralAnalysisService>[];
57 final Map<AnalysisService, List<String>> analysisSubscriptions = {}; 58 final Map<AnalysisService, List<String>> analysisSubscriptions = {};
58 59
59 String projectPath = '/project'; 60 String projectPath = '/project';
60 String testFolder = '/project/bin'; 61 String testFolder = '/project/bin';
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // 122 //
122 ExtensionManager manager = new ExtensionManager(); 123 ExtensionManager manager = new ExtensionManager();
123 manager.processPlugins(plugins); 124 manager.processPlugins(plugins);
124 // 125 //
125 // Create server 126 // Create server
126 // 127 //
127 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider); 128 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
128 return new AnalysisServer( 129 return new AnalysisServer(
129 serverChannel, 130 serverChannel,
130 resourceProvider, 131 resourceProvider,
132 packageMapProvider,
131 index, 133 index,
132 serverPlugin, 134 serverPlugin,
133 new AnalysisServerOptions(), 135 new AnalysisServerOptions(),
134 new DartSdkManager('/', false, (_) => sdk), 136 new DartSdkManager('/', false, (_) => sdk),
135 InstrumentationService.NULL_SERVICE); 137 InstrumentationService.NULL_SERVICE);
136 } 138 }
137 139
138 Index createIndex() { 140 Index createIndex() {
139 return null; 141 return null;
140 } 142 }
141 143
142 /** 144 /**
143 * Creates a project `/project`. 145 * Creates a project `/project`.
144 */ 146 */
145 void createProject({Map<String, String> packageRoots}) { 147 void createProject({Map<String, String> packageRoots}) {
146 resourceProvider.newFolder(projectPath); 148 resourceProvider.newFolder(projectPath);
147 Request request = new AnalysisSetAnalysisRootsParams([projectPath], [], 149 Request request =
148 packageRoots: packageRoots) 150 new AnalysisSetAnalysisRootsParams([projectPath], [], packageRoots: pack ageRoots).toRequest('0');
149 .toRequest('0');
150 handleSuccessfulRequest(request, handler: analysisHandler); 151 handleSuccessfulRequest(request, handler: analysisHandler);
151 } 152 }
152 153
153 /** 154 /**
154 * Returns the offset of [search] in [testCode]. 155 * Returns the offset of [search] in [testCode].
155 * Fails if not found. 156 * Fails if not found.
156 */ 157 */
157 int findFileOffset(String path, String search) { 158 int findFileOffset(String path, String search) {
158 File file = resourceProvider.getResource(path) as File; 159 File file = resourceProvider.getResource(path) as File;
159 String code = file.createSource().contents.data; 160 String code = file.createSource().contents.data;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void removeGeneralAnalysisSubscription(GeneralAnalysisService service) { 199 void removeGeneralAnalysisSubscription(GeneralAnalysisService service) {
199 generalServices.remove(service); 200 generalServices.remove(service);
200 Request request = new AnalysisSetGeneralSubscriptionsParams(generalServices) 201 Request request = new AnalysisSetGeneralSubscriptionsParams(generalServices)
201 .toRequest('0'); 202 .toRequest('0');
202 handleSuccessfulRequest(request); 203 handleSuccessfulRequest(request);
203 } 204 }
204 205
205 void setUp() { 206 void setUp() {
206 serverChannel = new MockServerChannel(); 207 serverChannel = new MockServerChannel();
207 resourceProvider = new MemoryResourceProvider(); 208 resourceProvider = new MemoryResourceProvider();
209 packageMapProvider = new MockPackageMapProvider();
208 Index index = createIndex(); 210 Index index = createIndex();
209 server = createAnalysisServer(index); 211 server = createAnalysisServer(index);
210 handler = analysisHandler; 212 handler = analysisHandler;
211 // listen for notifications 213 // listen for notifications
212 Stream<Notification> notificationStream = 214 Stream<Notification> notificationStream =
213 serverChannel.notificationController.stream; 215 serverChannel.notificationController.stream;
214 notificationStream.listen((Notification notification) { 216 notificationStream.listen((Notification notification) {
215 processNotification(notification); 217 processNotification(notification);
216 }); 218 });
217 } 219 }
(...skipping 14 matching lines...) Expand all
232 } 234 }
233 235
234 /** 236 /**
235 * Completes with a successful [Response] for the given [request]. 237 * Completes with a successful [Response] for the given [request].
236 * Otherwise fails. 238 * Otherwise fails.
237 */ 239 */
238 Future<Response> waitResponse(Request request) async { 240 Future<Response> waitResponse(Request request) async {
239 return serverChannel.sendRequest(request); 241 return serverChannel.sendRequest(request);
240 } 242 }
241 } 243 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698