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