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

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

Issue 1303343008: Extension point for AnalysisResultListener(s). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Replace with SetAnalysisDomain() function. Created 5 years, 3 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/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
11 import 'package:analysis_server/src/domain_analysis.dart'; 11 import 'package:analysis_server/src/domain_analysis.dart';
12 import 'package:analysis_server/src/plugin/server_plugin.dart'; 12 import 'package:analysis_server/src/plugin/server_plugin.dart';
13 import 'package:analysis_server/src/protocol.dart'; 13 import 'package:analysis_server/src/protocol.dart';
14 import 'package:analysis_server/src/services/index/index.dart'; 14 import 'package:analysis_server/src/services/index/index.dart';
15 import 'package:analyzer/file_system/file_system.dart'; 15 import 'package:analyzer/file_system/file_system.dart';
16 import 'package:analyzer/file_system/memory_file_system.dart'; 16 import 'package:analyzer/file_system/memory_file_system.dart';
17 import 'package:analyzer/instrumentation/instrumentation.dart'; 17 import 'package:analyzer/instrumentation/instrumentation.dart';
18 import 'package:plugin/manager.dart'; 18 import 'package:plugin/manager.dart';
19 import 'package:plugin/plugin.dart';
19 import 'package:unittest/unittest.dart'; 20 import 'package:unittest/unittest.dart';
20 21
21 import 'mock_sdk.dart'; 22 import 'mock_sdk.dart';
22 import 'mocks.dart'; 23 import 'mocks.dart';
23 24
24 int findIdentifierLength(String search) { 25 int findIdentifierLength(String search) {
25 int length = 0; 26 int length = 0;
26 while (length < search.length) { 27 while (length < search.length) {
27 int c = search.codeUnitAt(length); 28 int c = search.codeUnitAt(length);
28 if (!(c >= 'a'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0) || 29 if (!(c >= 'a'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0) ||
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return path; 77 return path;
77 } 78 }
78 79
79 void addGeneralAnalysisSubscription(GeneralAnalysisService service) { 80 void addGeneralAnalysisSubscription(GeneralAnalysisService service) {
80 generalServices.add(service); 81 generalServices.add(service);
81 Request request = new AnalysisSetGeneralSubscriptionsParams(generalServices) 82 Request request = new AnalysisSetGeneralSubscriptionsParams(generalServices)
82 .toRequest('0'); 83 .toRequest('0');
83 handleSuccessfulRequest(request); 84 handleSuccessfulRequest(request);
84 } 85 }
85 86
87 void addServerPlugins(List<Plugin> plugins) {}
88
86 String addTestFile(String content) { 89 String addTestFile(String content) {
87 addFile(testFile, content); 90 addFile(testFile, content);
88 this.testCode = content; 91 this.testCode = content;
89 return testFile; 92 return testFile;
90 } 93 }
91 94
92 AnalysisServer createAnalysisServer(Index index) { 95 AnalysisServer createAnalysisServer(Index index) {
96 ServerPlugin serverPlugin = new ServerPlugin();
97 List<Plugin> plugins = <Plugin>[serverPlugin];
98 addServerPlugins(plugins);
99 // process plugins
93 ExtensionManager manager = new ExtensionManager(); 100 ExtensionManager manager = new ExtensionManager();
94 ServerPlugin serverPlugin = new ServerPlugin(); 101 manager.processPlugins(plugins);
95 manager.processPlugins([serverPlugin]); 102 // create server
96 return new AnalysisServer(serverChannel, resourceProvider, 103 return new AnalysisServer(
97 packageMapProvider, index, serverPlugin, new AnalysisServerOptions(), 104 serverChannel,
98 new MockSdk(), InstrumentationService.NULL_SERVICE); 105 resourceProvider,
106 packageMapProvider,
107 index,
108 serverPlugin,
109 new AnalysisServerOptions(),
110 new MockSdk(),
111 InstrumentationService.NULL_SERVICE);
99 } 112 }
100 113
101 Index createIndex() { 114 Index createIndex() {
102 return null; 115 return null;
103 } 116 }
104 117
105 /** 118 /**
106 * Creates a project `/project`. 119 * Creates a project `/project`.
107 */ 120 */
108 void createProject() { 121 void createProject() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 .toRequest('0'); 175 .toRequest('0');
163 handleSuccessfulRequest(request); 176 handleSuccessfulRequest(request);
164 } 177 }
165 178
166 void setUp() { 179 void setUp() {
167 serverChannel = new MockServerChannel(); 180 serverChannel = new MockServerChannel();
168 resourceProvider = new MemoryResourceProvider(); 181 resourceProvider = new MemoryResourceProvider();
169 packageMapProvider = new MockPackageMapProvider(); 182 packageMapProvider = new MockPackageMapProvider();
170 Index index = createIndex(); 183 Index index = createIndex();
171 server = createAnalysisServer(index); 184 server = createAnalysisServer(index);
172 handler = new AnalysisDomainHandler(server); 185 handler = server.handlers.singleWhere((_) => _ is AnalysisDomainHandler);
Brian Wilkerson 2015/09/04 16:54:31 I think the standard convention is to use '_' only
173 // listen for notifications 186 // listen for notifications
174 Stream<Notification> notificationStream = 187 Stream<Notification> notificationStream =
175 serverChannel.notificationController.stream; 188 serverChannel.notificationController.stream;
176 notificationStream.listen((Notification notification) { 189 notificationStream.listen((Notification notification) {
177 processNotification(notification); 190 processNotification(notification);
178 }); 191 });
179 } 192 }
180 193
181 void tearDown() { 194 void tearDown() {
182 server.done(); 195 server.done();
(...skipping 11 matching lines...) Expand all
194 } 207 }
195 208
196 /** 209 /**
197 * Completes with a successful [Response] for the given [request]. 210 * Completes with a successful [Response] for the given [request].
198 * Otherwise fails. 211 * Otherwise fails.
199 */ 212 */
200 Future<Response> waitResponse(Request request) async { 213 Future<Response> waitResponse(Request request) async {
201 return serverChannel.sendRequest(request); 214 return serverChannel.sendRequest(request);
202 } 215 }
203 } 216 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/plugin/server_plugin.dart ('k') | pkg/analysis_server/test/plugin/set_analysis_domain_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698