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

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

Issue 346963006: Index Dart/HTML units after analysis. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/index/store/split_store_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 mocks; 5 library mocks;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 @MirrorsUsed(targets: 'mocks', override: '*') 10 @MirrorsUsed(targets: 'mocks', override: '*')
11 import 'dart:mirrors'; 11 import 'dart:mirrors';
12 12
13 import 'package:analysis_server/src/analysis_server.dart'; 13 import 'package:analysis_server/src/analysis_server.dart';
14 import 'package:analysis_server/src/channel.dart'; 14 import 'package:analysis_server/src/channel.dart';
15 import 'package:analysis_server/src/operation/operation_analysis.dart'; 15 import 'package:analysis_server/src/operation/operation_analysis.dart';
16 import 'package:analysis_server/src/operation/operation.dart'; 16 import 'package:analysis_server/src/operation/operation.dart';
17 import 'package:analysis_server/src/package_map_provider.dart'; 17 import 'package:analysis_server/src/package_map_provider.dart';
18 import 'package:analysis_server/src/protocol.dart'; 18 import 'package:analysis_server/src/protocol.dart';
19 import 'package:analysis_server/src/resource.dart' as resource; 19 import 'package:analysis_server/src/resource.dart' as resource;
20 import 'package:analyzer/src/generated/engine.dart'; 20 import 'package:analyzer/src/generated/engine.dart';
21 import 'package:analyzer/src/generated/sdk.dart'; 21 import 'package:analyzer/src/generated/sdk.dart';
22 import 'package:analyzer/src/generated/source.dart'; 22 import 'package:analyzer/src/generated/source.dart';
23 import 'package:matcher/matcher.dart'; 23 import 'package:matcher/matcher.dart';
24 import 'package:mock/mock.dart'; 24 import 'package:mock/mock.dart';
25 import 'package:unittest/unittest.dart'; 25 import 'package:unittest/unittest.dart';
26 import 'package:analyzer/src/generated/index.dart';
26 27
27 /** 28 /**
28 * Answer the absolute path the the SDK relative to the currently running 29 * Answer the absolute path the the SDK relative to the currently running
29 * script or throw an exception if it cannot be found. 30 * script or throw an exception if it cannot be found.
30 */ 31 */
31 String get sdkPath { 32 String get sdkPath {
32 Uri sdkUri = Platform.script.resolve('../../../sdk/'); 33 Uri sdkUri = Platform.script.resolve('../../../sdk/');
33 34
34 // Verify the directory exists 35 // Verify the directory exists
35 Directory sdkDir = new Directory.fromUri(sdkUri); 36 Directory sdkDir = new Directory.fromUri(sdkUri);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 208
208 @override 209 @override
209 AnalysisContext get context => null; 210 AnalysisContext get context => null;
210 211
211 @override 212 @override
212 bool get isContinue => false; 213 bool get isContinue => false;
213 214
214 @override 215 @override
215 void sendNotices(AnalysisServer server, List<ChangeNotice> notices) { 216 void sendNotices(AnalysisServer server, List<ChangeNotice> notices) {
216 } 217 }
218
219 @override
220 void updateIndex(Index index, List<ChangeNotice> notices) {
221 }
217 } 222 }
218 223
219 224
220 /** 225 /**
221 * A [Matcher] that check that the given [Response] has an expected identifier 226 * A [Matcher] that check that the given [Response] has an expected identifier
222 * and no error. 227 * and no error.
223 */ 228 */
224 Matcher isResponseSuccess(String id) => new _IsResponseSuccess(id); 229 Matcher isResponseSuccess(String id) => new _IsResponseSuccess(id);
225 230
226 /** 231 /**
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 return mismatchDescription; 302 return mismatchDescription;
298 } 303 }
299 } 304 }
300 305
301 class MockSdk implements DartSdk { 306 class MockSdk implements DartSdk {
302 307
303 final resource.MemoryResourceProvider provider = new resource.MemoryResourcePr ovider(); 308 final resource.MemoryResourceProvider provider = new resource.MemoryResourcePr ovider();
304 309
305 MockSdk() { 310 MockSdk() {
306 // TODO(paulberry): Add to this as needed. 311 // TODO(paulberry): Add to this as needed.
307 const Map<String, String> pathToSource = const { 312 const Map<String, String> pathToContent = const {
308 "/lib/core/core.dart": ''' 313 "/lib/core/core.dart": '''
309 library dart.core; 314 library dart.core;
310 class Object {} 315 class Object {}
311 class Function {} 316 class Function {}
312 class StackTrace {} 317 class StackTrace {}
313 class Symbol {} 318 class Symbol {}
314 class Type {} 319 class Type {}
315 320
316 class String extends Object {} 321 class String extends Object {}
317 class bool extends Object {} 322 class bool extends Object {}
(...skipping 29 matching lines...) Expand all
347 "/lib/html/dartium/html_dartium.dart": ''' 352 "/lib/html/dartium/html_dartium.dart": '''
348 library dart.html; 353 library dart.html;
349 class HtmlElement {} 354 class HtmlElement {}
350 ''', 355 ''',
351 356
352 "/lib/math/math.dart": ''' 357 "/lib/math/math.dart": '''
353 library dart.math; 358 library dart.math;
354 ''' 359 '''
355 }; 360 };
356 361
357 pathToSource.forEach((String path, String source) { 362 pathToContent.forEach((String path, String content) {
358 provider.newFile(path, source); 363 provider.newFile(path, content);
359 }); 364 });
360 } 365 }
361 366
362 // Not used 367 // Not used
363 @override 368 @override
364 AnalysisContext get context => throw unimplemented; 369 AnalysisContext get context => throw unimplemented;
365 370
366 @override 371 @override
367 Source fromEncoding(UriKind kind, Uri uri) { 372 Source fromEncoding(UriKind kind, Uri uri) {
368 // Not used 373 resource.Resource file = provider.getResource(uri.path);
369 throw unimplemented; 374 if (file is resource.File) {
375 return file.createSource(kind);
376 }
377 return null;
370 } 378 }
371 379
372 UnimplementedError get unimplemented => new UnimplementedError(); 380 UnimplementedError get unimplemented => new UnimplementedError();
373 381
374 @override 382 @override
375 SdkLibrary getSdkLibrary(String dartUri) { 383 SdkLibrary getSdkLibrary(String dartUri) {
376 // getSdkLibrary() is only used to determine whether a library is internal 384 // getSdkLibrary() is only used to determine whether a library is internal
377 // to the SDK. The mock SDK doesn't have any internals, so it's safe to 385 // to the SDK. The mock SDK doesn't have any internals, so it's safe to
378 // return null. 386 // return null.
379 return null; 387 return null;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 * A mock [PackageMapProvider]. 423 * A mock [PackageMapProvider].
416 */ 424 */
417 class MockPackageMapProvider implements PackageMapProvider { 425 class MockPackageMapProvider implements PackageMapProvider {
418 Map<String, List<resource.Folder>> packageMap = <String, List<resource.Folder> >{}; 426 Map<String, List<resource.Folder>> packageMap = <String, List<resource.Folder> >{};
419 427
420 @override 428 @override
421 Map<String, List<resource.Folder>> computePackageMap(resource.Folder folder) { 429 Map<String, List<resource.Folder>> computePackageMap(resource.Folder folder) {
422 return packageMap; 430 return packageMap;
423 } 431 }
424 } 432 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/index/store/split_store_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698