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 analyzer.test.src.context.context_test; | 5 library analyzer.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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 import 'libB.dart';'''; | 304 import 'libB.dart';'''; |
305 Source libA = addSource("/libA.dart", libAContents); | 305 Source libA = addSource("/libA.dart", libAContents); |
306 String libBContents = "library libB;"; | 306 String libBContents = "library libB;"; |
307 Source libB = addSource("/libB.dart", libBContents); | 307 Source libB = addSource("/libB.dart", libBContents); |
308 LibraryElement libAElement = context.computeLibraryElement(libA); | 308 LibraryElement libAElement = context.computeLibraryElement(libA); |
309 expect(libAElement, isNotNull); | 309 expect(libAElement, isNotNull); |
310 List<LibraryElement> importedLibraries = libAElement.importedLibraries; | 310 List<LibraryElement> importedLibraries = libAElement.importedLibraries; |
311 expect(importedLibraries, hasLength(2)); | 311 expect(importedLibraries, hasLength(2)); |
312 context.computeErrors(libA); | 312 context.computeErrors(libA); |
313 context.computeErrors(libB); | 313 context.computeErrors(libB); |
314 expect(context.sourcesNeedingProcessing, hasLength(0)); | |
315 context.setContents(libB, null); | 314 context.setContents(libB, null); |
316 _removeSource(libB); | 315 _removeSource(libB); |
317 List<Source> sources = context.sourcesNeedingProcessing; | 316 List<Source> sources = context.sourcesNeedingProcessing; |
318 expect(sources, hasLength(1)); | 317 expect(sources, hasLength(1)); |
319 expect(sources[0], same(libA)); | 318 expect(sources[0], same(libA)); |
320 libAElement = context.computeLibraryElement(libA); | 319 libAElement = context.computeLibraryElement(libA); |
321 importedLibraries = libAElement.importedLibraries; | 320 importedLibraries = libAElement.importedLibraries; |
322 expect(importedLibraries, hasLength(1)); | 321 expect(importedLibraries, hasLength(1)); |
323 return pumpEventQueue().then((_) { | 322 return pumpEventQueue().then((_) { |
324 listener.assertEvent(wereSourcesAdded: true); | 323 listener.assertEvent(wereSourcesAdded: true); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 context.onSourcesChanged.listen(listener.onData); | 373 context.onSourcesChanged.listen(listener.onData); |
375 String libAContents = r''' | 374 String libAContents = r''' |
376 library libA; | 375 library libA; |
377 import 'libB.dart';'''; | 376 import 'libB.dart';'''; |
378 Source libA = addSource("/libA.dart", libAContents); | 377 Source libA = addSource("/libA.dart", libAContents); |
379 String libBContents = "library libB;"; | 378 String libBContents = "library libB;"; |
380 Source libB = addSource("/libB.dart", libBContents); | 379 Source libB = addSource("/libB.dart", libBContents); |
381 context.computeLibraryElement(libA); | 380 context.computeLibraryElement(libA); |
382 context.computeErrors(libA); | 381 context.computeErrors(libA); |
383 context.computeErrors(libB); | 382 context.computeErrors(libB); |
384 expect(context.sourcesNeedingProcessing, hasLength(0)); | |
385 ChangeSet changeSet = new ChangeSet(); | 383 ChangeSet changeSet = new ChangeSet(); |
386 SourceContainer removedContainer = | 384 SourceContainer removedContainer = |
387 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB); | 385 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB); |
388 changeSet.removedContainer(removedContainer); | 386 changeSet.removedContainer(removedContainer); |
389 context.applyChanges(changeSet); | 387 context.applyChanges(changeSet); |
390 List<Source> sources = context.sourcesNeedingProcessing; | 388 List<Source> sources = context.sourcesNeedingProcessing; |
391 expect(sources, hasLength(1)); | 389 expect(sources, hasLength(1)); |
392 expect(sources[0], same(libA)); | 390 expect(sources[0], same(libA)); |
393 return pumpEventQueue().then((_) { | 391 return pumpEventQueue().then((_) { |
394 listener.assertEvent(wereSourcesAdded: true); | 392 listener.assertEvent(wereSourcesAdded: true); |
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1930 }); | 1928 }); |
1931 context.onResultComputed(RESOLVED_UNIT).listen((event) { | 1929 context.onResultComputed(RESOLVED_UNIT).listen((event) { |
1932 LibrarySpecificUnit target = event.target; | 1930 LibrarySpecificUnit target = event.target; |
1933 Source librarySource = target.library; | 1931 Source librarySource = target.library; |
1934 resolvedUnitUris.add(librarySource.uri.toString()); | 1932 resolvedUnitUris.add(librarySource.uri.toString()); |
1935 }); | 1933 }); |
1936 // analyze | 1934 // analyze |
1937 addSource('/test.dart', 'main() {}'); | 1935 addSource('/test.dart', 'main() {}'); |
1938 _analyzeAll_assertFinished(); | 1936 _analyzeAll_assertFinished(); |
1939 // verify | 1937 // verify |
1940 expect(libraryElementUris, contains('dart:core')); | |
1941 expect(libraryElementUris, contains('file:///test.dart')); | 1938 expect(libraryElementUris, contains('file:///test.dart')); |
1942 expect(parsedUnitUris, contains('dart:core')); | 1939 expect(parsedUnitUris, contains('dart:core')); |
1943 expect(parsedUnitUris, contains('file:///test.dart')); | 1940 expect(parsedUnitUris, contains('file:///test.dart')); |
1944 expect(resolvedUnitUris, contains('dart:core')); | 1941 expect(resolvedUnitUris, contains('dart:core')); |
1945 expect(resolvedUnitUris, contains('file:///test.dart')); | 1942 expect(resolvedUnitUris, contains('file:///test.dart')); |
1946 } | 1943 } |
1947 | 1944 |
1948 void test_performAnalysisTask_switchPackageVersion() { | 1945 void test_performAnalysisTask_switchPackageVersion() { |
1949 // version 1 | 1946 // version 1 |
1950 resourceProvider.newFile( | 1947 resourceProvider.newFile( |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2721 int get modificationStamp => stamp; | 2718 int get modificationStamp => stamp; |
2722 } | 2719 } |
2723 | 2720 |
2724 class _AnalysisContextImplTest_test_applyChanges_removeContainer | 2721 class _AnalysisContextImplTest_test_applyChanges_removeContainer |
2725 implements SourceContainer { | 2722 implements SourceContainer { |
2726 Source libB; | 2723 Source libB; |
2727 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); | 2724 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); |
2728 @override | 2725 @override |
2729 bool contains(Source source) => source == libB; | 2726 bool contains(Source source) => source == libB; |
2730 } | 2727 } |
OLD | NEW |