Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 29 matching lines...) Expand all
40 40
41 main() { 41 main() {
42 defineReflectiveSuite(() { 42 defineReflectiveSuite(() {
43 defineReflectiveTests(AnalysisContextImplTest); 43 defineReflectiveTests(AnalysisContextImplTest);
44 }); 44 });
45 } 45 }
46 46
47 @reflectiveTest 47 @reflectiveTest
48 class AnalysisContextImplTest extends AbstractContextTest { 48 class AnalysisContextImplTest extends AbstractContextTest {
49 void fail_getErrors_html_some() { 49 void fail_getErrors_html_some() {
50 Source source = addSource( 50 Source source = addSource("/test.html", r'''
51 "/test.html",
52 r'''
53 <html><head> 51 <html><head>
54 <script type='application/dart' src='test.dart'/> 52 <script type='application/dart' src='test.dart'/>
55 </head></html>'''); 53 </head></html>''');
56 AnalysisErrorInfo errorInfo = context.getErrors(source); 54 AnalysisErrorInfo errorInfo = context.getErrors(source);
57 expect(errorInfo, isNotNull); 55 expect(errorInfo, isNotNull);
58 List<AnalysisError> errors = errorInfo.errors; 56 List<AnalysisError> errors = errorInfo.errors;
59 expect(errors, hasLength(0)); 57 expect(errors, hasLength(0));
60 errors = context.computeErrors(source); 58 errors = context.computeErrors(source);
61 expect(errors, hasLength(2)); 59 expect(errors, hasLength(2));
62 } 60 }
(...skipping 19 matching lines...) Expand all
82 // longer implicitly analyzing the file. 80 // longer implicitly analyzing the file.
83 // 81 //
84 context.setContents(sourceA, "library a;"); 82 context.setContents(sourceA, "library a;");
85 context.computeErrors(sourceA); 83 context.computeErrors(sourceA);
86 await pumpEventQueue(); 84 await pumpEventQueue();
87 listener.expectNotAnalyzed(sourceB); 85 listener.expectNotAnalyzed(sourceB);
88 } 86 }
89 87
90 void fail_performAnalysisTask_importedLibraryDelete_html() { 88 void fail_performAnalysisTask_importedLibraryDelete_html() {
91 // NOTE: This was failing before converting to the new task model. 89 // NOTE: This was failing before converting to the new task model.
92 Source htmlSource = addSource( 90 Source htmlSource = addSource("/page.html", r'''
93 "/page.html",
94 r'''
95 <html><body><script type="application/dart"> 91 <html><body><script type="application/dart">
96 import 'libB.dart'; 92 import 'libB.dart';
97 main() {print('hello dart');} 93 main() {print('hello dart');}
98 </script></body></html>'''); 94 </script></body></html>''');
99 Source libBSource = addSource("/libB.dart", "library libB;"); 95 Source libBSource = addSource("/libB.dart", "library libB;");
100 _analyzeAll_assertFinished(); 96 _analyzeAll_assertFinished();
101 context.computeErrors(htmlSource); 97 context.computeErrors(htmlSource);
102 expect( 98 expect(
103 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, 99 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull,
104 reason: "libB resolved 1"); 100 reason: "libB resolved 1");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 changeSet.addedSource(source); 146 changeSet.addedSource(source);
151 context.applyChanges(changeSet); 147 context.applyChanges(changeSet);
152 // now the entry is explicit 148 // now the entry is explicit
153 expect(entry.explicitlyAdded, isTrue); 149 expect(entry.explicitlyAdded, isTrue);
154 } 150 }
155 151
156 void test_applyChanges_addNewImport_invalidateLibraryCycle() { 152 void test_applyChanges_addNewImport_invalidateLibraryCycle() {
157 context.analysisOptions = 153 context.analysisOptions =
158 new AnalysisOptionsImpl.from(context.analysisOptions) 154 new AnalysisOptionsImpl.from(context.analysisOptions)
159 ..strongMode = true; 155 ..strongMode = true;
160 Source embedder = addSource( 156 Source embedder = addSource('/a.dart', r'''
161 '/a.dart',
162 r'''
163 library a; 157 library a;
164 import 'b.dart'; 158 import 'b.dart';
165 //import 'c.dart'; 159 //import 'c.dart';
166 '''); 160 ''');
167 addSource( 161 addSource('/b.dart', r'''
168 '/b.dart',
169 r'''
170 library b; 162 library b;
171 import 'a.dart'; 163 import 'a.dart';
172 '''); 164 ''');
173 addSource( 165 addSource('/c.dart', r'''
174 '/c.dart',
175 r'''
176 library c; 166 library c;
177 import 'b.dart'; 167 import 'b.dart';
178 '''); 168 ''');
179 _performPendingAnalysisTasks(); 169 _performPendingAnalysisTasks();
180 // Add a new import into a.dart, this should invalidate its library cycle. 170 // Add a new import into a.dart, this should invalidate its library cycle.
181 // If it doesn't, we will get a task cycle exception. 171 // If it doesn't, we will get a task cycle exception.
182 context.setContents( 172 context.setContents(embedder, r'''
183 embedder,
184 r'''
185 library a; 173 library a;
186 import 'b.dart'; 174 import 'b.dart';
187 import 'c.dart'; 175 import 'c.dart';
188 '''); 176 ''');
189 _performPendingAnalysisTasks(); 177 _performPendingAnalysisTasks();
190 expect(context.getCacheEntry(embedder).exception, isNull); 178 expect(context.getCacheEntry(embedder).exception, isNull);
191 } 179 }
192 180
193 Future test_applyChanges_change() { 181 Future test_applyChanges_change() {
194 SourcesChangedListener listener = new SourcesChangedListener(); 182 SourcesChangedListener listener = new SourcesChangedListener();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 changeSet2.changedContent(source, 'library test;'); 214 changeSet2.changedContent(source, 'library test;');
227 context.applyChanges(changeSet2); 215 context.applyChanges(changeSet2);
228 return pumpEventQueue().then((_) { 216 return pumpEventQueue().then((_) {
229 listener.assertEvent(wereSourcesAdded: true); 217 listener.assertEvent(wereSourcesAdded: true);
230 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); 218 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]);
231 listener.assertNoMoreEvents(); 219 listener.assertNoMoreEvents();
232 }); 220 });
233 } 221 }
234 222
235 void test_applyChanges_change_flush_element() { 223 void test_applyChanges_change_flush_element() {
236 Source librarySource = addSource( 224 Source librarySource = addSource("/lib.dart", r'''
237 "/lib.dart",
238 r'''
239 library lib; 225 library lib;
240 int a = 0;'''); 226 int a = 0;''');
241 expect(context.computeLibraryElement(librarySource), isNotNull); 227 expect(context.computeLibraryElement(librarySource), isNotNull);
242 context.setContents( 228 context.setContents(librarySource, r'''
243 librarySource,
244 r'''
245 library lib; 229 library lib;
246 int aa = 0;'''); 230 int aa = 0;''');
247 expect(context.getLibraryElement(librarySource), isNull); 231 expect(context.getLibraryElement(librarySource), isNull);
248 } 232 }
249 233
250 Future test_applyChanges_change_multiple() { 234 Future test_applyChanges_change_multiple() {
251 SourcesChangedListener listener = new SourcesChangedListener(); 235 SourcesChangedListener listener = new SourcesChangedListener();
252 context.onSourcesChanged.listen(listener.onData); 236 context.onSourcesChanged.listen(listener.onData);
253 String libraryContents1 = r''' 237 String libraryContents1 = r'''
254 library lib; 238 library lib;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 382 }
399 // Adding the source as a changedSource should have no effect since 383 // Adding the source as a changedSource should have no effect since
400 // it is already overridden in the content cache. 384 // it is already overridden in the content cache.
401 ChangeSet changeSet = new ChangeSet(); 385 ChangeSet changeSet = new ChangeSet();
402 changeSet.changedSource(source); 386 changeSet.changedSource(source);
403 context.applyChanges(changeSet); 387 context.applyChanges(changeSet);
404 expect(context.sourcesNeedingProcessing, hasLength(0)); 388 expect(context.sourcesNeedingProcessing, hasLength(0));
405 } 389 }
406 390
407 void test_applyChanges_recompute_exportNamespace() { 391 void test_applyChanges_recompute_exportNamespace() {
408 Source libSource = addSource( 392 Source libSource = addSource("/lib.dart", r'''
409 "/lib.dart",
410 r'''
411 class A {} 393 class A {}
412 '''); 394 ''');
413 Source exporterSource = addSource( 395 Source exporterSource = addSource("/exporter.dart", r'''
414 "/exporter.dart",
415 r'''
416 export 'lib.dart'; 396 export 'lib.dart';
417 '''); 397 ''');
418 _performPendingAnalysisTasks(); 398 _performPendingAnalysisTasks();
419 // initially: A 399 // initially: A
420 { 400 {
421 LibraryElement libraryElement = 401 LibraryElement libraryElement =
422 context.getResult(exporterSource, LIBRARY_ELEMENT1); 402 context.getResult(exporterSource, LIBRARY_ELEMENT1);
423 expect(libraryElement.exportNamespace.definedNames.keys, 403 expect(libraryElement.exportNamespace.definedNames.keys,
424 unorderedEquals(['A'])); 404 unorderedEquals(['A']));
425 } 405 }
426 // after update: B 406 // after update: B
427 context.setContents( 407 context.setContents(libSource, r'''
428 libSource,
429 r'''
430 class B {}'''); 408 class B {}''');
431 _performPendingAnalysisTasks(); 409 _performPendingAnalysisTasks();
432 { 410 {
433 LibraryElement libraryElement = 411 LibraryElement libraryElement =
434 context.getResult(exporterSource, LIBRARY_ELEMENT1); 412 context.getResult(exporterSource, LIBRARY_ELEMENT1);
435 expect(libraryElement.exportNamespace.definedNames.keys, 413 expect(libraryElement.exportNamespace.definedNames.keys,
436 unorderedEquals(['B'])); 414 unorderedEquals(['B']));
437 } 415 }
438 } 416 }
439 417
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 Source source2 = resourceProvider.newFile(path2, '// 2-1').createSource(); 634 Source source2 = resourceProvider.newFile(path2, '// 2-1').createSource();
657 context.applyChanges( 635 context.applyChanges(
658 new ChangeSet()..addedSource(source1)..addedSource(source2)); 636 new ChangeSet()..addedSource(source1)..addedSource(source2));
659 // Verify. 637 // Verify.
660 expect(validator.getSourcesToComputeModificationTimes(), 638 expect(validator.getSourcesToComputeModificationTimes(),
661 unorderedEquals([source1, source2])); 639 unorderedEquals([source1, source2]));
662 } 640 }
663 641
664 void test_computeDocumentationComment_class_block() { 642 void test_computeDocumentationComment_class_block() {
665 String comment = "/** Comment */"; 643 String comment = "/** Comment */";
666 Source source = addSource( 644 Source source = addSource("/test.dart", """
667 "/test.dart",
668 """
669 $comment 645 $comment
670 class A {}"""); 646 class A {}""");
671 LibraryElement libraryElement = context.computeLibraryElement(source); 647 LibraryElement libraryElement = context.computeLibraryElement(source);
672 expect(libraryElement, isNotNull); 648 expect(libraryElement, isNotNull);
673 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; 649 ClassElement classElement = libraryElement.definingCompilationUnit.types[0];
674 expect(libraryElement, isNotNull); 650 expect(libraryElement, isNotNull);
675 expect(context.computeDocumentationComment(classElement), comment); 651 expect(context.computeDocumentationComment(classElement), comment);
676 } 652 }
677 653
678 void test_computeDocumentationComment_class_none() { 654 void test_computeDocumentationComment_class_none() {
(...skipping 22 matching lines...) Expand all
701 LibraryElement libraryElement = context.computeLibraryElement(source); 677 LibraryElement libraryElement = context.computeLibraryElement(source);
702 expect(libraryElement, isNotNull); 678 expect(libraryElement, isNotNull);
703 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; 679 ClassElement classElement = libraryElement.definingCompilationUnit.types[0];
704 expect(libraryElement, isNotNull); 680 expect(libraryElement, isNotNull);
705 String actual = context.computeDocumentationComment(classElement); 681 String actual = context.computeDocumentationComment(classElement);
706 expect(actual, "/// line 1\n/// line 2\n/// line 3"); 682 expect(actual, "/// line 1\n/// line 2\n/// line 3");
707 } 683 }
708 684
709 void test_computeDocumentationComment_exportDirective_block() { 685 void test_computeDocumentationComment_exportDirective_block() {
710 String comment = '/** Comment */'; 686 String comment = '/** Comment */';
711 Source source = addSource( 687 Source source = addSource("/test.dart", '''
712 "/test.dart",
713 '''
714 $comment 688 $comment
715 export 'dart:async'; 689 export 'dart:async';
716 '''); 690 ''');
717 LibraryElement libraryElement = context.computeLibraryElement(source); 691 LibraryElement libraryElement = context.computeLibraryElement(source);
718 expect(libraryElement, isNotNull); 692 expect(libraryElement, isNotNull);
719 ExportElement exportElement = libraryElement.exports[0]; 693 ExportElement exportElement = libraryElement.exports[0];
720 expect(context.computeDocumentationComment(exportElement), comment); 694 expect(context.computeDocumentationComment(exportElement), comment);
721 } 695 }
722 696
723 void test_computeDocumentationComment_importDirective_block() { 697 void test_computeDocumentationComment_importDirective_block() {
724 String comment = '/** Comment */'; 698 String comment = '/** Comment */';
725 Source source = addSource( 699 Source source = addSource("/test.dart", '''
726 "/test.dart",
727 '''
728 $comment 700 $comment
729 import 'dart:async'; 701 import 'dart:async';
730 '''); 702 ''');
731 LibraryElement libraryElement = context.computeLibraryElement(source); 703 LibraryElement libraryElement = context.computeLibraryElement(source);
732 expect(libraryElement, isNotNull); 704 expect(libraryElement, isNotNull);
733 ImportElement importElement = libraryElement.imports[0]; 705 ImportElement importElement = libraryElement.imports[0];
734 expect(context.computeDocumentationComment(importElement), comment); 706 expect(context.computeDocumentationComment(importElement), comment);
735 } 707 }
736 708
737 void test_computeDocumentationComment_libraryDirective_block() { 709 void test_computeDocumentationComment_libraryDirective_block() {
738 String comment = '/** Comment */'; 710 String comment = '/** Comment */';
739 Source source = addSource( 711 Source source = addSource("/test.dart", '''
740 "/test.dart",
741 '''
742 $comment 712 $comment
743 library lib; 713 library lib;
744 '''); 714 ''');
745 LibraryElement libraryElement = context.computeLibraryElement(source); 715 LibraryElement libraryElement = context.computeLibraryElement(source);
746 expect(libraryElement, isNotNull); 716 expect(libraryElement, isNotNull);
747 expect(context.computeDocumentationComment(libraryElement), comment); 717 expect(context.computeDocumentationComment(libraryElement), comment);
748 } 718 }
749 719
750 void test_computeDocumentationComment_null() { 720 void test_computeDocumentationComment_null() {
751 expect(context.computeDocumentationComment(null), isNull); 721 expect(context.computeDocumentationComment(null), isNull);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 expect(context.computeKindOf(source), same(SourceKind.PART)); 806 expect(context.computeKindOf(source), same(SourceKind.PART));
837 } 807 }
838 808
839 void test_computeLibraryElement() { 809 void test_computeLibraryElement() {
840 Source source = addSource("/test.dart", "library lib;"); 810 Source source = addSource("/test.dart", "library lib;");
841 LibraryElement element = context.computeLibraryElement(source); 811 LibraryElement element = context.computeLibraryElement(source);
842 expect(element, isNotNull); 812 expect(element, isNotNull);
843 } 813 }
844 814
845 void test_computeLineInfo_dart() { 815 void test_computeLineInfo_dart() {
846 Source source = addSource( 816 Source source = addSource("/test.dart", r'''
847 "/test.dart",
848 r'''
849 library lib; 817 library lib;
850 818
851 main() {}'''); 819 main() {}''');
852 LineInfo info = context.computeLineInfo(source); 820 LineInfo info = context.computeLineInfo(source);
853 expect(info, isNotNull); 821 expect(info, isNotNull);
854 } 822 }
855 823
856 void test_computeLineInfo_html() { 824 void test_computeLineInfo_html() {
857 Source source = addSource( 825 Source source = addSource("/test.html", r'''
858 "/test.html",
859 r'''
860 <html> 826 <html>
861 <body> 827 <body>
862 <h1>A</h1> 828 <h1>A</h1>
863 </body> 829 </body>
864 </html>'''); 830 </html>''');
865 LineInfo info = context.computeLineInfo(source); 831 LineInfo info = context.computeLineInfo(source);
866 expect(info, isNotNull); 832 expect(info, isNotNull);
867 } 833 }
868 834
869 Future test_computeResolvedCompilationUnitAsync() { 835 Future test_computeResolvedCompilationUnitAsync() {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 // schedule recomputing 980 // schedule recomputing
1015 List<CompilationUnit> units = context.ensureResolvedDartUnits(source); 981 List<CompilationUnit> units = context.ensureResolvedDartUnits(source);
1016 expect(units, isNull); 982 expect(units, isNull);
1017 // should be the next result to compute 983 // should be the next result to compute
1018 TargetedResult nextResult = context.dartWorkManager.getNextResult(); 984 TargetedResult nextResult = context.dartWorkManager.getNextResult();
1019 expect(nextResult.target, libTarget); 985 expect(nextResult.target, libTarget);
1020 expect(nextResult.result, RESOLVED_UNIT); 986 expect(nextResult.result, RESOLVED_UNIT);
1021 } 987 }
1022 988
1023 void test_ensureResolvedDartUnits_partUnit_hasResolved() { 989 void test_ensureResolvedDartUnits_partUnit_hasResolved() {
1024 Source libSource1 = addSource( 990 Source libSource1 = addSource('/lib1.dart', r'''
1025 '/lib1.dart',
1026 r'''
1027 library lib; 991 library lib;
1028 part 'part.dart'; 992 part 'part.dart';
1029 '''); 993 ''');
1030 Source libSource2 = addSource( 994 Source libSource2 = addSource('/lib2.dart', r'''
1031 '/lib2.dart',
1032 r'''
1033 library lib; 995 library lib;
1034 part 'part.dart'; 996 part 'part.dart';
1035 '''); 997 ''');
1036 Source partSource = addSource( 998 Source partSource = addSource('/part.dart', r'''
1037 '/part.dart',
1038 r'''
1039 part of lib; 999 part of lib;
1040 '''); 1000 ''');
1041 LibrarySpecificUnit partTarget1 = 1001 LibrarySpecificUnit partTarget1 =
1042 new LibrarySpecificUnit(libSource1, partSource); 1002 new LibrarySpecificUnit(libSource1, partSource);
1043 LibrarySpecificUnit partTarget2 = 1003 LibrarySpecificUnit partTarget2 =
1044 new LibrarySpecificUnit(libSource2, partSource); 1004 new LibrarySpecificUnit(libSource2, partSource);
1045 analysisDriver.computeResult(partTarget1, RESOLVED_UNIT); 1005 analysisDriver.computeResult(partTarget1, RESOLVED_UNIT);
1046 analysisDriver.computeResult(partTarget2, RESOLVED_UNIT); 1006 analysisDriver.computeResult(partTarget2, RESOLVED_UNIT);
1047 CompilationUnit unit1 = 1007 CompilationUnit unit1 =
1048 context.getCacheEntry(partTarget1).getValue(RESOLVED_UNIT); 1008 context.getCacheEntry(partTarget1).getValue(RESOLVED_UNIT);
1049 CompilationUnit unit2 = 1009 CompilationUnit unit2 =
1050 context.getCacheEntry(partTarget2).getValue(RESOLVED_UNIT); 1010 context.getCacheEntry(partTarget2).getValue(RESOLVED_UNIT);
1051 List<CompilationUnit> units = context.ensureResolvedDartUnits(partSource); 1011 List<CompilationUnit> units = context.ensureResolvedDartUnits(partSource);
1052 expect(units, unorderedEquals([unit1, unit2])); 1012 expect(units, unorderedEquals([unit1, unit2]));
1053 } 1013 }
1054 1014
1055 void test_ensureResolvedDartUnits_partUnit_notResolved() { 1015 void test_ensureResolvedDartUnits_partUnit_notResolved() {
1056 Source libSource1 = addSource( 1016 Source libSource1 = addSource('/lib1.dart', r'''
1057 '/lib1.dart',
1058 r'''
1059 library lib; 1017 library lib;
1060 part 'part.dart'; 1018 part 'part.dart';
1061 '''); 1019 ''');
1062 Source libSource2 = addSource( 1020 Source libSource2 = addSource('/lib2.dart', r'''
1063 '/lib2.dart',
1064 r'''
1065 library lib; 1021 library lib;
1066 part 'part.dart'; 1022 part 'part.dart';
1067 '''); 1023 ''');
1068 Source partSource = addSource( 1024 Source partSource = addSource('/part.dart', r'''
1069 '/part.dart',
1070 r'''
1071 part of lib; 1025 part of lib;
1072 '''); 1026 ''');
1073 LibrarySpecificUnit partTarget1 = 1027 LibrarySpecificUnit partTarget1 =
1074 new LibrarySpecificUnit(libSource1, partSource); 1028 new LibrarySpecificUnit(libSource1, partSource);
1075 LibrarySpecificUnit partTarget2 = 1029 LibrarySpecificUnit partTarget2 =
1076 new LibrarySpecificUnit(libSource2, partSource); 1030 new LibrarySpecificUnit(libSource2, partSource);
1077 analysisDriver.computeResult(partTarget1, RESOLVED_UNIT); 1031 analysisDriver.computeResult(partTarget1, RESOLVED_UNIT);
1078 analysisDriver.computeResult(partTarget2, RESOLVED_UNIT); 1032 analysisDriver.computeResult(partTarget2, RESOLVED_UNIT);
1079 // flush 1033 // flush
1080 context 1034 context
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 expect(cls.accessors[0].returnType.toString(), 'int', reason: reason); 1130 expect(cls.accessors[0].returnType.toString(), 'int', reason: reason);
1177 expect(cls.accessors[1].isSetter, isTrue, reason: reason); 1131 expect(cls.accessors[1].isSetter, isTrue, reason: reason);
1178 expect(cls.accessors[1].returnType.toString(), 'void', reason: reason); 1132 expect(cls.accessors[1].returnType.toString(), 'void', reason: reason);
1179 expect(cls.accessors[1].parameters, hasLength(1), reason: reason); 1133 expect(cls.accessors[1].parameters, hasLength(1), reason: reason);
1180 expect(cls.accessors[1].parameters[0].type.toString(), 'int', 1134 expect(cls.accessors[1].parameters[0].type.toString(), 'int',
1181 reason: reason); 1135 reason: reason);
1182 }); 1136 });
1183 } 1137 }
1184 1138
1185 void test_flushSingleResolvedUnit_instanceGetter() { 1139 void test_flushSingleResolvedUnit_instanceGetter() {
1186 _checkFlushSingleResolvedUnit( 1140 _checkFlushSingleResolvedUnit('''
1187 '''
1188 abstract class B { 1141 abstract class B {
1189 int get x; 1142 int get x;
1190 } 1143 }
1191 class C extends B { 1144 class C extends B {
1192 get x => null; 1145 get x => null;
1193 } 1146 }
1194 ''', (CompilationUnitElement unitElement, String reason) { 1147 ''', (CompilationUnitElement unitElement, String reason) {
1195 expect(unitElement.types, hasLength(2), reason: reason); 1148 expect(unitElement.types, hasLength(2), reason: reason);
1196 ClassElement cls = unitElement.types[1]; 1149 ClassElement cls = unitElement.types[1];
1197 expect(cls.name, 'C', reason: reason); 1150 expect(cls.name, 'C', reason: reason);
1198 expect(cls.accessors, hasLength(1), reason: reason); 1151 expect(cls.accessors, hasLength(1), reason: reason);
1199 expect(cls.accessors[0].returnType.toString(), 'int', reason: reason); 1152 expect(cls.accessors[0].returnType.toString(), 'int', reason: reason);
1200 expect(cls.fields, hasLength(1), reason: reason); 1153 expect(cls.fields, hasLength(1), reason: reason);
1201 expect(cls.fields[0].type.toString(), 'int', reason: reason); 1154 expect(cls.fields[0].type.toString(), 'int', reason: reason);
1202 }); 1155 });
1203 } 1156 }
1204 1157
1205 void test_flushSingleResolvedUnit_instanceMethod() { 1158 void test_flushSingleResolvedUnit_instanceMethod() {
1206 _checkFlushSingleResolvedUnit( 1159 _checkFlushSingleResolvedUnit('''
1207 '''
1208 abstract class B { 1160 abstract class B {
1209 int f(String s); 1161 int f(String s);
1210 } 1162 }
1211 class C extends B { 1163 class C extends B {
1212 f(s) => null; 1164 f(s) => null;
1213 } 1165 }
1214 ''', (CompilationUnitElement unitElement, String reason) { 1166 ''', (CompilationUnitElement unitElement, String reason) {
1215 expect(unitElement.types, hasLength(2), reason: reason); 1167 expect(unitElement.types, hasLength(2), reason: reason);
1216 ClassElement cls = unitElement.types[1]; 1168 ClassElement cls = unitElement.types[1];
1217 expect(cls.name, 'C', reason: reason); 1169 expect(cls.name, 'C', reason: reason);
1218 expect(cls.methods, hasLength(1), reason: reason); 1170 expect(cls.methods, hasLength(1), reason: reason);
1219 expect(cls.methods[0].returnType.toString(), 'int', reason: reason); 1171 expect(cls.methods[0].returnType.toString(), 'int', reason: reason);
1220 expect(cls.methods[0].parameters, hasLength(1), reason: reason); 1172 expect(cls.methods[0].parameters, hasLength(1), reason: reason);
1221 expect(cls.methods[0].parameters[0].type.toString(), 'String', 1173 expect(cls.methods[0].parameters[0].type.toString(), 'String',
1222 reason: reason); 1174 reason: reason);
1223 }); 1175 });
1224 } 1176 }
1225 1177
1226 void test_flushSingleResolvedUnit_instanceSetter() { 1178 void test_flushSingleResolvedUnit_instanceSetter() {
1227 _checkFlushSingleResolvedUnit( 1179 _checkFlushSingleResolvedUnit('''
1228 '''
1229 abstract class B { 1180 abstract class B {
1230 set x(int value); 1181 set x(int value);
1231 } 1182 }
1232 class C extends B { 1183 class C extends B {
1233 set x(value) {} 1184 set x(value) {}
1234 } 1185 }
1235 ''', (CompilationUnitElement unitElement, String reason) { 1186 ''', (CompilationUnitElement unitElement, String reason) {
1236 expect(unitElement.types, hasLength(2), reason: reason); 1187 expect(unitElement.types, hasLength(2), reason: reason);
1237 ClassElement cls = unitElement.types[1]; 1188 ClassElement cls = unitElement.types[1];
1238 expect(cls.name, 'C', reason: reason); 1189 expect(cls.name, 'C', reason: reason);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 expect(core, isNotNull); 1272 expect(core, isNotNull);
1322 ClassElement classObject = 1273 ClassElement classObject =
1323 _findClass(core.definingCompilationUnit, "Object"); 1274 _findClass(core.definingCompilationUnit, "Object");
1324 expect(classObject, isNotNull); 1275 expect(classObject, isNotNull);
1325 ElementLocation location = classObject.location; 1276 ElementLocation location = classObject.location;
1326 Element element = context.getElement(location); 1277 Element element = context.getElement(location);
1327 expect(element, same(classObject)); 1278 expect(element, same(classObject));
1328 } 1279 }
1329 1280
1330 void test_getElement_constructor_named() { 1281 void test_getElement_constructor_named() {
1331 Source source = addSource( 1282 Source source = addSource("/lib.dart", r'''
1332 "/lib.dart",
1333 r'''
1334 class A { 1283 class A {
1335 A.named() {} 1284 A.named() {}
1336 }'''); 1285 }''');
1337 _analyzeAll_assertFinished(); 1286 _analyzeAll_assertFinished();
1338 LibraryElement library = context.computeLibraryElement(source); 1287 LibraryElement library = context.computeLibraryElement(source);
1339 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); 1288 ClassElement classA = _findClass(library.definingCompilationUnit, "A");
1340 ConstructorElement constructor = classA.constructors[0]; 1289 ConstructorElement constructor = classA.constructors[0];
1341 ElementLocation location = constructor.location; 1290 ElementLocation location = constructor.location;
1342 Element element = context.getElement(location); 1291 Element element = context.getElement(location);
1343 expect(element, same(constructor)); 1292 expect(element, same(constructor));
1344 } 1293 }
1345 1294
1346 void test_getElement_constructor_unnamed() { 1295 void test_getElement_constructor_unnamed() {
1347 Source source = addSource( 1296 Source source = addSource("/lib.dart", r'''
1348 "/lib.dart",
1349 r'''
1350 class A { 1297 class A {
1351 A() {} 1298 A() {}
1352 }'''); 1299 }''');
1353 _analyzeAll_assertFinished(); 1300 _analyzeAll_assertFinished();
1354 LibraryElement library = context.computeLibraryElement(source); 1301 LibraryElement library = context.computeLibraryElement(source);
1355 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); 1302 ClassElement classA = _findClass(library.definingCompilationUnit, "A");
1356 ConstructorElement constructor = classA.constructors[0]; 1303 ConstructorElement constructor = classA.constructors[0];
1357 ElementLocation location = constructor.location; 1304 ElementLocation location = constructor.location;
1358 Element element = context.getElement(location); 1305 Element element = context.getElement(location);
1359 expect(element, same(constructor)); 1306 expect(element, same(constructor));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 AnalysisErrorInfo errorInfo = context.getErrors(source); 1342 AnalysisErrorInfo errorInfo = context.getErrors(source);
1396 expect(errorInfo, isNotNull); 1343 expect(errorInfo, isNotNull);
1397 List<AnalysisError> errors = errorInfo.errors; 1344 List<AnalysisError> errors = errorInfo.errors;
1398 expect(errors, hasLength(0)); 1345 expect(errors, hasLength(0));
1399 context.computeErrors(source); 1346 context.computeErrors(source);
1400 errors = errorInfo.errors; 1347 errors = errorInfo.errors;
1401 expect(errors, hasLength(0)); 1348 expect(errors, hasLength(0));
1402 } 1349 }
1403 1350
1404 void test_getHtmlFilesReferencing_html() { 1351 void test_getHtmlFilesReferencing_html() {
1405 Source htmlSource = addSource( 1352 Source htmlSource = addSource("/test.html", r'''
1406 "/test.html",
1407 r'''
1408 <html><head> 1353 <html><head>
1409 <script type='application/dart' src='test.dart'/> 1354 <script type='application/dart' src='test.dart'/>
1410 <script type='application/dart' src='test.js'/> 1355 <script type='application/dart' src='test.js'/>
1411 </head></html>'''); 1356 </head></html>''');
1412 Source librarySource = addSource("/test.dart", "library lib;"); 1357 Source librarySource = addSource("/test.dart", "library lib;");
1413 Source secondHtmlSource = addSource("/test.html", "<html></html>"); 1358 Source secondHtmlSource = addSource("/test.html", "<html></html>");
1414 context.computeLibraryElement(librarySource); 1359 context.computeLibraryElement(librarySource);
1415 List<Source> result = context.getHtmlFilesReferencing(secondHtmlSource); 1360 List<Source> result = context.getHtmlFilesReferencing(secondHtmlSource);
1416 expect(result, hasLength(0)); 1361 expect(result, hasLength(0));
1417 context.parseHtmlDocument(htmlSource); 1362 context.parseHtmlDocument(htmlSource);
1418 result = context.getHtmlFilesReferencing(secondHtmlSource); 1363 result = context.getHtmlFilesReferencing(secondHtmlSource);
1419 expect(result, hasLength(0)); 1364 expect(result, hasLength(0));
1420 } 1365 }
1421 1366
1422 void test_getHtmlFilesReferencing_library() { 1367 void test_getHtmlFilesReferencing_library() {
1423 Source htmlSource = addSource( 1368 Source htmlSource = addSource("/test.html", r'''
1424 "/test.html",
1425 r'''
1426 <!DOCTYPE html> 1369 <!DOCTYPE html>
1427 <html><head> 1370 <html><head>
1428 <script type='application/dart' src='test.dart'/> 1371 <script type='application/dart' src='test.dart'/>
1429 <script type='application/dart' src='test.js'/> 1372 <script type='application/dart' src='test.js'/>
1430 </head></html>'''); 1373 </head></html>''');
1431 Source librarySource = addSource("/test.dart", "library lib;"); 1374 Source librarySource = addSource("/test.dart", "library lib;");
1432 context.computeLibraryElement(librarySource); 1375 context.computeLibraryElement(librarySource);
1433 List<Source> result = context.getHtmlFilesReferencing(librarySource); 1376 List<Source> result = context.getHtmlFilesReferencing(librarySource);
1434 expect(result, hasLength(0)); 1377 expect(result, hasLength(0));
1435 // Indirectly force the data to be computed. 1378 // Indirectly force the data to be computed.
1436 context.computeErrors(htmlSource); 1379 context.computeErrors(htmlSource);
1437 result = context.getHtmlFilesReferencing(librarySource); 1380 result = context.getHtmlFilesReferencing(librarySource);
1438 expect(result, hasLength(1)); 1381 expect(result, hasLength(1));
1439 expect(result[0], htmlSource); 1382 expect(result[0], htmlSource);
1440 } 1383 }
1441 1384
1442 void test_getHtmlFilesReferencing_part() { 1385 void test_getHtmlFilesReferencing_part() {
1443 Source htmlSource = addSource( 1386 Source htmlSource = addSource("/test.html", r'''
1444 "/test.html",
1445 r'''
1446 <!DOCTYPE html> 1387 <!DOCTYPE html>
1447 <html><head> 1388 <html><head>
1448 <script type='application/dart' src='test.dart'/> 1389 <script type='application/dart' src='test.dart'/>
1449 <script type='application/dart' src='test.js'/> 1390 <script type='application/dart' src='test.js'/>
1450 </head></html>'''); 1391 </head></html>''');
1451 Source librarySource = 1392 Source librarySource =
1452 addSource("/test.dart", "library lib; part 'part.dart';"); 1393 addSource("/test.dart", "library lib; part 'part.dart';");
1453 Source partSource = addSource("/part.dart", "part of lib;"); 1394 Source partSource = addSource("/part.dart", "part of lib;");
1454 context.computeLibraryElement(librarySource); 1395 context.computeLibraryElement(librarySource);
1455 List<Source> result = context.getHtmlFilesReferencing(partSource); 1396 List<Source> result = context.getHtmlFilesReferencing(partSource);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 context.computeKindOf(source); 1429 context.computeKindOf(source);
1489 expect(context.getKindOf(source), same(SourceKind.PART)); 1430 expect(context.getKindOf(source), same(SourceKind.PART));
1490 } 1431 }
1491 1432
1492 void test_getKindOf_unknown() { 1433 void test_getKindOf_unknown() {
1493 Source source = addSource("/test.css", ""); 1434 Source source = addSource("/test.css", "");
1494 expect(context.getKindOf(source), same(SourceKind.UNKNOWN)); 1435 expect(context.getKindOf(source), same(SourceKind.UNKNOWN));
1495 } 1436 }
1496 1437
1497 void test_getLaunchableClientLibrarySources_doesNotImportHtml() { 1438 void test_getLaunchableClientLibrarySources_doesNotImportHtml() {
1498 Source source = addSource( 1439 Source source = addSource("/test.dart", r'''
1499 "/test.dart",
1500 r'''
1501 main() {}'''); 1440 main() {}''');
1502 context.computeLibraryElement(source); 1441 context.computeLibraryElement(source);
1503 List<Source> sources = context.launchableClientLibrarySources; 1442 List<Source> sources = context.launchableClientLibrarySources;
1504 expect(sources, isEmpty); 1443 expect(sources, isEmpty);
1505 } 1444 }
1506 1445
1507 void test_getLaunchableClientLibrarySources_importsHtml_explicitly() { 1446 void test_getLaunchableClientLibrarySources_importsHtml_explicitly() {
1508 List<Source> sources = context.launchableClientLibrarySources; 1447 List<Source> sources = context.launchableClientLibrarySources;
1509 expect(sources, isEmpty); 1448 expect(sources, isEmpty);
1510 Source source = addSource( 1449 Source source = addSource("/test.dart", r'''
1511 "/test.dart",
1512 r'''
1513 import 'dart:html'; 1450 import 'dart:html';
1514 main() {}'''); 1451 main() {}''');
1515 context.computeLibraryElement(source); 1452 context.computeLibraryElement(source);
1516 sources = context.launchableClientLibrarySources; 1453 sources = context.launchableClientLibrarySources;
1517 expect(sources, unorderedEquals([source])); 1454 expect(sources, unorderedEquals([source]));
1518 } 1455 }
1519 1456
1520 void test_getLaunchableClientLibrarySources_importsHtml_implicitly() { 1457 void test_getLaunchableClientLibrarySources_importsHtml_implicitly() {
1521 List<Source> sources = context.launchableClientLibrarySources; 1458 List<Source> sources = context.launchableClientLibrarySources;
1522 expect(sources, isEmpty); 1459 expect(sources, isEmpty);
1523 addSource( 1460 addSource('/a.dart', r'''
1524 '/a.dart',
1525 r'''
1526 import 'dart:html'; 1461 import 'dart:html';
1527 '''); 1462 ''');
1528 Source source = addSource( 1463 Source source = addSource("/test.dart", r'''
1529 "/test.dart",
1530 r'''
1531 import 'a.dart'; 1464 import 'a.dart';
1532 main() {}'''); 1465 main() {}''');
1533 _analyzeAll_assertFinished(); 1466 _analyzeAll_assertFinished();
1534 sources = context.launchableClientLibrarySources; 1467 sources = context.launchableClientLibrarySources;
1535 expect(sources, unorderedEquals([source])); 1468 expect(sources, unorderedEquals([source]));
1536 } 1469 }
1537 1470
1538 void test_getLaunchableClientLibrarySources_importsHtml_implicitly2() { 1471 void test_getLaunchableClientLibrarySources_importsHtml_implicitly2() {
1539 List<Source> sources = context.launchableClientLibrarySources; 1472 List<Source> sources = context.launchableClientLibrarySources;
1540 expect(sources, isEmpty); 1473 expect(sources, isEmpty);
1541 addSource( 1474 addSource('/a.dart', r'''
1542 '/a.dart',
1543 r'''
1544 export 'dart:html'; 1475 export 'dart:html';
1545 '''); 1476 ''');
1546 Source source = addSource( 1477 Source source = addSource("/test.dart", r'''
1547 "/test.dart",
1548 r'''
1549 import 'a.dart'; 1478 import 'a.dart';
1550 main() {}'''); 1479 main() {}''');
1551 _analyzeAll_assertFinished(); 1480 _analyzeAll_assertFinished();
1552 sources = context.launchableClientLibrarySources; 1481 sources = context.launchableClientLibrarySources;
1553 expect(sources, unorderedEquals([source])); 1482 expect(sources, unorderedEquals([source]));
1554 } 1483 }
1555 1484
1556 void test_getLaunchableServerLibrarySources() { 1485 void test_getLaunchableServerLibrarySources() {
1557 expect(context.launchableServerLibrarySources, isEmpty); 1486 expect(context.launchableServerLibrarySources, isEmpty);
1558 Source source = addSource("/test.dart", "main() {}"); 1487 Source source = addSource("/test.dart", "main() {}");
1559 context.computeLibraryElement(source); 1488 context.computeLibraryElement(source);
1560 expect(context.launchableServerLibrarySources, unorderedEquals([source])); 1489 expect(context.launchableServerLibrarySources, unorderedEquals([source]));
1561 } 1490 }
1562 1491
1563 void test_getLaunchableServerLibrarySources_importsHtml_explicitly() { 1492 void test_getLaunchableServerLibrarySources_importsHtml_explicitly() {
1564 Source source = addSource( 1493 Source source = addSource("/test.dart", r'''
1565 "/test.dart",
1566 r'''
1567 import 'dart:html'; 1494 import 'dart:html';
1568 main() {} 1495 main() {}
1569 '''); 1496 ''');
1570 context.computeLibraryElement(source); 1497 context.computeLibraryElement(source);
1571 expect(context.launchableServerLibrarySources, isEmpty); 1498 expect(context.launchableServerLibrarySources, isEmpty);
1572 } 1499 }
1573 1500
1574 void test_getLaunchableServerLibrarySources_importsHtml_implicitly() { 1501 void test_getLaunchableServerLibrarySources_importsHtml_implicitly() {
1575 addSource( 1502 addSource("/imports_html.dart", r'''
1576 "/imports_html.dart",
1577 r'''
1578 import 'dart:html'; 1503 import 'dart:html';
1579 '''); 1504 ''');
1580 addSource( 1505 addSource("/test.dart", r'''
1581 "/test.dart",
1582 r'''
1583 import 'imports_html.dart'; 1506 import 'imports_html.dart';
1584 main() {}'''); 1507 main() {}''');
1585 _analyzeAll_assertFinished(); 1508 _analyzeAll_assertFinished();
1586 expect(context.launchableServerLibrarySources, isEmpty); 1509 expect(context.launchableServerLibrarySources, isEmpty);
1587 } 1510 }
1588 1511
1589 void test_getLaunchableServerLibrarySources_noMain() { 1512 void test_getLaunchableServerLibrarySources_noMain() {
1590 Source source = addSource("/test.dart", ''); 1513 Source source = addSource("/test.dart", '');
1591 context.computeLibraryElement(source); 1514 context.computeLibraryElement(source);
1592 expect(context.launchableServerLibrarySources, isEmpty); 1515 expect(context.launchableServerLibrarySources, isEmpty);
1593 } 1516 }
1594 1517
1595 void test_getLibrariesContaining() { 1518 void test_getLibrariesContaining() {
1596 Source librarySource = addSource( 1519 Source librarySource = addSource("/lib.dart", r'''
1597 "/lib.dart",
1598 r'''
1599 library lib; 1520 library lib;
1600 part 'part.dart';'''); 1521 part 'part.dart';''');
1601 Source partSource = addSource("/part.dart", "part of lib;"); 1522 Source partSource = addSource("/part.dart", "part of lib;");
1602 context.computeLibraryElement(librarySource); 1523 context.computeLibraryElement(librarySource);
1603 List<Source> result = context.getLibrariesContaining(librarySource); 1524 List<Source> result = context.getLibrariesContaining(librarySource);
1604 expect(result, hasLength(1)); 1525 expect(result, hasLength(1));
1605 expect(result[0], librarySource); 1526 expect(result[0], librarySource);
1606 result = context.getLibrariesContaining(partSource); 1527 result = context.getLibrariesContaining(partSource);
1607 expect(result, hasLength(1)); 1528 expect(result, hasLength(1));
1608 expect(result[0], librarySource); 1529 expect(result[0], librarySource);
1609 } 1530 }
1610 1531
1611 void test_getLibrariesDependingOn() { 1532 void test_getLibrariesDependingOn() {
1612 Source libASource = addSource("/libA.dart", "library libA;"); 1533 Source libASource = addSource("/libA.dart", "library libA;");
1613 addSource("/libB.dart", "library libB;"); 1534 addSource("/libB.dart", "library libB;");
1614 Source lib1Source = addSource( 1535 Source lib1Source = addSource("/lib1.dart", r'''
1615 "/lib1.dart",
1616 r'''
1617 library lib1; 1536 library lib1;
1618 import 'libA.dart'; 1537 import 'libA.dart';
1619 export 'libB.dart';'''); 1538 export 'libB.dart';''');
1620 Source lib2Source = addSource( 1539 Source lib2Source = addSource("/lib2.dart", r'''
1621 "/lib2.dart",
1622 r'''
1623 library lib2; 1540 library lib2;
1624 import 'libB.dart'; 1541 import 'libB.dart';
1625 export 'libA.dart';'''); 1542 export 'libA.dart';''');
1626 context.computeLibraryElement(lib1Source); 1543 context.computeLibraryElement(lib1Source);
1627 context.computeLibraryElement(lib2Source); 1544 context.computeLibraryElement(lib2Source);
1628 List<Source> result = context.getLibrariesDependingOn(libASource); 1545 List<Source> result = context.getLibrariesDependingOn(libASource);
1629 expect(result, unorderedEquals([lib1Source, lib2Source])); 1546 expect(result, unorderedEquals([lib1Source, lib2Source]));
1630 } 1547 }
1631 1548
1632 void test_getLibrariesReferencedFromHtml() { 1549 void test_getLibrariesReferencedFromHtml() {
1633 Source htmlSource = addSource( 1550 Source htmlSource = addSource("/test.html", r'''
1634 "/test.html",
1635 r'''
1636 <!DOCTYPE html> 1551 <!DOCTYPE html>
1637 <html><head> 1552 <html><head>
1638 <script type='application/dart' src='test.dart'/> 1553 <script type='application/dart' src='test.dart'/>
1639 <script type='application/dart' src='test.js'/> 1554 <script type='application/dart' src='test.js'/>
1640 </head></html>'''); 1555 </head></html>''');
1641 Source librarySource = addSource("/test.dart", "library lib;"); 1556 Source librarySource = addSource("/test.dart", "library lib;");
1642 context.computeLibraryElement(librarySource); 1557 context.computeLibraryElement(librarySource);
1643 // Indirectly force the data to be computed. 1558 // Indirectly force the data to be computed.
1644 context.computeErrors(htmlSource); 1559 context.computeErrors(htmlSource);
1645 List<Source> result = context.getLibrariesReferencedFromHtml(htmlSource); 1560 List<Source> result = context.getLibrariesReferencedFromHtml(htmlSource);
1646 expect(result, hasLength(1)); 1561 expect(result, hasLength(1));
1647 expect(result[0], librarySource); 1562 expect(result[0], librarySource);
1648 } 1563 }
1649 1564
1650 void test_getLibrariesReferencedFromHtml_none() { 1565 void test_getLibrariesReferencedFromHtml_none() {
1651 Source htmlSource = addSource( 1566 Source htmlSource = addSource("/test.html", r'''
1652 "/test.html",
1653 r'''
1654 <html><head> 1567 <html><head>
1655 <script type='application/dart' src='test.js'/> 1568 <script type='application/dart' src='test.js'/>
1656 </head></html>'''); 1569 </head></html>''');
1657 addSource("/test.dart", "library lib;"); 1570 addSource("/test.dart", "library lib;");
1658 context.parseHtmlDocument(htmlSource); 1571 context.parseHtmlDocument(htmlSource);
1659 List<Source> result = context.getLibrariesReferencedFromHtml(htmlSource); 1572 List<Source> result = context.getLibrariesReferencedFromHtml(htmlSource);
1660 expect(result, hasLength(0)); 1573 expect(result, hasLength(0));
1661 } 1574 }
1662 1575
1663 void test_getLibraryElement() { 1576 void test_getLibraryElement() {
(...skipping 14 matching lines...) Expand all
1678 expect(sources, hasLength(originalLength + 1)); 1591 expect(sources, hasLength(originalLength + 1));
1679 for (Source returnedSource in sources) { 1592 for (Source returnedSource in sources) {
1680 if (returnedSource == source) { 1593 if (returnedSource == source) {
1681 return; 1594 return;
1682 } 1595 }
1683 } 1596 }
1684 fail("The added source was not in the list of library sources"); 1597 fail("The added source was not in the list of library sources");
1685 } 1598 }
1686 1599
1687 void test_getLibrarySources_inSDK() { 1600 void test_getLibrarySources_inSDK() {
1688 Source source = addSource( 1601 Source source = addSource('/test.dart', r'''
1689 '/test.dart',
1690 r'''
1691 import 'dart:async'; 1602 import 'dart:async';
1692 Stream S = null; 1603 Stream S = null;
1693 '''); 1604 ''');
1694 LibraryElement testLibrary = context.computeLibraryElement(source); 1605 LibraryElement testLibrary = context.computeLibraryElement(source);
1695 // prepare "Stream" ClassElement 1606 // prepare "Stream" ClassElement
1696 ClassElement streamElement; 1607 ClassElement streamElement;
1697 { 1608 {
1698 CompilationUnitElement testUnit = testLibrary.definingCompilationUnit; 1609 CompilationUnitElement testUnit = testLibrary.definingCompilationUnit;
1699 InterfaceType streamType = testUnit.topLevelVariables[0].type; 1610 InterfaceType streamType = testUnit.topLevelVariables[0].type;
1700 streamElement = streamType.element; 1611 streamElement = streamType.element;
(...skipping 14 matching lines...) Expand all
1715 { 1626 {
1716 List<Source> coreLibraries = context.getLibrariesContaining(intSource); 1627 List<Source> coreLibraries = context.getLibrariesContaining(intSource);
1717 expect(coreLibraries, hasLength(1)); 1628 expect(coreLibraries, hasLength(1));
1718 Source coreSource = coreLibraries[0]; 1629 Source coreSource = coreLibraries[0];
1719 expect(coreSource.isInSystemLibrary, isTrue); 1630 expect(coreSource.isInSystemLibrary, isTrue);
1720 expect(coreSource.shortName, 'async.dart'); 1631 expect(coreSource.shortName, 'async.dart');
1721 } 1632 }
1722 } 1633 }
1723 1634
1724 void test_getLineInfo() { 1635 void test_getLineInfo() {
1725 Source source = addSource( 1636 Source source = addSource("/test.dart", r'''
1726 "/test.dart",
1727 r'''
1728 library lib; 1637 library lib;
1729 1638
1730 main() {}'''); 1639 main() {}''');
1731 LineInfo info = context.getLineInfo(source); 1640 LineInfo info = context.getLineInfo(source);
1732 expect(info, isNull); 1641 expect(info, isNull);
1733 context.parseCompilationUnit(source); 1642 context.parseCompilationUnit(source);
1734 info = context.getLineInfo(source); 1643 info = context.getLineInfo(source);
1735 expect(info, isNotNull); 1644 expect(info, isNotNull);
1736 } 1645 }
1737 1646
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 Source sourceB = newSource('/b.dart', "library b;"); 1784 Source sourceB = newSource('/b.dart', "library b;");
1876 ChangeSet changeSet = new ChangeSet(); 1785 ChangeSet changeSet = new ChangeSet();
1877 changeSet.addedSource(sourceA); 1786 changeSet.addedSource(sourceA);
1878 context.applyChanges(changeSet); 1787 context.applyChanges(changeSet);
1879 context.computeErrors(sourceA); 1788 context.computeErrors(sourceA);
1880 await pumpEventQueue(); 1789 await pumpEventQueue();
1881 listener.expectAnalyzed(sourceB); 1790 listener.expectAnalyzed(sourceB);
1882 } 1791 }
1883 1792
1884 void test_isClientLibrary_dart() { 1793 void test_isClientLibrary_dart() {
1885 Source source = addSource( 1794 Source source = addSource("/test.dart", r'''
1886 "/test.dart",
1887 r'''
1888 import 'dart:html'; 1795 import 'dart:html';
1889 1796
1890 main() {}'''); 1797 main() {}''');
1891 expect(context.isClientLibrary(source), isFalse); 1798 expect(context.isClientLibrary(source), isFalse);
1892 expect(context.isServerLibrary(source), isFalse); 1799 expect(context.isServerLibrary(source), isFalse);
1893 context.computeLibraryElement(source); 1800 context.computeLibraryElement(source);
1894 expect(context.isClientLibrary(source), isTrue); 1801 expect(context.isClientLibrary(source), isTrue);
1895 expect(context.isServerLibrary(source), isFalse); 1802 expect(context.isServerLibrary(source), isFalse);
1896 } 1803 }
1897 1804
1898 void test_isClientLibrary_html() { 1805 void test_isClientLibrary_html() {
1899 Source source = addSource("/test.html", "<html></html>"); 1806 Source source = addSource("/test.html", "<html></html>");
1900 expect(context.isClientLibrary(source), isFalse); 1807 expect(context.isClientLibrary(source), isFalse);
1901 } 1808 }
1902 1809
1903 void test_isClientLibrary_unknown() { 1810 void test_isClientLibrary_unknown() {
1904 Source source = newSource("/test.dart"); 1811 Source source = newSource("/test.dart");
1905 expect(context.isClientLibrary(source), isFalse); 1812 expect(context.isClientLibrary(source), isFalse);
1906 } 1813 }
1907 1814
1908 void test_isServerLibrary_dart() { 1815 void test_isServerLibrary_dart() {
1909 Source source = addSource( 1816 Source source = addSource("/test.dart", r'''
1910 "/test.dart",
1911 r'''
1912 library lib; 1817 library lib;
1913 1818
1914 main() {}'''); 1819 main() {}''');
1915 expect(context.isClientLibrary(source), isFalse); 1820 expect(context.isClientLibrary(source), isFalse);
1916 expect(context.isServerLibrary(source), isFalse); 1821 expect(context.isServerLibrary(source), isFalse);
1917 context.computeLibraryElement(source); 1822 context.computeLibraryElement(source);
1918 expect(context.isClientLibrary(source), isFalse); 1823 expect(context.isClientLibrary(source), isFalse);
1919 expect(context.isServerLibrary(source), isTrue); 1824 expect(context.isServerLibrary(source), isTrue);
1920 } 1825 }
1921 1826
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 } 1920 }
2016 } 1921 }
2017 1922
2018 void test_parseHtmlDocument() { 1923 void test_parseHtmlDocument() {
2019 Source source = addSource("/lib.html", "<!DOCTYPE html><html></html>"); 1924 Source source = addSource("/lib.html", "<!DOCTYPE html><html></html>");
2020 Document document = context.parseHtmlDocument(source); 1925 Document document = context.parseHtmlDocument(source);
2021 expect(document, isNotNull); 1926 expect(document, isNotNull);
2022 } 1927 }
2023 1928
2024 void test_parseHtmlUnit_resolveDirectives() { 1929 void test_parseHtmlUnit_resolveDirectives() {
2025 Source libSource = addSource( 1930 Source libSource = addSource("/lib.dart", r'''
2026 "/lib.dart",
2027 r'''
2028 library lib; 1931 library lib;
2029 class ClassA {}'''); 1932 class ClassA {}''');
2030 Source source = addSource( 1933 Source source = addSource("/lib.html", r'''
2031 "/lib.html",
2032 r'''
2033 <!DOCTYPE html> 1934 <!DOCTYPE html>
2034 <html> 1935 <html>
2035 <head> 1936 <head>
2036 <script type='application/dart'> 1937 <script type='application/dart'>
2037 import 'lib.dart'; 1938 import 'lib.dart';
2038 ClassA v = null; 1939 ClassA v = null;
2039 </script> 1940 </script>
2040 </head> 1941 </head>
2041 <body> 1942 <body>
2042 </body> 1943 </body>
2043 </html>'''); 1944 </html>''');
2044 Document document = context.parseHtmlDocument(source); 1945 Document document = context.parseHtmlDocument(source);
2045 expect(document, isNotNull); 1946 expect(document, isNotNull);
2046 List<DartScript> scripts = context.computeResult(source, DART_SCRIPTS); 1947 List<DartScript> scripts = context.computeResult(source, DART_SCRIPTS);
2047 expect(scripts, hasLength(1)); 1948 expect(scripts, hasLength(1));
2048 CompilationUnit unit = context.computeResult(scripts[0], PARSED_UNIT); 1949 CompilationUnit unit = context.computeResult(scripts[0], PARSED_UNIT);
2049 ImportDirective importNode = unit.directives[0] as ImportDirective; 1950 ImportDirective importNode = unit.directives[0] as ImportDirective;
2050 expect(importNode.uriContent, isNotNull); 1951 expect(importNode.uriContent, isNotNull);
2051 expect(importNode.uriSource, libSource); 1952 expect(importNode.uriSource, libSource);
2052 } 1953 }
2053 1954
2054 void test_performAnalysisTask_addPart() { 1955 void test_performAnalysisTask_addPart() {
2055 Source libSource = addSource( 1956 Source libSource = addSource("/lib.dart", r'''
2056 "/lib.dart",
2057 r'''
2058 library lib; 1957 library lib;
2059 part 'part.dart';'''); 1958 part 'part.dart';''');
2060 // run all tasks without part 1959 // run all tasks without part
2061 _analyzeAll_assertFinished(); 1960 _analyzeAll_assertFinished();
2062 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libSource)), 1961 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libSource)),
2063 isTrue, 1962 isTrue,
2064 reason: "lib has errors"); 1963 reason: "lib has errors");
2065 // add part and run all tasks 1964 // add part and run all tasks
2066 Source partSource = addSource( 1965 Source partSource = addSource("/part.dart", r'''
2067 "/part.dart",
2068 r'''
2069 part of lib; 1966 part of lib;
2070 '''); 1967 ''');
2071 _analyzeAll_assertFinished(); 1968 _analyzeAll_assertFinished();
2072 // "libSource" should be here 1969 // "libSource" should be here
2073 List<Source> librariesWithPart = context.getLibrariesContaining(partSource); 1970 List<Source> librariesWithPart = context.getLibrariesContaining(partSource);
2074 expect(librariesWithPart, unorderedEquals([libSource])); 1971 expect(librariesWithPart, unorderedEquals([libSource]));
2075 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libSource)), 1972 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libSource)),
2076 isFalse, 1973 isFalse,
2077 reason: "lib doesn't have errors"); 1974 reason: "lib doesn't have errors");
2078 expect( 1975 expect(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, 2042 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull,
2146 reason: "part changed 3"); 2043 reason: "part changed 3");
2147 _analyzeAll_assertFinished(); 2044 _analyzeAll_assertFinished();
2148 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, 2045 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull,
2149 reason: "library resolved 3"); 2046 reason: "library resolved 3");
2150 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, 2047 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull,
2151 reason: "part resolved 3"); 2048 reason: "part resolved 3");
2152 } 2049 }
2153 2050
2154 void test_performAnalysisTask_changePartContents_makeItAPart() { 2051 void test_performAnalysisTask_changePartContents_makeItAPart() {
2155 Source libSource = addSource( 2052 Source libSource = addSource("/lib.dart", r'''
2156 "/lib.dart",
2157 r'''
2158 library lib; 2053 library lib;
2159 part 'part.dart'; 2054 part 'part.dart';
2160 void f(x) {}'''); 2055 void f(x) {}''');
2161 Source partSource = addSource("/part.dart", "void g() { f(null); }"); 2056 Source partSource = addSource("/part.dart", "void g() { f(null); }");
2162 _analyzeAll_assertFinished(); 2057 _analyzeAll_assertFinished();
2163 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, 2058 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull,
2164 reason: "library resolved 1"); 2059 reason: "library resolved 1");
2165 expect( 2060 expect(
2166 context.getResolvedCompilationUnit2(partSource, partSource), isNotNull, 2061 context.getResolvedCompilationUnit2(partSource, partSource), isNotNull,
2167 reason: "part resolved 1"); 2062 reason: "part resolved 1");
2168 // update and analyze 2063 // update and analyze
2169 context.setContents( 2064 context.setContents(partSource, r'''
2170 partSource,
2171 r'''
2172 part of lib; 2065 part of lib;
2173 void g() { f(null); }'''); 2066 void g() { f(null); }''');
2174 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, 2067 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull,
2175 reason: "library changed 2"); 2068 reason: "library changed 2");
2176 expect(context.getResolvedCompilationUnit2(partSource, partSource), isNull, 2069 expect(context.getResolvedCompilationUnit2(partSource, partSource), isNull,
2177 reason: "part changed 2"); 2070 reason: "part changed 2");
2178 _analyzeAll_assertFinished(); 2071 _analyzeAll_assertFinished();
2179 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, 2072 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull,
2180 reason: "library resolved 2"); 2073 reason: "library resolved 2");
2181 expect( 2074 expect(
2182 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, 2075 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull,
2183 reason: "part resolved 2"); 2076 reason: "part resolved 2");
2184 expect(context.getErrors(libSource).errors, hasLength(0)); 2077 expect(context.getErrors(libSource).errors, hasLength(0));
2185 expect(context.getErrors(partSource).errors, hasLength(0)); 2078 expect(context.getErrors(partSource).errors, hasLength(0));
2186 } 2079 }
2187 2080
2188 /** 2081 /**
2189 * https://code.google.com/p/dart/issues/detail?id=12424 2082 * https://code.google.com/p/dart/issues/detail?id=12424
2190 */ 2083 */
2191 void test_performAnalysisTask_changePartContents_makeItNotPart() { 2084 void test_performAnalysisTask_changePartContents_makeItNotPart() {
2192 Source libSource = addSource( 2085 Source libSource = addSource("/lib.dart", r'''
2193 "/lib.dart",
2194 r'''
2195 library lib; 2086 library lib;
2196 part 'part.dart'; 2087 part 'part.dart';
2197 void f(x) {}'''); 2088 void f(x) {}''');
2198 Source partSource = addSource( 2089 Source partSource = addSource("/part.dart", r'''
2199 "/part.dart",
2200 r'''
2201 part of lib; 2090 part of lib;
2202 void g() { f(null); }'''); 2091 void g() { f(null); }''');
2203 _analyzeAll_assertFinished(); 2092 _analyzeAll_assertFinished();
2204 expect(context.getErrors(libSource).errors, hasLength(0)); 2093 expect(context.getErrors(libSource).errors, hasLength(0));
2205 expect(context.getErrors(partSource).errors, hasLength(0)); 2094 expect(context.getErrors(partSource).errors, hasLength(0));
2206 // Remove 'part' directive, which should make "f(null)" an error. 2095 // Remove 'part' directive, which should make "f(null)" an error.
2207 context.setContents( 2096 context.setContents(partSource, r'''
2208 partSource,
2209 r'''
2210 //part of lib; 2097 //part of lib;
2211 void g() { f(null); }'''); 2098 void g() { f(null); }''');
2212 _analyzeAll_assertFinished(); 2099 _analyzeAll_assertFinished();
2213 expect(context.getErrors(libSource).errors.length != 0, isTrue); 2100 expect(context.getErrors(libSource).errors.length != 0, isTrue);
2214 } 2101 }
2215 2102
2216 void test_performAnalysisTask_changePartContents_noSemanticChanges() { 2103 void test_performAnalysisTask_changePartContents_noSemanticChanges() {
2217 Source libSource = 2104 Source libSource =
2218 addSource("/test.dart", "library lib; part 'test-part.dart';"); 2105 addSource("/test.dart", "library lib; part 'test-part.dart';");
2219 Source partSource = addSource("/test-part.dart", "part of lib;"); 2106 Source partSource = addSource("/test-part.dart", "part of lib;");
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 reason: "libA resolved 2"); 2178 reason: "libA resolved 2");
2292 expect( 2179 expect(
2293 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, 2180 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull,
2294 reason: "libB resolved 2"); 2181 reason: "libB resolved 2");
2295 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), 2182 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)),
2296 isFalse, 2183 isFalse,
2297 reason: "libA doesn't have errors"); 2184 reason: "libA doesn't have errors");
2298 } 2185 }
2299 2186
2300 void test_performAnalysisTask_importedLibraryAdd_html() { 2187 void test_performAnalysisTask_importedLibraryAdd_html() {
2301 Source htmlSource = addSource( 2188 Source htmlSource = addSource("/page.html", r'''
2302 "/page.html",
2303 r'''
2304 <html><body><script type="application/dart"> 2189 <html><body><script type="application/dart">
2305 import '/libB.dart'; 2190 import '/libB.dart';
2306 main() {print('hello dart');} 2191 main() {print('hello dart');}
2307 </script></body></html>'''); 2192 </script></body></html>''');
2308 _analyzeAll_assertFinished(); 2193 _analyzeAll_assertFinished();
2309 context.computeErrors(htmlSource); 2194 context.computeErrors(htmlSource);
2310 // expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(htmlSource)), 2195 // expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(htmlSource)),
2311 // isTrue, 2196 // isTrue,
2312 // reason: "htmlSource has an error"); 2197 // reason: "htmlSource has an error");
2313 // add libB.dart and analyze 2198 // add libB.dart and analyze
(...skipping 30 matching lines...) Expand all
2344 _analyzeAll_assertFinished(); 2229 _analyzeAll_assertFinished();
2345 expect( 2230 expect(
2346 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull, 2231 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull,
2347 reason: "libA resolved 2"); 2232 reason: "libA resolved 2");
2348 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), 2233 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)),
2349 isTrue, 2234 isTrue,
2350 reason: "libA has an error"); 2235 reason: "libA has an error");
2351 } 2236 }
2352 2237
2353 void test_performAnalysisTask_interruptBy_setContents() { 2238 void test_performAnalysisTask_interruptBy_setContents() {
2354 Source sourceA = addSource( 2239 Source sourceA = addSource('/a.dart', r'''
2355 '/a.dart',
2356 r'''
2357 library expectedToFindSemicolon 2240 library expectedToFindSemicolon
2358 '''); 2241 ''');
2359 // Analyze to the point where some of the results stop depending on 2242 // Analyze to the point where some of the results stop depending on
2360 // the source content. 2243 // the source content.
2361 LibrarySpecificUnit unitA = new LibrarySpecificUnit(sourceA, sourceA); 2244 LibrarySpecificUnit unitA = new LibrarySpecificUnit(sourceA, sourceA);
2362 for (int i = 0; i < 10000; i++) { 2245 for (int i = 0; i < 10000; i++) {
2363 context.performAnalysisTask(); 2246 context.performAnalysisTask();
2364 if (context.getResult(unitA, RESOLVED_UNIT3) != null) { 2247 if (context.getResult(unitA, RESOLVED_UNIT3) != null) {
2365 break; 2248 break;
2366 } 2249 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 .getFile(resourceProvider.convertPath('/test.dart')) 2327 .getFile(resourceProvider.convertPath('/test.dart'))
2445 .toUri() 2328 .toUri()
2446 .toString(); 2329 .toString();
2447 expect(libraryElementUris, contains(testUri)); 2330 expect(libraryElementUris, contains(testUri));
2448 expect(parsedUnitUris, contains(testUri)); 2331 expect(parsedUnitUris, contains(testUri));
2449 expect(resolvedUnitUris, contains(testUri)); 2332 expect(resolvedUnitUris, contains(testUri));
2450 } 2333 }
2451 2334
2452 void test_performAnalysisTask_switchPackageVersion() { 2335 void test_performAnalysisTask_switchPackageVersion() {
2453 // version 1 2336 // version 1
2454 resourceProvider.newFile( 2337 resourceProvider.newFile('/pkgs/crypto-1/lib/crypto.dart', r'''
2455 '/pkgs/crypto-1/lib/crypto.dart',
2456 r'''
2457 library crypto; 2338 library crypto;
2458 part 'src/hash_utils.dart'; 2339 part 'src/hash_utils.dart';
2459 '''); 2340 ''');
2460 resourceProvider.newFile( 2341 resourceProvider.newFile('/pkgs/crypto-1/lib/src/hash_utils.dart', r'''
2461 '/pkgs/crypto-1/lib/src/hash_utils.dart',
2462 r'''
2463 part of crypto; 2342 part of crypto;
2464 const _MASK_8 = 0xff; 2343 const _MASK_8 = 0xff;
2465 '''); 2344 ''');
2466 // version 2 2345 // version 2
2467 resourceProvider.newFile( 2346 resourceProvider.newFile('/pkgs/crypto-2/lib/crypto.dart', r'''
2468 '/pkgs/crypto-2/lib/crypto.dart',
2469 r'''
2470 library crypto; 2347 library crypto;
2471 part 'src/hash_utils.dart'; 2348 part 'src/hash_utils.dart';
2472 '''); 2349 ''');
2473 resourceProvider.newFile( 2350 resourceProvider.newFile('/pkgs/crypto-2/lib/src/hash_utils.dart', r'''
2474 '/pkgs/crypto-2/lib/src/hash_utils.dart',
2475 r'''
2476 part of crypto; 2351 part of crypto;
2477 const _MASK_8 = 0xff; 2352 const _MASK_8 = 0xff;
2478 '''); 2353 ''');
2479 // use version 1 2354 // use version 1
2480 context.sourceFactory = new SourceFactory(<UriResolver>[ 2355 context.sourceFactory = new SourceFactory(<UriResolver>[
2481 sdkResolver, 2356 sdkResolver,
2482 resourceResolver, 2357 resourceResolver,
2483 new PackageMapUriResolver(resourceProvider, { 2358 new PackageMapUriResolver(resourceProvider, {
2484 'crypto': [resourceProvider.getFolder('/pkgs/crypto-1/lib')] 2359 'crypto': [resourceProvider.getFolder('/pkgs/crypto-1/lib')]
2485 }) 2360 })
2486 ]); 2361 ]);
2487 // analyze 2362 // analyze
2488 addSource( 2363 addSource("/test.dart", r'''
2489 "/test.dart",
2490 r'''
2491 import 'package:crypto/crypto.dart'; 2364 import 'package:crypto/crypto.dart';
2492 '''); 2365 ''');
2493 _analyzeAll_assertFinished(); 2366 _analyzeAll_assertFinished();
2494 // use version 2 2367 // use version 2
2495 context.sourceFactory = new SourceFactory(<UriResolver>[ 2368 context.sourceFactory = new SourceFactory(<UriResolver>[
2496 sdkResolver, 2369 sdkResolver,
2497 resourceResolver, 2370 resourceResolver,
2498 new PackageMapUriResolver(resourceProvider, { 2371 new PackageMapUriResolver(resourceProvider, {
2499 'crypto': [resourceProvider.getFolder('/pkgs/crypto-2/lib')] 2372 'crypto': [resourceProvider.getFolder('/pkgs/crypto-2/lib')]
2500 }) 2373 })
2501 ]); 2374 ]);
2502 _analyzeAll_assertFinished(); 2375 _analyzeAll_assertFinished();
2503 _assertNoExceptions(); 2376 _assertNoExceptions();
2504 } 2377 }
2505 2378
2506 @failingTest // TODO(paulberry): Remove the annotation when dartbug.com/28515 is fixed. 2379 @failingTest // TODO(paulberry): Remove the annotation when dartbug.com/28515 is fixed.
2507 void test_resolveCompilationUnit_existingElementModel() { 2380 void test_resolveCompilationUnit_existingElementModel() {
2508 prepareAnalysisContext(new AnalysisOptionsImpl()..strongMode = true); 2381 prepareAnalysisContext(new AnalysisOptionsImpl()..strongMode = true);
2509 Source source = addSource( 2382 Source source = addSource('/test.dart', r'''
2510 '/test.dart',
2511 r'''
2512 library test; 2383 library test;
2513 2384
2514 String topLevelVariable; 2385 String topLevelVariable;
2515 int get topLevelGetter => 0; 2386 int get topLevelGetter => 0;
2516 void set topLevelSetter(int value) {} 2387 void set topLevelSetter(int value) {}
2517 String topLevelFunction(int i) => ''; 2388 String topLevelFunction(int i) => '';
2518 2389
2519 typedef String FunctionTypeAlias(int i); 2390 typedef String FunctionTypeAlias(int i);
2520 2391
2521 enum EnumeratedType {Invalid, Valid} 2392 enum EnumeratedType {Invalid, Valid}
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 * Initialize the visitor. 2979 * Initialize the visitor.
3109 */ 2980 */
3110 _ElementGatherer(); 2981 _ElementGatherer();
3111 2982
3112 @override 2983 @override
3113 void visitElement(Element element) { 2984 void visitElement(Element element) {
3114 elements[element] = element; 2985 elements[element] = element;
3115 super.visitElement(element); 2986 super.visitElement(element);
3116 } 2987 }
3117 } 2988 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/context/builder_test.dart ('k') | pkg/analyzer/test/src/context/mock_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698