Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.index; | 5 library test.index; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io' show Directory; | 8 import 'dart:io' show Directory; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/index/index.dart'; | 10 import 'package:analysis_server/src/index/index.dart'; |
| 11 import 'package:analysis_server/src/resource.dart'; | 11 import 'package:analysis_server/src/resource.dart'; |
| 12 import 'package:analyzer/src/generated/ast.dart'; | 12 import 'package:analyzer/src/generated/ast.dart'; |
| 13 import 'package:analyzer/src/generated/element.dart'; | 13 import 'package:analyzer/src/generated/element.dart'; |
| 14 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
| 15 import 'package:analyzer/src/generated/html.dart'; | 15 import 'package:analyzer/src/generated/html.dart'; |
| 16 import 'package:analyzer/src/generated/index.dart'; | 16 import 'package:analyzer/src/generated/index.dart'; |
| 17 import 'package:analyzer/src/generated/sdk.dart'; | 17 import 'package:analyzer/src/generated/sdk.dart'; |
| 18 import 'package:analyzer/src/generated/source_io.dart'; | 18 import 'package:analyzer/src/generated/source_io.dart'; |
| 19 import 'package:unittest/unittest.dart'; | 19 import 'package:unittest/unittest.dart'; |
| 20 | 20 |
| 21 import '../mocks.dart'; | 21 import '../mocks.dart'; |
| 22 import '../reflective_tests.dart'; | 22 import '../reflective_tests.dart'; |
| 23 import 'store/single_source_container.dart'; | 23 import 'store/single_source_container.dart'; |
| 24 import 'store/memory_node_manager.dart'; | |
| 24 | 25 |
| 25 | 26 |
| 26 main() { | 27 main() { |
| 27 groupSep = ' | '; | 28 groupSep = ' | '; |
| 28 group('ServerIndex', () { | 29 group('LocalIndex', () { |
| 29 runReflectiveTests(_LocalSplitIndexTest); | 30 runReflectiveTests(_LocalIndexTest); |
| 30 }); | 31 }); |
| 31 } | 32 } |
| 32 | 33 |
| 33 | 34 |
| 34 void _assertElementNames(List<Location> locations, List expected) { | 35 void _assertElementNames(List<Location> locations, List expected) { |
| 35 expect(_toElementNames(locations), unorderedEquals(expected)); | 36 expect(_toElementNames(locations), unorderedEquals(expected)); |
| 36 } | 37 } |
| 37 | 38 |
| 38 | 39 |
| 39 Iterable<String> _toElementNames(List<Location> locations) { | 40 Iterable<String> _toElementNames(List<Location> locations) { |
| 40 return locations.map((loc) => loc.element.name); | 41 return locations.map((loc) => loc.element.name); |
| 41 } | 42 } |
| 42 | 43 |
| 43 | 44 |
| 44 @ReflectiveTestCase() | 45 @ReflectiveTestCase() |
| 45 class _LocalSplitIndexTest { | 46 class _LocalIndexTest { |
|
Brian Wilkerson
2014/06/25 20:57:18
Why is this private? Nobody outside this package c
scheglov
2014/06/25 21:13:38
Done.
| |
| 46 static final DartSdk SDK = new MockSdk(); | 47 static final DartSdk SDK = new MockSdk(); |
| 47 | 48 |
| 48 AnalysisContext context; | 49 AnalysisContext context; |
| 49 LocalSplitIndex index; | 50 LocalIndex index; |
| 50 Directory indexDirectory; | 51 Directory indexDirectory; |
| 51 MemoryResourceProvider provider = new MemoryResourceProvider(); | 52 MemoryResourceProvider provider = new MemoryResourceProvider(); |
| 52 | 53 |
| 53 void setUp() { | 54 void setUp() { |
| 54 // prepare Index | 55 // prepare Index |
| 55 indexDirectory = Directory.systemTemp.createTempSync( | 56 indexDirectory = Directory.systemTemp.createTempSync( |
| 56 'AnalysisServer_index'); | 57 'AnalysisServer_index'); |
| 57 index = new LocalSplitIndex(indexDirectory); | 58 { |
| 59 var nodeManager = new MemoryNodeManager(); | |
| 60 index = new LocalIndex(nodeManager); | |
| 61 } | |
|
Brian Wilkerson
2014/06/25 20:57:18
nit: I don't see the value of wrapping these two l
scheglov
2014/06/25 21:13:38
Inlined.
| |
| 58 // prepare AnalysisContext | 62 // prepare AnalysisContext |
| 59 context = AnalysisEngine.instance.createAnalysisContext(); | 63 context = AnalysisEngine.instance.createAnalysisContext(); |
| 60 context.sourceFactory = new SourceFactory(<UriResolver>[new DartUriResolver( | 64 context.sourceFactory = new SourceFactory(<UriResolver>[new DartUriResolver( |
| 61 SDK), new ResourceUriResolver(provider)]); | 65 SDK), new ResourceUriResolver(provider)]); |
| 62 } | 66 } |
| 63 | 67 |
| 64 void tearDown() { | 68 void tearDown() { |
| 65 indexDirectory.delete(recursive: true); | 69 indexDirectory.delete(recursive: true); |
| 66 index = null; | 70 index = null; |
| 67 context = null; | 71 context = null; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 */ | 198 */ |
| 195 class _RecordingRelationshipCallback extends RelationshipCallback { | 199 class _RecordingRelationshipCallback extends RelationshipCallback { |
| 196 List<Location> locations; | 200 List<Location> locations; |
| 197 | 201 |
| 198 @override | 202 @override |
| 199 void hasRelationships(Element element, Relationship relationship, | 203 void hasRelationships(Element element, Relationship relationship, |
| 200 List<Location> locations) { | 204 List<Location> locations) { |
| 201 this.locations = locations; | 205 this.locations = locations; |
| 202 } | 206 } |
| 203 } | 207 } |
| OLD | NEW |