| 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.src.context.context_test; | 5 library test.src.context.context_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/file_system/memory_file_system.dart'; | 9 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 10 import 'package:analyzer/source/package_map_resolver.dart'; | 10 import 'package:analyzer/source/package_map_resolver.dart'; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 import 'libB.dart';'''; | 321 import 'libB.dart';'''; |
| 322 Source libA = addSource("/libA.dart", libAContents); | 322 Source libA = addSource("/libA.dart", libAContents); |
| 323 String libBContents = "library libB;"; | 323 String libBContents = "library libB;"; |
| 324 Source libB = addSource("/libB.dart", libBContents); | 324 Source libB = addSource("/libB.dart", libBContents); |
| 325 LibraryElement libAElement = context.computeLibraryElement(libA); | 325 LibraryElement libAElement = context.computeLibraryElement(libA); |
| 326 expect(libAElement, isNotNull); | 326 expect(libAElement, isNotNull); |
| 327 List<LibraryElement> importedLibraries = libAElement.importedLibraries; | 327 List<LibraryElement> importedLibraries = libAElement.importedLibraries; |
| 328 expect(importedLibraries, hasLength(2)); | 328 expect(importedLibraries, hasLength(2)); |
| 329 context.computeErrors(libA); | 329 context.computeErrors(libA); |
| 330 context.computeErrors(libB); | 330 context.computeErrors(libB); |
| 331 expect(context.sourcesNeedingProcessing, hasLength(0)); |
| 331 context.setContents(libB, null); | 332 context.setContents(libB, null); |
| 332 _removeSource(libB); | 333 _removeSource(libB); |
| 333 List<Source> sources = context.sourcesNeedingProcessing; | 334 List<Source> sources = context.sourcesNeedingProcessing; |
| 334 expect(sources, hasLength(1)); | 335 expect(sources, hasLength(1)); |
| 335 expect(sources[0], same(libA)); | 336 expect(sources[0], same(libA)); |
| 336 libAElement = context.computeLibraryElement(libA); | 337 libAElement = context.computeLibraryElement(libA); |
| 337 importedLibraries = libAElement.importedLibraries; | 338 importedLibraries = libAElement.importedLibraries; |
| 338 expect(importedLibraries, hasLength(1)); | 339 expect(importedLibraries, hasLength(1)); |
| 339 return pumpEventQueue().then((_) { | 340 return pumpEventQueue().then((_) { |
| 340 listener.assertEvent(wereSourcesAdded: true); | 341 listener.assertEvent(wereSourcesAdded: true); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 context.onSourcesChanged.listen(listener.onData); | 391 context.onSourcesChanged.listen(listener.onData); |
| 391 String libAContents = r''' | 392 String libAContents = r''' |
| 392 library libA; | 393 library libA; |
| 393 import 'libB.dart';'''; | 394 import 'libB.dart';'''; |
| 394 Source libA = addSource("/libA.dart", libAContents); | 395 Source libA = addSource("/libA.dart", libAContents); |
| 395 String libBContents = "library libB;"; | 396 String libBContents = "library libB;"; |
| 396 Source libB = addSource("/libB.dart", libBContents); | 397 Source libB = addSource("/libB.dart", libBContents); |
| 397 context.computeLibraryElement(libA); | 398 context.computeLibraryElement(libA); |
| 398 context.computeErrors(libA); | 399 context.computeErrors(libA); |
| 399 context.computeErrors(libB); | 400 context.computeErrors(libB); |
| 401 expect(context.sourcesNeedingProcessing, hasLength(0)); |
| 400 ChangeSet changeSet = new ChangeSet(); | 402 ChangeSet changeSet = new ChangeSet(); |
| 401 SourceContainer removedContainer = | 403 SourceContainer removedContainer = |
| 402 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB); | 404 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB); |
| 403 changeSet.removedContainer(removedContainer); | 405 changeSet.removedContainer(removedContainer); |
| 404 context.applyChanges(changeSet); | 406 context.applyChanges(changeSet); |
| 405 List<Source> sources = context.sourcesNeedingProcessing; | 407 List<Source> sources = context.sourcesNeedingProcessing; |
| 406 expect(sources, hasLength(1)); | 408 expect(sources, hasLength(1)); |
| 407 expect(sources[0], same(libA)); | 409 expect(sources[0], same(libA)); |
| 408 return pumpEventQueue().then((_) { | 410 return pumpEventQueue().then((_) { |
| 409 listener.assertEvent(wereSourcesAdded: true); | 411 listener.assertEvent(wereSourcesAdded: true); |
| (...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 }); | 1957 }); |
| 1956 context.onResultComputed(RESOLVED_UNIT).listen((event) { | 1958 context.onResultComputed(RESOLVED_UNIT).listen((event) { |
| 1957 LibrarySpecificUnit target = event.target; | 1959 LibrarySpecificUnit target = event.target; |
| 1958 Source librarySource = target.library; | 1960 Source librarySource = target.library; |
| 1959 resolvedUnitUris.add(librarySource.uri.toString()); | 1961 resolvedUnitUris.add(librarySource.uri.toString()); |
| 1960 }); | 1962 }); |
| 1961 // analyze | 1963 // analyze |
| 1962 addSource('/test.dart', 'main() {}'); | 1964 addSource('/test.dart', 'main() {}'); |
| 1963 _analyzeAll_assertFinished(); | 1965 _analyzeAll_assertFinished(); |
| 1964 // verify | 1966 // verify |
| 1967 expect(libraryElementUris, contains('dart:core')); |
| 1965 expect(libraryElementUris, contains('file:///test.dart')); | 1968 expect(libraryElementUris, contains('file:///test.dart')); |
| 1966 expect(parsedUnitUris, contains('dart:core')); | 1969 expect(parsedUnitUris, contains('dart:core')); |
| 1967 expect(parsedUnitUris, contains('file:///test.dart')); | 1970 expect(parsedUnitUris, contains('file:///test.dart')); |
| 1968 expect(resolvedUnitUris, contains('dart:core')); | 1971 expect(resolvedUnitUris, contains('dart:core')); |
| 1969 expect(resolvedUnitUris, contains('file:///test.dart')); | 1972 expect(resolvedUnitUris, contains('file:///test.dart')); |
| 1970 } | 1973 } |
| 1971 | 1974 |
| 1972 void test_performAnalysisTask_switchPackageVersion() { | 1975 void test_performAnalysisTask_switchPackageVersion() { |
| 1973 // version 1 | 1976 // version 1 |
| 1974 resourceProvider.newFile( | 1977 resourceProvider.newFile( |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2724 } | 2727 } |
| 2725 } | 2728 } |
| 2726 | 2729 |
| 2727 class _AnalysisContextImplTest_test_applyChanges_removeContainer | 2730 class _AnalysisContextImplTest_test_applyChanges_removeContainer |
| 2728 implements SourceContainer { | 2731 implements SourceContainer { |
| 2729 Source libB; | 2732 Source libB; |
| 2730 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); | 2733 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); |
| 2731 @override | 2734 @override |
| 2732 bool contains(Source source) => source == libB; | 2735 bool contains(Source source) => source == libB; |
| 2733 } | 2736 } |
| OLD | NEW |