| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:analysis_server/src/services/index/index.dart'; | 5 import 'package:analysis_server/src/services/index/index.dart'; |
| 6 import 'package:analyzer/dart/ast/ast.dart'; | 6 import 'package:analyzer/dart/ast/ast.dart'; |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
| 9 import 'package:analyzer/src/summary/idl.dart'; | 9 import 'package:analyzer/src/summary/idl.dart'; |
| 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 11 import 'package:typed_mock/typed_mock.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
| 12 | 13 |
| 13 import '../../abstract_single_unit.dart'; | 14 import '../../abstract_single_unit.dart'; |
| 14 import '../../utils.dart'; | 15 import '../../utils.dart'; |
| 15 | 16 |
| 16 main() { | 17 main() { |
| 17 initializeTestEnvironment(); | 18 initializeTestEnvironment(); |
| 18 defineReflectiveTests(IndexTest); | 19 defineReflectiveTests(IndexTest); |
| 19 } | 20 } |
| 20 | 21 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 test_indexDeclarations_nullUnit() async { | 251 test_indexDeclarations_nullUnit() async { |
| 251 index.indexDeclarations(null); | 252 index.indexDeclarations(null); |
| 252 } | 253 } |
| 253 | 254 |
| 254 test_indexDeclarations_nullUnitElement() async { | 255 test_indexDeclarations_nullUnitElement() async { |
| 255 resolveTestUnit(''); | 256 resolveTestUnit(''); |
| 256 testUnit.element = null; | 257 testUnit.element = null; |
| 257 index.indexDeclarations(testUnit); | 258 index.indexDeclarations(testUnit); |
| 258 } | 259 } |
| 259 | 260 |
| 261 test_indexUnit_nullLibraryElement() async { |
| 262 resolveTestUnit(''); |
| 263 CompilationUnitElement unitElement = new _CompilationUnitElementMock(); |
| 264 expect(unitElement.library, isNull); |
| 265 testUnit.element = unitElement; |
| 266 index.indexUnit(testUnit); |
| 267 } |
| 268 |
| 260 test_indexUnit_nullUnit() async { | 269 test_indexUnit_nullUnit() async { |
| 261 index.indexUnit(null); | 270 index.indexUnit(null); |
| 262 } | 271 } |
| 263 | 272 |
| 264 test_indexUnit_nullUnitElement() async { | 273 test_indexUnit_nullUnitElement() async { |
| 265 resolveTestUnit(''); | 274 resolveTestUnit(''); |
| 266 testUnit.element = null; | 275 testUnit.element = null; |
| 267 index.indexUnit(testUnit); | 276 index.indexUnit(testUnit); |
| 268 } | 277 } |
| 269 | 278 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 343 } |
| 335 } | 344 } |
| 336 | 345 |
| 337 Source _indexUnit(String path, String code) { | 346 Source _indexUnit(String path, String code) { |
| 338 Source source = addSource(path, code); | 347 Source source = addSource(path, code); |
| 339 CompilationUnit unit = resolveLibraryUnit(source); | 348 CompilationUnit unit = resolveLibraryUnit(source); |
| 340 index.indexUnit(unit); | 349 index.indexUnit(unit); |
| 341 return source; | 350 return source; |
| 342 } | 351 } |
| 343 } | 352 } |
| 353 |
| 354 class _CompilationUnitElementMock extends TypedMock |
| 355 implements CompilationUnitElement {} |
| OLD | NEW |