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

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

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

Powered by Google App Engine
This is Rietveld 408576698