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/src/cancelable_future.dart'; | 9 import 'package:analyzer/src/cancelable_future.dart'; |
10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
(...skipping 17 matching lines...) Expand all Loading... |
28 ChangeSet, | 28 ChangeSet, |
29 IncrementalAnalysisCache, | 29 IncrementalAnalysisCache, |
30 TimestampedData; | 30 TimestampedData; |
31 import 'package:analyzer/src/generated/error.dart'; | 31 import 'package:analyzer/src/generated/error.dart'; |
32 import 'package:analyzer/src/generated/html.dart' as ht; | 32 import 'package:analyzer/src/generated/html.dart' as ht; |
33 import 'package:analyzer/src/generated/java_engine.dart'; | 33 import 'package:analyzer/src/generated/java_engine.dart'; |
34 import 'package:analyzer/src/generated/resolver.dart'; | 34 import 'package:analyzer/src/generated/resolver.dart'; |
35 import 'package:analyzer/src/generated/scanner.dart'; | 35 import 'package:analyzer/src/generated/scanner.dart'; |
36 import 'package:analyzer/src/generated/source.dart'; | 36 import 'package:analyzer/src/generated/source.dart'; |
37 import 'package:analyzer/task/dart.dart'; | 37 import 'package:analyzer/task/dart.dart'; |
| 38 import 'package:html/dom.dart' show Document; |
38 import 'package:path/path.dart' as pathos; | 39 import 'package:path/path.dart' as pathos; |
39 import 'package:unittest/unittest.dart'; | 40 import 'package:unittest/unittest.dart'; |
40 import 'package:watcher/src/utils.dart'; | 41 import 'package:watcher/src/utils.dart'; |
41 | 42 |
42 import '../../generated/engine_test.dart'; | 43 import '../../generated/engine_test.dart'; |
43 import '../../generated/test_support.dart'; | 44 import '../../generated/test_support.dart'; |
44 import '../../reflective_tests.dart'; | 45 import '../../reflective_tests.dart'; |
45 import 'abstract_context.dart'; | 46 import 'abstract_context.dart'; |
46 import 'package:html/dom.dart' show Document; | |
47 | 47 |
48 main() { | 48 main() { |
49 groupSep = ' | '; | 49 groupSep = ' | '; |
50 runReflectiveTests(AnalysisContextImplTest); | 50 runReflectiveTests(AnalysisContextImplTest); |
51 } | 51 } |
52 | 52 |
53 @reflectiveTest | 53 @reflectiveTest |
54 class AnalysisContextImplTest extends AbstractContextTest { | 54 class AnalysisContextImplTest extends AbstractContextTest { |
55 void fail_applyChanges_empty() { | 55 void fail_applyChanges_empty() { |
56 context.applyChanges(new ChangeSet()); | 56 context.applyChanges(new ChangeSet()); |
57 expect(context.performAnalysisTask().changeNotices, isNull); | 57 expect(context.performAnalysisTask().changeNotices, isNull); |
58 // This test appears to be flaky. If it is named "test_" it fails, if it's | 58 // This test appears to be flaky. If it is named "test_" it fails, if it's |
59 // named "fail_" it doesn't fail. I'm guessing that it's dependent on | 59 // named "fail_" it doesn't fail. I'm guessing that it's dependent on |
60 // whether some other test is run. | 60 // whether some other test is run. |
61 fail('Should have failed'); | 61 fail('Should have failed'); |
62 } | 62 } |
63 | 63 |
64 void test_applyChanges_overriddenSource() { | |
65 // Note: addSource adds the source to the contentCache. | |
66 Source source = addSource("/test.dart", "library test;"); | |
67 context.computeErrors(source); | |
68 while (!context.sourcesNeedingProcessing.isEmpty) { | |
69 context.performAnalysisTask(); | |
70 } | |
71 // Adding the source as a changedSource should have no effect since | |
72 // it is already overridden in the content cache. | |
73 ChangeSet changeSet = new ChangeSet(); | |
74 changeSet.changedSource(source); | |
75 context.applyChanges(changeSet); | |
76 expect(context.sourcesNeedingProcessing, hasLength(0)); | |
77 } | |
78 | |
79 Future test_applyChanges_remove() { | |
80 SourcesChangedListener listener = new SourcesChangedListener(); | |
81 context.onSourcesChanged.listen(listener.onData); | |
82 String libAContents = r''' | |
83 library libA; | |
84 import 'libB.dart';'''; | |
85 Source libA = addSource("/libA.dart", libAContents); | |
86 String libBContents = "library libB;"; | |
87 Source libB = addSource("/libB.dart", libBContents); | |
88 LibraryElement libAElement = context.computeLibraryElement(libA); | |
89 expect(libAElement, isNotNull); | |
90 List<LibraryElement> importedLibraries = libAElement.importedLibraries; | |
91 expect(importedLibraries, hasLength(2)); | |
92 context.computeErrors(libA); | |
93 context.computeErrors(libB); | |
94 expect(context.sourcesNeedingProcessing, hasLength(0)); | |
95 context.setContents(libB, null); | |
96 _removeSource(libB); | |
97 List<Source> sources = context.sourcesNeedingProcessing; | |
98 expect(sources, hasLength(1)); | |
99 expect(sources[0], same(libA)); | |
100 libAElement = context.computeLibraryElement(libA); | |
101 importedLibraries = libAElement.importedLibraries; | |
102 expect(importedLibraries, hasLength(1)); | |
103 return pumpEventQueue().then((_) { | |
104 listener.assertEvent(wereSourcesAdded: true); | |
105 listener.assertEvent(wereSourcesAdded: true); | |
106 listener.assertEvent(wereSourcesRemovedOrDeleted: true); | |
107 listener.assertNoMoreEvents(); | |
108 }); | |
109 } | |
110 | |
111 Future test_applyChanges_removeContainer() { | |
112 SourcesChangedListener listener = new SourcesChangedListener(); | |
113 context.onSourcesChanged.listen(listener.onData); | |
114 String libAContents = r''' | |
115 library libA; | |
116 import 'libB.dart';'''; | |
117 Source libA = addSource("/libA.dart", libAContents); | |
118 String libBContents = "library libB;"; | |
119 Source libB = addSource("/libB.dart", libBContents); | |
120 context.computeLibraryElement(libA); | |
121 context.computeErrors(libA); | |
122 context.computeErrors(libB); | |
123 expect(context.sourcesNeedingProcessing, hasLength(0)); | |
124 ChangeSet changeSet = new ChangeSet(); | |
125 SourceContainer removedContainer = | |
126 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB); | |
127 changeSet.removedContainer(removedContainer); | |
128 context.applyChanges(changeSet); | |
129 List<Source> sources = context.sourcesNeedingProcessing; | |
130 expect(sources, hasLength(1)); | |
131 expect(sources[0], same(libA)); | |
132 return pumpEventQueue().then((_) { | |
133 listener.assertEvent(wereSourcesAdded: true); | |
134 listener.assertEvent(wereSourcesAdded: true); | |
135 listener.assertEvent(wereSourcesRemovedOrDeleted: true); | |
136 listener.assertNoMoreEvents(); | |
137 }); | |
138 } | |
139 | |
140 void test_computeErrors_dart_none() { | |
141 Source source = addSource("/lib.dart", "library lib;"); | |
142 List<AnalysisError> errors = context.computeErrors(source); | |
143 expect(errors, hasLength(0)); | |
144 } | |
145 | |
146 void test_computeErrors_dart_part() { | |
147 Source librarySource = | |
148 addSource("/lib.dart", "library lib; part 'part.dart';"); | |
149 Source partSource = addSource("/part.dart", "part of 'lib';"); | |
150 context.parseCompilationUnit(librarySource); | |
151 List<AnalysisError> errors = context.computeErrors(partSource); | |
152 expect(errors, isNotNull); | |
153 expect(errors.length > 0, isTrue); | |
154 } | |
155 | |
156 void test_computeErrors_dart_some() { | |
157 Source source = addSource("/lib.dart", "library 'lib';"); | |
158 List<AnalysisError> errors = context.computeErrors(source); | |
159 expect(errors, isNotNull); | |
160 expect(errors.length > 0, isTrue); | |
161 } | |
162 | |
163 void test_computeErrors_html_none() { | |
164 Source source = addSource("/test.html", "<!DOCTYPE html><html></html>"); | |
165 List<AnalysisError> errors = context.computeErrors(source); | |
166 expect(errors, hasLength(0)); | |
167 } | |
168 | |
169 void fail_computeHtmlElement_valid() { | 64 void fail_computeHtmlElement_valid() { |
170 Source source = addSource("/test.html", "<html></html>"); | 65 Source source = addSource("/test.html", "<html></html>"); |
171 HtmlElement element = context.computeHtmlElement(source); | 66 HtmlElement element = context.computeHtmlElement(source); |
172 expect(element, isNotNull); | 67 expect(element, isNotNull); |
173 expect(context.computeHtmlElement(source), same(element)); | 68 expect(context.computeHtmlElement(source), same(element)); |
174 } | 69 } |
175 | 70 |
176 void test_computeImportedLibraries_none() { | |
177 Source source = addSource("/test.dart", "library test;"); | |
178 expect(context.computeImportedLibraries(source), hasLength(0)); | |
179 } | |
180 | |
181 void test_computeImportedLibraries_some() { | |
182 Source source = addSource( | |
183 "/test.dart", "library test; import 'lib1.dart'; import 'lib2.dart';"); | |
184 expect(context.computeImportedLibraries(source), hasLength(2)); | |
185 } | |
186 | |
187 void fail_computeResolvableCompilationUnit_dart_exception() { | |
188 TestSource source = _addSourceWithException("/test.dart"); | |
189 try { | |
190 context.computeResolvableCompilationUnit(source); | |
191 fail("Expected AnalysisException"); | |
192 } on AnalysisException { | |
193 // Expected | |
194 } | |
195 } | |
196 | |
197 void fail_computeResolvableCompilationUnit_html_exception() { | |
198 Source source = addSource("/lib.html", "<html></html>"); | |
199 try { | |
200 context.computeResolvableCompilationUnit(source); | |
201 fail("Expected AnalysisException"); | |
202 } on AnalysisException { | |
203 // Expected | |
204 } | |
205 } | |
206 | |
207 void fail_computeResolvableCompilationUnit_valid() { | |
208 Source source = addSource("/lib.dart", "library lib;"); | |
209 CompilationUnit parsedUnit = context.parseCompilationUnit(source); | |
210 expect(parsedUnit, isNotNull); | |
211 CompilationUnit resolvedUnit = | |
212 context.computeResolvableCompilationUnit(source); | |
213 expect(resolvedUnit, isNotNull); | |
214 expect(resolvedUnit, same(parsedUnit)); | |
215 } | |
216 | |
217 Future test_computeResolvedCompilationUnitAsync_dispose() { | |
218 Source source = addSource("/lib.dart", "library lib;"); | |
219 // Complete all pending analysis tasks and flush the AST so that it won't | |
220 // be available immediately. | |
221 _performPendingAnalysisTasks(); | |
222 _flushAst(source); | |
223 bool completed = false; | |
224 CancelableFuture<CompilationUnit> future = | |
225 context.computeResolvedCompilationUnitAsync(source, source); | |
226 future.then((CompilationUnit unit) { | |
227 fail('Future should have completed with error'); | |
228 }, onError: (error) { | |
229 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); | |
230 completed = true; | |
231 }); | |
232 expect(completed, isFalse); | |
233 expect(context.pendingFutureSources_forTesting, isNotEmpty); | |
234 // Disposing of the context should cause all pending futures to complete | |
235 // with AnalysisNotScheduled, so that no clients are left hanging. | |
236 context.dispose(); | |
237 expect(context.pendingFutureSources_forTesting, isEmpty); | |
238 return pumpEventQueue().then((_) { | |
239 expect(completed, isTrue); | |
240 expect(context.pendingFutureSources_forTesting, isEmpty); | |
241 }); | |
242 } | |
243 | |
244 Future test_computeResolvedCompilationUnitAsync_noCacheEntry() { | |
245 Source librarySource = addSource("/lib.dart", "library lib;"); | |
246 Source partSource = addSource("/part.dart", "part of foo;"); | |
247 bool completed = false; | |
248 context | |
249 .computeResolvedCompilationUnitAsync(partSource, librarySource) | |
250 .then((CompilationUnit unit) { | |
251 expect(unit, isNotNull); | |
252 completed = true; | |
253 }); | |
254 return pumpEventQueue().then((_) { | |
255 expect(completed, isFalse); | |
256 _performPendingAnalysisTasks(); | |
257 }).then((_) => pumpEventQueue()).then((_) { | |
258 expect(completed, isTrue); | |
259 }); | |
260 } | |
261 | |
262 void fail_extractContext() { | 71 void fail_extractContext() { |
263 fail("Implement this"); | 72 fail("Implement this"); |
264 } | 73 } |
265 | 74 |
266 void test_getElement_constructor_named() { | |
267 Source source = addSource("/lib.dart", r''' | |
268 class A { | |
269 A.named() {} | |
270 }'''); | |
271 _analyzeAll_assertFinished(); | |
272 LibraryElement library = context.computeLibraryElement(source); | |
273 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); | |
274 ConstructorElement constructor = classA.constructors[0]; | |
275 ElementLocation location = constructor.location; | |
276 Element element = context.getElement(location); | |
277 expect(element, same(constructor)); | |
278 } | |
279 | |
280 void test_getElement_constructor_unnamed() { | |
281 Source source = addSource("/lib.dart", r''' | |
282 class A { | |
283 A() {} | |
284 }'''); | |
285 _analyzeAll_assertFinished(); | |
286 LibraryElement library = context.computeLibraryElement(source); | |
287 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); | |
288 ConstructorElement constructor = classA.constructors[0]; | |
289 ElementLocation location = constructor.location; | |
290 Element element = context.getElement(location); | |
291 expect(element, same(constructor)); | |
292 } | |
293 | |
294 void test_getElement_enum() { | |
295 Source source = addSource('/test.dart', 'enum MyEnum {A, B, C}'); | |
296 _analyzeAll_assertFinished(); | |
297 LibraryElement library = context.computeLibraryElement(source); | |
298 ClassElement myEnum = library.definingCompilationUnit.getEnum('MyEnum'); | |
299 ElementLocation location = myEnum.location; | |
300 Element element = context.getElement(location); | |
301 expect(element, same(myEnum)); | |
302 } | |
303 | |
304 void test_getErrors_dart_none() { | |
305 Source source = addSource("/lib.dart", "library lib;"); | |
306 var errorInfo = context.getErrors(source); | |
307 expect(errorInfo, isNotNull); | |
308 List<AnalysisError> errors = errorInfo.errors; | |
309 expect(errors, hasLength(0)); | |
310 context.computeErrors(source); | |
311 errors = errorInfo.errors; | |
312 expect(errors, hasLength(0)); | |
313 } | |
314 | |
315 void test_getErrors_dart_some() { | |
316 Source source = addSource("/lib.dart", "library 'lib';"); | |
317 var errorInfo = context.getErrors(source); | |
318 expect(errorInfo, isNotNull); | |
319 List<AnalysisError> errors = errorInfo.errors; | |
320 expect(errors, hasLength(0)); | |
321 errors = context.computeErrors(source); | |
322 expect(errors, hasLength(1)); | |
323 } | |
324 | |
325 void test_getErrors_html_none() { | |
326 Source source = addSource("/test.html", "<html></html>"); | |
327 AnalysisErrorInfo errorInfo = context.getErrors(source); | |
328 expect(errorInfo, isNotNull); | |
329 List<AnalysisError> errors = errorInfo.errors; | |
330 expect(errors, hasLength(0)); | |
331 context.computeErrors(source); | |
332 errors = errorInfo.errors; | |
333 expect(errors, hasLength(0)); | |
334 } | |
335 | |
336 void test_getErrors_html_some() { | |
337 Source source = addSource("/test.html", r''' | |
338 <html><head> | |
339 <script type='application/dart' src='test.dart'/> | |
340 </head></html>'''); | |
341 AnalysisErrorInfo errorInfo = context.getErrors(source); | |
342 expect(errorInfo, isNotNull); | |
343 List<AnalysisError> errors = errorInfo.errors; | |
344 expect(errors, hasLength(0)); | |
345 errors = context.computeErrors(source); | |
346 expect(errors, hasLength(3)); | |
347 } | |
348 | |
349 void fail_getHtmlElement_html() { | 75 void fail_getHtmlElement_html() { |
350 Source source = addSource("/test.html", "<html></html>"); | 76 Source source = addSource("/test.html", "<html></html>"); |
351 HtmlElement element = context.getHtmlElement(source); | 77 HtmlElement element = context.getHtmlElement(source); |
352 expect(element, isNull); | 78 expect(element, isNull); |
353 context.computeHtmlElement(source); | 79 context.computeHtmlElement(source); |
354 element = context.getHtmlElement(source); | 80 element = context.getHtmlElement(source); |
355 expect(element, isNotNull); | 81 expect(element, isNotNull); |
356 } | 82 } |
357 | 83 |
358 void test_getHtmlFilesReferencing_library() { | |
359 Source htmlSource = addSource("/test.html", r''' | |
360 <!DOCTYPE html> | |
361 <html><head> | |
362 <script type='application/dart' src='test.dart'/> | |
363 <script type='application/dart' src='test.js'/> | |
364 </head></html>'''); | |
365 Source librarySource = addSource("/test.dart", "library lib;"); | |
366 context.computeLibraryElement(librarySource); | |
367 List<Source> result = context.getHtmlFilesReferencing(librarySource); | |
368 expect(result, hasLength(0)); | |
369 context.computeHtmlElement(htmlSource); | |
370 result = context.getHtmlFilesReferencing(librarySource); | |
371 expect(result, hasLength(1)); | |
372 expect(result[0], htmlSource); | |
373 } | |
374 | |
375 void test_getHtmlFilesReferencing_part() { | |
376 Source htmlSource = addSource("/test.html", r''' | |
377 <!DOCTYPE html> | |
378 <html><head> | |
379 <script type='application/dart' src='test.dart'/> | |
380 <script type='application/dart' src='test.js'/> | |
381 </head></html>'''); | |
382 Source librarySource = | |
383 addSource("/test.dart", "library lib; part 'part.dart';"); | |
384 Source partSource = addSource("/part.dart", "part of lib;"); | |
385 context.computeLibraryElement(librarySource); | |
386 List<Source> result = context.getHtmlFilesReferencing(partSource); | |
387 expect(result, hasLength(0)); | |
388 context.computeHtmlElement(htmlSource); | |
389 result = context.getHtmlFilesReferencing(partSource); | |
390 expect(result, hasLength(1)); | |
391 expect(result[0], htmlSource); | |
392 } | |
393 | |
394 void test_getHtmlSources() { | |
395 List<Source> sources = context.htmlSources; | |
396 expect(sources, hasLength(0)); | |
397 Source source = addSource("/test.html", ""); | |
398 sources = context.htmlSources; | |
399 expect(sources, hasLength(1)); | |
400 expect(sources[0], source); | |
401 } | |
402 | |
403 void test_getLibrariesReferencedFromHtml() { | |
404 Source htmlSource = addSource("/test.html", r''' | |
405 <!DOCTYPE html> | |
406 <html><head> | |
407 <script type='application/dart' src='test.dart'/> | |
408 <script type='application/dart' src='test.js'/> | |
409 </head></html>'''); | |
410 Source librarySource = addSource("/test.dart", "library lib;"); | |
411 context.computeLibraryElement(librarySource); | |
412 context.computeHtmlElement(htmlSource); | |
413 List<Source> result = context.getLibrariesReferencedFromHtml(htmlSource); | |
414 expect(result, hasLength(1)); | |
415 expect(result[0], librarySource); | |
416 } | |
417 | |
418 void test_getResolvedCompilationUnit_library() { | |
419 Source source = addSource("/lib.dart", "library libb;"); | |
420 LibraryElement library = context.computeLibraryElement(source); | |
421 context.computeErrors(source); // Force the resolved unit to be built. | |
422 expect(context.getResolvedCompilationUnit(source, library), isNotNull); | |
423 context.setContents(source, "library lib;"); | |
424 expect(context.getResolvedCompilationUnit(source, library), isNull); | |
425 } | |
426 | |
427 void fail_getResolvedHtmlUnit() { | 84 void fail_getResolvedHtmlUnit() { |
428 Source source = addSource("/test.html", "<html></html>"); | 85 Source source = addSource("/test.html", "<html></html>"); |
429 expect(context.getResolvedHtmlUnit(source), isNull); | 86 expect(context.getResolvedHtmlUnit(source), isNull); |
430 context.resolveHtmlUnit(source); | 87 context.resolveHtmlUnit(source); |
431 expect(context.getResolvedHtmlUnit(source), isNotNull); | 88 expect(context.getResolvedHtmlUnit(source), isNotNull); |
432 } | 89 } |
433 | 90 |
434 void fail_mergeContext() { | 91 void fail_mergeContext() { |
435 fail("Implement this"); | 92 fail("Implement this"); |
436 } | 93 } |
437 | 94 |
438 void test_parseDocument() { | |
439 Source source = addSource("/lib.html", "<!DOCTYPE html><html></html>"); | |
440 Document unit = context.parseHtmlDocument(source); | |
441 expect(unit, isNotNull); | |
442 } | |
443 | |
444 void fail_parseHtmlUnit_noErrors() { | |
445 Source source = addSource("/lib.html", "<html></html>"); | |
446 ht.HtmlUnit unit = context.parseHtmlUnit(source); | |
447 expect(unit, isNotNull); | |
448 } | |
449 | |
450 void fail_parseHtmlUnit_resolveDirectives() { | 95 void fail_parseHtmlUnit_resolveDirectives() { |
451 Source libSource = addSource("/lib.dart", r''' | 96 Source libSource = addSource("/lib.dart", r''' |
452 library lib; | 97 library lib; |
453 class ClassA {}'''); | 98 class ClassA {}'''); |
454 Source source = addSource("/lib.html", r''' | 99 Source source = addSource("/lib.html", r''' |
455 <!DOCTYPE html> | 100 <!DOCTYPE html> |
456 <html> | 101 <html> |
457 <head> | 102 <head> |
458 <script type='application/dart'> | 103 <script type='application/dart'> |
459 import 'lib.dart'; | 104 import 'lib.dart'; |
460 ClassA v = null; | 105 ClassA v = null; |
461 </script> | 106 </script> |
462 </head> | 107 </head> |
463 <body> | 108 <body> |
464 </body> | 109 </body> |
465 </html>'''); | 110 </html>'''); |
466 ht.HtmlUnit unit = context.parseHtmlUnit(source); | 111 ht.HtmlUnit unit = context.parseHtmlUnit(source); |
467 expect(unit, isNotNull); | 112 expect(unit, isNotNull); |
468 // import directive should be resolved | 113 // import directive should be resolved |
469 ht.XmlTagNode htmlNode = unit.tagNodes[0]; | 114 ht.XmlTagNode htmlNode = unit.tagNodes[0]; |
470 ht.XmlTagNode headNode = htmlNode.tagNodes[0]; | 115 ht.XmlTagNode headNode = htmlNode.tagNodes[0]; |
471 ht.HtmlScriptTagNode scriptNode = headNode.tagNodes[0]; | 116 ht.HtmlScriptTagNode scriptNode = headNode.tagNodes[0]; |
472 CompilationUnit script = scriptNode.script; | 117 CompilationUnit script = scriptNode.script; |
473 ImportDirective importNode = script.directives[0] as ImportDirective; | 118 ImportDirective importNode = script.directives[0] as ImportDirective; |
474 expect(importNode.uriContent, isNotNull); | 119 expect(importNode.uriContent, isNotNull); |
475 expect(importNode.source, libSource); | 120 expect(importNode.source, libSource); |
476 } | 121 } |
477 | 122 |
478 void test_performAnalysisTask_addPart() { | |
479 Source libSource = addSource("/lib.dart", r''' | |
480 library lib; | |
481 part 'part.dart';'''); | |
482 // run all tasks without part | |
483 _analyzeAll_assertFinished(); | |
484 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libSource)), | |
485 isTrue, reason: "lib has errors"); | |
486 // add part and run all tasks | |
487 Source partSource = addSource("/part.dart", r''' | |
488 part of lib; | |
489 '''); | |
490 _analyzeAll_assertFinished(); | |
491 // "libSource" should be here | |
492 List<Source> librariesWithPart = context.getLibrariesContaining(partSource); | |
493 expect(librariesWithPart, unorderedEquals([libSource])); | |
494 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libSource)), | |
495 isFalse, reason: "lib doesn't have errors"); | |
496 expect( | |
497 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | |
498 reason: "part resolved"); | |
499 } | |
500 | |
501 void test_performAnalysisTask_changeLibraryContents() { | |
502 Source libSource = | |
503 addSource("/test.dart", "library lib; part 'test-part.dart';"); | |
504 Source partSource = addSource("/test-part.dart", "part of lib;"); | |
505 _analyzeAll_assertFinished(); | |
506 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
507 reason: "library resolved 1"); | |
508 expect( | |
509 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | |
510 reason: "part resolved 1"); | |
511 // update and analyze #1 | |
512 context.setContents(libSource, "library lib;"); | |
513 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, | |
514 reason: "library changed 2"); | |
515 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | |
516 reason: "part changed 2"); | |
517 _analyzeAll_assertFinished(); | |
518 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
519 reason: "library resolved 2"); | |
520 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | |
521 reason: "part resolved 2"); | |
522 // update and analyze #2 | |
523 context.setContents(libSource, "library lib; part 'test-part.dart';"); | |
524 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, | |
525 reason: "library changed 3"); | |
526 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | |
527 reason: "part changed 3"); | |
528 _analyzeAll_assertFinished(); | |
529 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
530 reason: "library resolved 2"); | |
531 expect( | |
532 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | |
533 reason: "part resolved 3"); | |
534 } | |
535 | |
536 void test_performAnalysisTask_changeLibraryThenPartContents() { | |
537 Source libSource = | |
538 addSource("/test.dart", "library lib; part 'test-part.dart';"); | |
539 Source partSource = addSource("/test-part.dart", "part of lib;"); | |
540 _analyzeAll_assertFinished(); | |
541 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
542 reason: "library resolved 1"); | |
543 expect( | |
544 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | |
545 reason: "part resolved 1"); | |
546 // update and analyze #1 | |
547 context.setContents(libSource, "library lib;"); | |
548 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, | |
549 reason: "library changed 2"); | |
550 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | |
551 reason: "part changed 2"); | |
552 _analyzeAll_assertFinished(); | |
553 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
554 reason: "library resolved 2"); | |
555 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | |
556 reason: "part resolved 2"); | |
557 // update and analyze #2 | |
558 context.setContents(partSource, "part of lib; // 1"); | |
559 // Assert that changing the part's content does not effect the library | |
560 // now that it is no longer part of that library | |
561 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
562 reason: "library changed 3"); | |
563 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | |
564 reason: "part changed 3"); | |
565 _analyzeAll_assertFinished(); | |
566 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
567 reason: "library resolved 3"); | |
568 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | |
569 reason: "part resolved 3"); | |
570 } | |
571 | |
572 void test_performAnalysisTask_changePartContents_makeItAPart() { | |
573 Source libSource = addSource("/lib.dart", r''' | |
574 library lib; | |
575 part 'part.dart'; | |
576 void f(x) {}'''); | |
577 Source partSource = addSource("/part.dart", "void g() { f(null); }"); | |
578 _analyzeAll_assertFinished(); | |
579 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
580 reason: "library resolved 1"); | |
581 expect( | |
582 context.getResolvedCompilationUnit2(partSource, partSource), isNotNull, | |
583 reason: "part resolved 1"); | |
584 // update and analyze | |
585 context.setContents(partSource, r''' | |
586 part of lib; | |
587 void g() { f(null); }'''); | |
588 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, | |
589 reason: "library changed 2"); | |
590 expect(context.getResolvedCompilationUnit2(partSource, partSource), isNull, | |
591 reason: "part changed 2"); | |
592 _analyzeAll_assertFinished(); | |
593 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
594 reason: "library resolved 2"); | |
595 expect( | |
596 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | |
597 reason: "part resolved 2"); | |
598 expect(context.getErrors(libSource).errors, hasLength(0)); | |
599 expect(context.getErrors(partSource).errors, hasLength(0)); | |
600 } | |
601 | |
602 /** | |
603 * https://code.google.com/p/dart/issues/detail?id=12424 | |
604 */ | |
605 void test_performAnalysisTask_changePartContents_makeItNotPart() { | |
606 Source libSource = addSource("/lib.dart", r''' | |
607 library lib; | |
608 part 'part.dart'; | |
609 void f(x) {}'''); | |
610 Source partSource = addSource("/part.dart", r''' | |
611 part of lib; | |
612 void g() { f(null); }'''); | |
613 _analyzeAll_assertFinished(); | |
614 expect(context.getErrors(libSource).errors, hasLength(0)); | |
615 expect(context.getErrors(partSource).errors, hasLength(0)); | |
616 // Remove 'part' directive, which should make "f(null)" an error. | |
617 context.setContents(partSource, r''' | |
618 //part of lib; | |
619 void g() { f(null); }'''); | |
620 _analyzeAll_assertFinished(); | |
621 expect(context.getErrors(libSource).errors.length != 0, isTrue); | |
622 } | |
623 | |
624 void test_performAnalysisTask_changePartContents_noSemanticChanges() { | |
625 Source libSource = | |
626 addSource("/test.dart", "library lib; part 'test-part.dart';"); | |
627 Source partSource = addSource("/test-part.dart", "part of lib;"); | |
628 _analyzeAll_assertFinished(); | |
629 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
630 reason: "library resolved 1"); | |
631 expect( | |
632 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | |
633 reason: "part resolved 1"); | |
634 // update and analyze #1 | |
635 context.setContents(partSource, "part of lib; // 1"); | |
636 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, | |
637 reason: "library changed 2"); | |
638 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | |
639 reason: "part changed 2"); | |
640 _analyzeAll_assertFinished(); | |
641 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
642 reason: "library resolved 2"); | |
643 expect( | |
644 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | |
645 reason: "part resolved 2"); | |
646 // update and analyze #2 | |
647 context.setContents(partSource, "part of lib; // 12"); | |
648 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, | |
649 reason: "library changed 3"); | |
650 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | |
651 reason: "part changed 3"); | |
652 _analyzeAll_assertFinished(); | |
653 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | |
654 reason: "library resolved 3"); | |
655 expect( | |
656 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | |
657 reason: "part resolved 3"); | |
658 } | |
659 | |
660 void fail_performAnalysisTask_getContentException_dart() { | 123 void fail_performAnalysisTask_getContentException_dart() { |
661 // add source that throw an exception on "get content" | 124 // add source that throw an exception on "get content" |
662 Source source = new _Source_getContent_throwException('test.dart'); | 125 Source source = new _Source_getContent_throwException('test.dart'); |
663 { | 126 { |
664 ChangeSet changeSet = new ChangeSet(); | 127 ChangeSet changeSet = new ChangeSet(); |
665 changeSet.addedSource(source); | 128 changeSet.addedSource(source); |
666 context.applyChanges(changeSet); | 129 context.applyChanges(changeSet); |
667 } | 130 } |
668 // prepare errors | 131 // prepare errors |
669 _analyzeAll_assertFinished(); | 132 _analyzeAll_assertFinished(); |
(...skipping 16 matching lines...) Expand all Loading... |
686 // prepare errors | 149 // prepare errors |
687 _analyzeAll_assertFinished(); | 150 _analyzeAll_assertFinished(); |
688 List<AnalysisError> errors = context.getErrors(source).errors; | 151 List<AnalysisError> errors = context.getErrors(source).errors; |
689 // validate errors | 152 // validate errors |
690 expect(errors, hasLength(1)); | 153 expect(errors, hasLength(1)); |
691 AnalysisError error = errors[0]; | 154 AnalysisError error = errors[0]; |
692 expect(error.source, same(source)); | 155 expect(error.source, same(source)); |
693 expect(error.errorCode, ScannerErrorCode.UNABLE_GET_CONTENT); | 156 expect(error.errorCode, ScannerErrorCode.UNABLE_GET_CONTENT); |
694 } | 157 } |
695 | 158 |
696 void test_performAnalysisTask_importedLibraryAdd() { | |
697 Source libASource = | |
698 addSource("/libA.dart", "library libA; import 'libB.dart';"); | |
699 _analyzeAll_assertFinished(); | |
700 expect( | |
701 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull, | |
702 reason: "libA resolved 1"); | |
703 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), | |
704 isTrue, reason: "libA has an error"); | |
705 // add libB.dart and analyze | |
706 Source libBSource = addSource("/libB.dart", "library libB;"); | |
707 _analyzeAll_assertFinished(); | |
708 expect( | |
709 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull, | |
710 reason: "libA resolved 2"); | |
711 expect( | |
712 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, | |
713 reason: "libB resolved 2"); | |
714 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), | |
715 isFalse, reason: "libA doesn't have errors"); | |
716 } | |
717 | |
718 void fail_performAnalysisTask_importedLibraryAdd_html() { | 159 void fail_performAnalysisTask_importedLibraryAdd_html() { |
719 Source htmlSource = addSource("/page.html", r''' | 160 Source htmlSource = addSource("/page.html", r''' |
720 <html><body><script type="application/dart"> | 161 <html><body><script type="application/dart"> |
721 import '/libB.dart'; | 162 import '/libB.dart'; |
722 main() {print('hello dart');} | 163 main() {print('hello dart');} |
723 </script></body></html>'''); | 164 </script></body></html>'''); |
724 _analyzeAll_assertFinished(); | 165 _analyzeAll_assertFinished(); |
725 expect(context.getResolvedHtmlUnit(htmlSource), isNotNull, | 166 expect(context.getResolvedHtmlUnit(htmlSource), isNotNull, |
726 reason: "htmlUnit resolved 1"); | 167 reason: "htmlUnit resolved 1"); |
727 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(htmlSource)), | 168 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(htmlSource)), |
728 isTrue, reason: "htmlSource has an error"); | 169 isTrue, reason: "htmlSource has an error"); |
729 // add libB.dart and analyze | 170 // add libB.dart and analyze |
730 Source libBSource = addSource("/libB.dart", "library libB;"); | 171 Source libBSource = addSource("/libB.dart", "library libB;"); |
731 _analyzeAll_assertFinished(); | 172 _analyzeAll_assertFinished(); |
732 expect(context.getResolvedHtmlUnit(htmlSource), isNotNull, | 173 expect(context.getResolvedHtmlUnit(htmlSource), isNotNull, |
733 reason: "htmlUnit resolved 1"); | 174 reason: "htmlUnit resolved 1"); |
734 expect( | 175 expect( |
735 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, | 176 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, |
736 reason: "libB resolved 2"); | 177 reason: "libB resolved 2"); |
737 // TODO (danrubel) commented out to fix red bots | 178 // TODO (danrubel) commented out to fix red bots |
738 // AnalysisErrorInfo errors = _context.getErrors(htmlSource); | 179 // AnalysisErrorInfo errors = _context.getErrors(htmlSource); |
739 // expect( | 180 // expect( |
740 // !_hasAnalysisErrorWithErrorSeverity(errors), | 181 // !_hasAnalysisErrorWithErrorSeverity(errors), |
741 // isTrue, | 182 // isTrue, |
742 // reason: "htmlSource doesn't have errors"); | 183 // reason: "htmlSource doesn't have errors"); |
743 } | 184 } |
744 | 185 |
745 void test_performAnalysisTask_importedLibraryDelete() { | |
746 Source libASource = | |
747 addSource("/libA.dart", "library libA; import 'libB.dart';"); | |
748 Source libBSource = addSource("/libB.dart", "library libB;"); | |
749 _analyzeAll_assertFinished(); | |
750 expect( | |
751 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull, | |
752 reason: "libA resolved 1"); | |
753 expect( | |
754 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, | |
755 reason: "libB resolved 1"); | |
756 expect(!_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), | |
757 isTrue, reason: "libA doesn't have errors"); | |
758 // remove libB.dart and analyze | |
759 _removeSource(libBSource); | |
760 _analyzeAll_assertFinished(); | |
761 expect( | |
762 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull, | |
763 reason: "libA resolved 2"); | |
764 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), | |
765 isTrue, reason: "libA has an error"); | |
766 } | |
767 | |
768 void fail_performAnalysisTask_importedLibraryDelete_html() { | 186 void fail_performAnalysisTask_importedLibraryDelete_html() { |
769 // NOTE: This was failing before converting to the new task model. | 187 // NOTE: This was failing before converting to the new task model. |
770 Source htmlSource = addSource("/page.html", r''' | 188 Source htmlSource = addSource("/page.html", r''' |
771 <html><body><script type="application/dart"> | 189 <html><body><script type="application/dart"> |
772 import 'libB.dart'; | 190 import 'libB.dart'; |
773 main() {print('hello dart');} | 191 main() {print('hello dart');} |
774 </script></body></html>'''); | 192 </script></body></html>'''); |
775 Source libBSource = addSource("/libB.dart", "library libB;"); | 193 Source libBSource = addSource("/libB.dart", "library libB;"); |
776 _analyzeAll_assertFinished(); | 194 _analyzeAll_assertFinished(); |
777 expect(context.getResolvedHtmlUnit(htmlSource), isNotNull, | 195 expect(context.getResolvedHtmlUnit(htmlSource), isNotNull, |
778 reason: "htmlUnit resolved 1"); | 196 reason: "htmlUnit resolved 1"); |
779 expect( | 197 expect( |
780 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, | 198 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, |
781 reason: "libB resolved 1"); | 199 reason: "libB resolved 1"); |
782 expect(!_hasAnalysisErrorWithErrorSeverity(context.getErrors(htmlSource)), | 200 expect(!_hasAnalysisErrorWithErrorSeverity(context.getErrors(htmlSource)), |
783 isTrue, reason: "htmlSource doesn't have errors"); | 201 isTrue, reason: "htmlSource doesn't have errors"); |
784 // remove libB.dart content and analyze | 202 // remove libB.dart content and analyze |
785 context.setContents(libBSource, null); | 203 context.setContents(libBSource, null); |
786 _analyzeAll_assertFinished(); | 204 _analyzeAll_assertFinished(); |
787 expect(context.getResolvedHtmlUnit(htmlSource), isNotNull, | 205 expect(context.getResolvedHtmlUnit(htmlSource), isNotNull, |
788 reason: "htmlUnit resolved 1"); | 206 reason: "htmlUnit resolved 1"); |
789 AnalysisErrorInfo errors = context.getErrors(htmlSource); | 207 AnalysisErrorInfo errors = context.getErrors(htmlSource); |
790 expect(_hasAnalysisErrorWithErrorSeverity(errors), isTrue, | 208 expect(_hasAnalysisErrorWithErrorSeverity(errors), isTrue, |
791 reason: "htmlSource has an error"); | 209 reason: "htmlSource has an error"); |
792 } | 210 } |
793 | 211 |
794 void test_performAnalysisTask_onResultComputed() { | |
795 Set<String> libraryElementUris = new Set<String>(); | |
796 Set<String> parsedUnitUris = new Set<String>(); | |
797 Set<String> resolvedUnitUris = new Set<String>(); | |
798 // listen | |
799 context.onResultComputed(LIBRARY_ELEMENT).listen((event) { | |
800 Source librarySource = event.target; | |
801 libraryElementUris.add(librarySource.uri.toString()); | |
802 }); | |
803 context.onResultComputed(PARSED_UNIT).listen((event) { | |
804 Source source = event.target; | |
805 parsedUnitUris.add(source.uri.toString()); | |
806 }); | |
807 context.onResultComputed(RESOLVED_UNIT).listen((event) { | |
808 LibrarySpecificUnit target = event.target; | |
809 Source librarySource = target.library; | |
810 resolvedUnitUris.add(librarySource.uri.toString()); | |
811 }); | |
812 // analyze | |
813 addSource('/test.dart', 'main() {}'); | |
814 _analyzeAll_assertFinished(); | |
815 // verify | |
816 expect(libraryElementUris, contains('dart:core')); | |
817 expect(libraryElementUris, contains('file:///test.dart')); | |
818 expect(parsedUnitUris, contains('dart:core')); | |
819 expect(parsedUnitUris, contains('file:///test.dart')); | |
820 expect(resolvedUnitUris, contains('dart:core')); | |
821 expect(resolvedUnitUris, contains('file:///test.dart')); | |
822 } | |
823 | |
824 void fail_performAnalysisTask_IOException() { | 212 void fail_performAnalysisTask_IOException() { |
825 TestSource source = _addSourceWithException2("/test.dart", "library test;"); | 213 TestSource source = _addSourceWithException2("/test.dart", "library test;"); |
826 int oldTimestamp = context.getModificationStamp(source); | 214 int oldTimestamp = context.getModificationStamp(source); |
827 source.generateExceptionOnRead = false; | 215 source.generateExceptionOnRead = false; |
828 _analyzeAll_assertFinished(); | 216 _analyzeAll_assertFinished(); |
829 expect(source.readCount, 1); | 217 expect(source.readCount, 1); |
830 source.generateExceptionOnRead = true; | 218 source.generateExceptionOnRead = true; |
831 do { | 219 do { |
832 _changeSource(source, ""); | 220 _changeSource(source, ""); |
833 // Ensure that the timestamp differs, | 221 // Ensure that the timestamp differs, |
834 // so that analysis engine notices the change | 222 // so that analysis engine notices the change |
835 } while (oldTimestamp == context.getModificationStamp(source)); | 223 } while (oldTimestamp == context.getModificationStamp(source)); |
836 _analyzeAll_assertFinished(); | 224 _analyzeAll_assertFinished(); |
837 expect(source.readCount, 2); | 225 expect(source.readCount, 2); |
838 } | 226 } |
839 | 227 |
840 void test_performAnalysisTask_missingPart() { | |
841 Source source = | |
842 addSource("/test.dart", "library lib; part 'no-such-file.dart';"); | |
843 _analyzeAll_assertFinished(); | |
844 expect(context.getLibraryElement(source), isNotNull, | |
845 reason: "performAnalysisTask failed to compute an element model"); | |
846 } | |
847 | |
848 void fail_recordLibraryElements() { | 228 void fail_recordLibraryElements() { |
849 fail("Implement this"); | 229 fail("Implement this"); |
850 } | 230 } |
851 | 231 |
852 void test_resolveCompilationUnit_import_relative() { | |
853 Source sourceA = | |
854 addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}"); | |
855 addSource("/libB.dart", "library libB; class B{}"); | |
856 CompilationUnit compilationUnit = | |
857 context.resolveCompilationUnit2(sourceA, sourceA); | |
858 expect(compilationUnit, isNotNull); | |
859 LibraryElement library = compilationUnit.element.library; | |
860 List<LibraryElement> importedLibraries = library.importedLibraries; | |
861 assertNamedElements(importedLibraries, ["dart.core", "libB"]); | |
862 List<LibraryElement> visibleLibraries = library.visibleLibraries; | |
863 assertNamedElements(visibleLibraries, [ | |
864 "dart.core", | |
865 "dart.async", | |
866 "dart.math", | |
867 "libA", | |
868 "libB" | |
869 ]); | |
870 } | |
871 | |
872 void test_resolveCompilationUnit_import_relative_cyclic() { | |
873 Source sourceA = | |
874 addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}"); | |
875 addSource("/libB.dart", "library libB; import 'libA.dart'; class B{}"); | |
876 CompilationUnit compilationUnit = | |
877 context.resolveCompilationUnit2(sourceA, sourceA); | |
878 expect(compilationUnit, isNotNull); | |
879 LibraryElement library = compilationUnit.element.library; | |
880 List<LibraryElement> importedLibraries = library.importedLibraries; | |
881 assertNamedElements(importedLibraries, ["dart.core", "libB"]); | |
882 List<LibraryElement> visibleLibraries = library.visibleLibraries; | |
883 assertNamedElements(visibleLibraries, [ | |
884 "dart.core", | |
885 "dart.async", | |
886 "dart.math", | |
887 "libA", | |
888 "libB" | |
889 ]); | |
890 } | |
891 | |
892 void fail_resolveHtmlUnit() { | 232 void fail_resolveHtmlUnit() { |
893 Source source = addSource("/lib.html", "<html></html>"); | 233 Source source = addSource("/lib.html", "<html></html>"); |
894 ht.HtmlUnit unit = context.resolveHtmlUnit(source); | 234 ht.HtmlUnit unit = context.resolveHtmlUnit(source); |
895 expect(unit, isNotNull); | 235 expect(unit, isNotNull); |
896 } | 236 } |
897 | 237 |
898 void fail_setAnalysisOptions_reduceAnalysisPriorityOrder() { | 238 void fail_setAnalysisOptions_reduceAnalysisPriorityOrder() { |
899 AnalysisOptionsImpl options = | 239 AnalysisOptionsImpl options = |
900 new AnalysisOptionsImpl.from(context.analysisOptions); | 240 new AnalysisOptionsImpl.from(context.analysisOptions); |
901 List<Source> sources = new List<Source>(); | 241 List<Source> sources = new List<Source>(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 return pumpEventQueue().then((_) { | 296 return pumpEventQueue().then((_) { |
957 listener.assertEvent(wereSourcesAdded: true); | 297 listener.assertEvent(wereSourcesAdded: true); |
958 listener.assertEvent(changedSources: [librarySource]); | 298 listener.assertEvent(changedSources: [librarySource]); |
959 listener.assertEvent(wereSourcesAdded: true); | 299 listener.assertEvent(wereSourcesAdded: true); |
960 listener.assertEvent(changedSources: [partSource]); | 300 listener.assertEvent(changedSources: [partSource]); |
961 listener.assertEvent(changedSources: [librarySource]); | 301 listener.assertEvent(changedSources: [librarySource]); |
962 listener.assertNoMoreEvents(); | 302 listener.assertNoMoreEvents(); |
963 }); | 303 }); |
964 } | 304 } |
965 | 305 |
966 void test_setContents_unchanged_consistentModificationTime() { | |
967 String contents = "// foo"; | |
968 Source source = addSource("/test.dart", contents); | |
969 context.setContents(source, contents); | |
970 // do all, no tasks | |
971 _analyzeAll_assertFinished(); | |
972 { | |
973 AnalysisResult result = context.performAnalysisTask(); | |
974 expect(result.changeNotices, isNull); | |
975 } | |
976 // set the same contents, still no tasks | |
977 context.setContents(source, contents); | |
978 { | |
979 AnalysisResult result = context.performAnalysisTask(); | |
980 expect(result.changeNotices, isNull); | |
981 } | |
982 } | |
983 | |
984 void fail_unreadableSource() { | 306 void fail_unreadableSource() { |
985 Source test1 = addSource("/test1.dart", r''' | 307 Source test1 = addSource("/test1.dart", r''' |
986 import 'test2.dart'; | 308 import 'test2.dart'; |
987 library test1;'''); | 309 library test1;'''); |
988 Source test2 = addSource("/test2.dart", r''' | 310 Source test2 = addSource("/test2.dart", r''' |
989 import 'test1.dart'; | 311 import 'test1.dart'; |
990 import 'test3.dart'; | 312 import 'test3.dart'; |
991 library test2;'''); | 313 library test2;'''); |
992 Source test3 = _addSourceWithException("/test3.dart"); | 314 Source test3 = _addSourceWithException("/test3.dart"); |
993 _analyzeAll_assertFinished(); | 315 _analyzeAll_assertFinished(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 ChangeSet changeSet2 = new ChangeSet(); | 455 ChangeSet changeSet2 = new ChangeSet(); |
1134 changeSet2.addedSource(source2); | 456 changeSet2.addedSource(source2); |
1135 changeSet2.changedRange(source, 'library test;', 0, 0, 13); | 457 changeSet2.changedRange(source, 'library test;', 0, 0, 13); |
1136 context.applyChanges(changeSet2); | 458 context.applyChanges(changeSet2); |
1137 return pumpEventQueue().then((_) { | 459 return pumpEventQueue().then((_) { |
1138 listener.assertEvent(wereSourcesAdded: true); | 460 listener.assertEvent(wereSourcesAdded: true); |
1139 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); | 461 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); |
1140 listener.assertNoMoreEvents(); | 462 listener.assertNoMoreEvents(); |
1141 }); | 463 }); |
1142 } | 464 } |
| 465 |
| 466 void test_applyChanges_overriddenSource() { |
| 467 // Note: addSource adds the source to the contentCache. |
| 468 Source source = addSource("/test.dart", "library test;"); |
| 469 context.computeErrors(source); |
| 470 while (!context.sourcesNeedingProcessing.isEmpty) { |
| 471 context.performAnalysisTask(); |
| 472 } |
| 473 // Adding the source as a changedSource should have no effect since |
| 474 // it is already overridden in the content cache. |
| 475 ChangeSet changeSet = new ChangeSet(); |
| 476 changeSet.changedSource(source); |
| 477 context.applyChanges(changeSet); |
| 478 expect(context.sourcesNeedingProcessing, hasLength(0)); |
| 479 } |
| 480 |
| 481 Future test_applyChanges_remove() { |
| 482 SourcesChangedListener listener = new SourcesChangedListener(); |
| 483 context.onSourcesChanged.listen(listener.onData); |
| 484 String libAContents = r''' |
| 485 library libA; |
| 486 import 'libB.dart';'''; |
| 487 Source libA = addSource("/libA.dart", libAContents); |
| 488 String libBContents = "library libB;"; |
| 489 Source libB = addSource("/libB.dart", libBContents); |
| 490 LibraryElement libAElement = context.computeLibraryElement(libA); |
| 491 expect(libAElement, isNotNull); |
| 492 List<LibraryElement> importedLibraries = libAElement.importedLibraries; |
| 493 expect(importedLibraries, hasLength(2)); |
| 494 context.computeErrors(libA); |
| 495 context.computeErrors(libB); |
| 496 expect(context.sourcesNeedingProcessing, hasLength(0)); |
| 497 context.setContents(libB, null); |
| 498 _removeSource(libB); |
| 499 List<Source> sources = context.sourcesNeedingProcessing; |
| 500 expect(sources, hasLength(1)); |
| 501 expect(sources[0], same(libA)); |
| 502 libAElement = context.computeLibraryElement(libA); |
| 503 importedLibraries = libAElement.importedLibraries; |
| 504 expect(importedLibraries, hasLength(1)); |
| 505 return pumpEventQueue().then((_) { |
| 506 listener.assertEvent(wereSourcesAdded: true); |
| 507 listener.assertEvent(wereSourcesAdded: true); |
| 508 listener.assertEvent(wereSourcesRemovedOrDeleted: true); |
| 509 listener.assertNoMoreEvents(); |
| 510 }); |
| 511 } |
| 512 |
| 513 Future test_applyChanges_removeContainer() { |
| 514 SourcesChangedListener listener = new SourcesChangedListener(); |
| 515 context.onSourcesChanged.listen(listener.onData); |
| 516 String libAContents = r''' |
| 517 library libA; |
| 518 import 'libB.dart';'''; |
| 519 Source libA = addSource("/libA.dart", libAContents); |
| 520 String libBContents = "library libB;"; |
| 521 Source libB = addSource("/libB.dart", libBContents); |
| 522 context.computeLibraryElement(libA); |
| 523 context.computeErrors(libA); |
| 524 context.computeErrors(libB); |
| 525 expect(context.sourcesNeedingProcessing, hasLength(0)); |
| 526 ChangeSet changeSet = new ChangeSet(); |
| 527 SourceContainer removedContainer = |
| 528 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB); |
| 529 changeSet.removedContainer(removedContainer); |
| 530 context.applyChanges(changeSet); |
| 531 List<Source> sources = context.sourcesNeedingProcessing; |
| 532 expect(sources, hasLength(1)); |
| 533 expect(sources[0], same(libA)); |
| 534 return pumpEventQueue().then((_) { |
| 535 listener.assertEvent(wereSourcesAdded: true); |
| 536 listener.assertEvent(wereSourcesAdded: true); |
| 537 listener.assertEvent(wereSourcesRemovedOrDeleted: true); |
| 538 listener.assertNoMoreEvents(); |
| 539 }); |
| 540 } |
1143 | 541 |
1144 void test_computeDocumentationComment_block() { | 542 void test_computeDocumentationComment_block() { |
1145 String comment = "/** Comment */"; | 543 String comment = "/** Comment */"; |
1146 Source source = addSource("/test.dart", """ | 544 Source source = addSource("/test.dart", """ |
1147 $comment | 545 $comment |
1148 class A {}"""); | 546 class A {}"""); |
1149 LibraryElement libraryElement = context.computeLibraryElement(source); | 547 LibraryElement libraryElement = context.computeLibraryElement(source); |
1150 expect(libraryElement, isNotNull); | 548 expect(libraryElement, isNotNull); |
1151 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 549 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
1152 expect(libraryElement, isNotNull); | 550 expect(libraryElement, isNotNull); |
(...skipping 28 matching lines...) Expand all Loading... |
1181 String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n"; | 579 String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n"; |
1182 Source source = addSource("/test.dart", "${comment}class A {}"); | 580 Source source = addSource("/test.dart", "${comment}class A {}"); |
1183 LibraryElement libraryElement = context.computeLibraryElement(source); | 581 LibraryElement libraryElement = context.computeLibraryElement(source); |
1184 expect(libraryElement, isNotNull); | 582 expect(libraryElement, isNotNull); |
1185 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 583 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
1186 expect(libraryElement, isNotNull); | 584 expect(libraryElement, isNotNull); |
1187 String actual = context.computeDocumentationComment(classElement); | 585 String actual = context.computeDocumentationComment(classElement); |
1188 expect(actual, "/// line 1\n/// line 2\n/// line 3"); | 586 expect(actual, "/// line 1\n/// line 2\n/// line 3"); |
1189 } | 587 } |
1190 | 588 |
| 589 void test_computeErrors_dart_none() { |
| 590 Source source = addSource("/lib.dart", "library lib;"); |
| 591 List<AnalysisError> errors = context.computeErrors(source); |
| 592 expect(errors, hasLength(0)); |
| 593 } |
| 594 |
| 595 void test_computeErrors_dart_part() { |
| 596 Source librarySource = |
| 597 addSource("/lib.dart", "library lib; part 'part.dart';"); |
| 598 Source partSource = addSource("/part.dart", "part of 'lib';"); |
| 599 context.parseCompilationUnit(librarySource); |
| 600 List<AnalysisError> errors = context.computeErrors(partSource); |
| 601 expect(errors, isNotNull); |
| 602 expect(errors.length > 0, isTrue); |
| 603 } |
| 604 |
| 605 void test_computeErrors_dart_some() { |
| 606 Source source = addSource("/lib.dart", "library 'lib';"); |
| 607 List<AnalysisError> errors = context.computeErrors(source); |
| 608 expect(errors, isNotNull); |
| 609 expect(errors.length > 0, isTrue); |
| 610 } |
| 611 |
| 612 void test_computeErrors_html_none() { |
| 613 Source source = addSource("/test.html", "<!DOCTYPE html><html></html>"); |
| 614 List<AnalysisError> errors = context.computeErrors(source); |
| 615 expect(errors, hasLength(0)); |
| 616 } |
| 617 |
1191 void test_computeExportedLibraries_none() { | 618 void test_computeExportedLibraries_none() { |
1192 Source source = addSource("/test.dart", "library test;"); | 619 Source source = addSource("/test.dart", "library test;"); |
1193 expect(context.computeExportedLibraries(source), hasLength(0)); | 620 expect(context.computeExportedLibraries(source), hasLength(0)); |
1194 } | 621 } |
1195 | 622 |
1196 void test_computeExportedLibraries_some() { | 623 void test_computeExportedLibraries_some() { |
1197 // addSource("/lib1.dart", "library lib1;"); | 624 // addSource("/lib1.dart", "library lib1;"); |
1198 // addSource("/lib2.dart", "library lib2;"); | 625 // addSource("/lib2.dart", "library lib2;"); |
1199 Source source = addSource( | 626 Source source = addSource( |
1200 "/test.dart", "library test; export 'lib1.dart'; export 'lib2.dart';"); | 627 "/test.dart", "library test; export 'lib1.dart'; export 'lib2.dart';"); |
1201 expect(context.computeExportedLibraries(source), hasLength(2)); | 628 expect(context.computeExportedLibraries(source), hasLength(2)); |
1202 } | 629 } |
1203 | 630 |
1204 void test_computeHtmlElement_nonHtml() { | 631 void test_computeHtmlElement_nonHtml() { |
1205 Source source = addSource("/test.dart", "library test;"); | 632 Source source = addSource("/test.dart", "library test;"); |
1206 expect(context.computeHtmlElement(source), isNull); | 633 expect(context.computeHtmlElement(source), isNull); |
1207 } | 634 } |
1208 | 635 |
| 636 void test_computeImportedLibraries_none() { |
| 637 Source source = addSource("/test.dart", "library test;"); |
| 638 expect(context.computeImportedLibraries(source), hasLength(0)); |
| 639 } |
| 640 |
| 641 void test_computeImportedLibraries_some() { |
| 642 Source source = addSource( |
| 643 "/test.dart", "library test; import 'lib1.dart'; import 'lib2.dart';"); |
| 644 expect(context.computeImportedLibraries(source), hasLength(2)); |
| 645 } |
| 646 |
1209 void test_computeKindOf_html() { | 647 void test_computeKindOf_html() { |
1210 Source source = addSource("/test.html", ""); | 648 Source source = addSource("/test.html", ""); |
1211 expect(context.computeKindOf(source), same(SourceKind.HTML)); | 649 expect(context.computeKindOf(source), same(SourceKind.HTML)); |
1212 } | 650 } |
1213 | 651 |
1214 void test_computeKindOf_library() { | 652 void test_computeKindOf_library() { |
1215 Source source = addSource("/test.dart", "library lib;"); | 653 Source source = addSource("/test.dart", "library lib;"); |
1216 expect(context.computeKindOf(source), same(SourceKind.LIBRARY)); | 654 expect(context.computeKindOf(source), same(SourceKind.LIBRARY)); |
1217 } | 655 } |
1218 | 656 |
(...skipping 26 matching lines...) Expand all Loading... |
1245 Source source = addSource("/test.html", r''' | 683 Source source = addSource("/test.html", r''' |
1246 <html> | 684 <html> |
1247 <body> | 685 <body> |
1248 <h1>A</h1> | 686 <h1>A</h1> |
1249 </body> | 687 </body> |
1250 </html>'''); | 688 </html>'''); |
1251 LineInfo info = context.computeLineInfo(source); | 689 LineInfo info = context.computeLineInfo(source); |
1252 expect(info, isNotNull); | 690 expect(info, isNotNull); |
1253 } | 691 } |
1254 | 692 |
| 693 Future test_computeResolvedCompilationUnitAsync() { |
| 694 Source source = addSource("/lib.dart", "library lib;"); |
| 695 // Complete all pending analysis tasks and flush the AST so that it won't |
| 696 // be available immediately. |
| 697 _performPendingAnalysisTasks(); |
| 698 _flushAst(source); |
| 699 bool completed = false; |
| 700 context |
| 701 .computeResolvedCompilationUnitAsync(source, source) |
| 702 .then((CompilationUnit unit) { |
| 703 expect(unit, isNotNull); |
| 704 completed = true; |
| 705 }); |
| 706 return pumpEventQueue().then((_) { |
| 707 expect(completed, isFalse); |
| 708 _performPendingAnalysisTasks(); |
| 709 }).then((_) => pumpEventQueue()).then((_) { |
| 710 expect(completed, isTrue); |
| 711 }); |
| 712 } |
| 713 |
1255 Future test_computeResolvedCompilationUnitAsync_afterDispose() { | 714 Future test_computeResolvedCompilationUnitAsync_afterDispose() { |
1256 Source source = addSource("/lib.dart", "library lib;"); | 715 Source source = addSource("/lib.dart", "library lib;"); |
1257 // Complete all pending analysis tasks and flush the AST so that it won't | 716 // Complete all pending analysis tasks and flush the AST so that it won't |
1258 // be available immediately. | 717 // be available immediately. |
1259 _performPendingAnalysisTasks(); | 718 _performPendingAnalysisTasks(); |
1260 _flushAst(source); | 719 _flushAst(source); |
1261 // Dispose of the context. | 720 // Dispose of the context. |
1262 context.dispose(); | 721 context.dispose(); |
1263 // Any attempt to start an asynchronous computation should return a future | 722 // Any attempt to start an asynchronous computation should return a future |
1264 // which completes with error. | 723 // which completes with error. |
1265 CancelableFuture<CompilationUnit> future = | 724 CancelableFuture<CompilationUnit> future = |
1266 context.computeResolvedCompilationUnitAsync(source, source); | 725 context.computeResolvedCompilationUnitAsync(source, source); |
1267 bool completed = false; | 726 bool completed = false; |
1268 future.then((CompilationUnit unit) { | 727 future.then((CompilationUnit unit) { |
1269 fail('Future should have completed with error'); | 728 fail('Future should have completed with error'); |
1270 }, onError: (error) { | 729 }, onError: (error) { |
1271 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); | 730 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); |
1272 completed = true; | 731 completed = true; |
1273 }); | 732 }); |
1274 return pumpEventQueue().then((_) { | 733 return pumpEventQueue().then((_) { |
1275 expect(completed, isTrue); | 734 expect(completed, isTrue); |
1276 }); | 735 }); |
1277 } | 736 } |
1278 | 737 |
| 738 Future test_computeResolvedCompilationUnitAsync_cancel() { |
| 739 Source source = addSource("/lib.dart", "library lib;"); |
| 740 // Complete all pending analysis tasks and flush the AST so that it won't |
| 741 // be available immediately. |
| 742 _performPendingAnalysisTasks(); |
| 743 _flushAst(source); |
| 744 CancelableFuture<CompilationUnit> future = |
| 745 context.computeResolvedCompilationUnitAsync(source, source); |
| 746 bool completed = false; |
| 747 future.then((CompilationUnit unit) { |
| 748 fail('Future should have been canceled'); |
| 749 }, onError: (error) { |
| 750 expect(error, new isInstanceOf<FutureCanceledError>()); |
| 751 completed = true; |
| 752 }); |
| 753 expect(completed, isFalse); |
| 754 expect(context.pendingFutureSources_forTesting, isNotEmpty); |
| 755 future.cancel(); |
| 756 expect(context.pendingFutureSources_forTesting, isEmpty); |
| 757 return pumpEventQueue().then((_) { |
| 758 expect(completed, isTrue); |
| 759 expect(context.pendingFutureSources_forTesting, isEmpty); |
| 760 }); |
| 761 } |
| 762 |
| 763 Future test_computeResolvedCompilationUnitAsync_dispose() { |
| 764 Source source = addSource("/lib.dart", "library lib;"); |
| 765 // Complete all pending analysis tasks and flush the AST so that it won't |
| 766 // be available immediately. |
| 767 _performPendingAnalysisTasks(); |
| 768 _flushAst(source); |
| 769 bool completed = false; |
| 770 CancelableFuture<CompilationUnit> future = |
| 771 context.computeResolvedCompilationUnitAsync(source, source); |
| 772 future.then((CompilationUnit unit) { |
| 773 fail('Future should have completed with error'); |
| 774 }, onError: (error) { |
| 775 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); |
| 776 completed = true; |
| 777 }); |
| 778 expect(completed, isFalse); |
| 779 expect(context.pendingFutureSources_forTesting, isNotEmpty); |
| 780 // Disposing of the context should cause all pending futures to complete |
| 781 // with AnalysisNotScheduled, so that no clients are left hanging. |
| 782 context.dispose(); |
| 783 expect(context.pendingFutureSources_forTesting, isEmpty); |
| 784 return pumpEventQueue().then((_) { |
| 785 expect(completed, isTrue); |
| 786 expect(context.pendingFutureSources_forTesting, isEmpty); |
| 787 }); |
| 788 } |
| 789 |
| 790 Future test_computeResolvedCompilationUnitAsync_noCacheEntry() { |
| 791 Source librarySource = addSource("/lib.dart", "library lib;"); |
| 792 Source partSource = addSource("/part.dart", "part of foo;"); |
| 793 bool completed = false; |
| 794 context |
| 795 .computeResolvedCompilationUnitAsync(partSource, librarySource) |
| 796 .then((CompilationUnit unit) { |
| 797 expect(unit, isNotNull); |
| 798 completed = true; |
| 799 }); |
| 800 return pumpEventQueue().then((_) { |
| 801 expect(completed, isFalse); |
| 802 _performPendingAnalysisTasks(); |
| 803 }).then((_) => pumpEventQueue()).then((_) { |
| 804 expect(completed, isTrue); |
| 805 }); |
| 806 } |
| 807 |
1279 void test_dispose() { | 808 void test_dispose() { |
1280 expect(context.isDisposed, isFalse); | 809 expect(context.isDisposed, isFalse); |
1281 context.dispose(); | 810 context.dispose(); |
1282 expect(context.isDisposed, isTrue); | 811 expect(context.isDisposed, isTrue); |
1283 } | 812 } |
1284 | 813 |
1285 void test_ensureResolvedDartUnits_definingUnit_hasResolved() { | 814 void test_ensureResolvedDartUnits_definingUnit_hasResolved() { |
1286 Source source = addSource('/test.dart', ''); | 815 Source source = addSource('/test.dart', ''); |
1287 LibrarySpecificUnit libTarget = new LibrarySpecificUnit(source, source); | 816 LibrarySpecificUnit libTarget = new LibrarySpecificUnit(source, source); |
1288 analysisDriver.computeResult(libTarget, RESOLVED_UNIT); | 817 analysisDriver.computeResult(libTarget, RESOLVED_UNIT); |
(...skipping 12 matching lines...) Expand all Loading... |
1301 RESOLVED_UNIT, CacheState.FLUSHED); | 830 RESOLVED_UNIT, CacheState.FLUSHED); |
1302 // schedule recomputing | 831 // schedule recomputing |
1303 List<CompilationUnit> units = context.ensureResolvedDartUnits(source); | 832 List<CompilationUnit> units = context.ensureResolvedDartUnits(source); |
1304 expect(units, isNull); | 833 expect(units, isNull); |
1305 // should be the next result to compute | 834 // should be the next result to compute |
1306 TargetedResult nextResult = context.dartWorkManager.getNextResult(); | 835 TargetedResult nextResult = context.dartWorkManager.getNextResult(); |
1307 expect(nextResult.target, libTarget); | 836 expect(nextResult.target, libTarget); |
1308 expect(nextResult.result, RESOLVED_UNIT); | 837 expect(nextResult.result, RESOLVED_UNIT); |
1309 } | 838 } |
1310 | 839 |
1311 void test_ensureResolvedDartUnits_partUnit_notResolved() { | 840 void test_ensureResolvedDartUnits_partUnit_hasResolved() { |
1312 Source libSource1 = addSource('/lib1.dart', r''' | 841 Source libSource1 = addSource('/lib1.dart', r''' |
1313 library lib; | 842 library lib; |
1314 part 'part.dart'; | 843 part 'part.dart'; |
1315 '''); | 844 '''); |
1316 Source libSource2 = addSource('/lib2.dart', r''' | 845 Source libSource2 = addSource('/lib2.dart', r''' |
1317 library lib; | 846 library lib; |
1318 part 'part.dart'; | 847 part 'part.dart'; |
1319 '''); | 848 '''); |
1320 Source partSource = addSource('/part.dart', r''' | 849 Source partSource = addSource('/part.dart', r''' |
1321 part of lib; | 850 part of lib; |
1322 '''); | 851 '''); |
1323 LibrarySpecificUnit partTarget1 = | 852 LibrarySpecificUnit partTarget1 = |
1324 new LibrarySpecificUnit(libSource1, partSource); | 853 new LibrarySpecificUnit(libSource1, partSource); |
1325 LibrarySpecificUnit partTarget2 = | 854 LibrarySpecificUnit partTarget2 = |
1326 new LibrarySpecificUnit(libSource2, partSource); | 855 new LibrarySpecificUnit(libSource2, partSource); |
1327 analysisDriver.computeResult(partTarget1, RESOLVED_UNIT); | 856 analysisDriver.computeResult(partTarget1, RESOLVED_UNIT); |
1328 analysisDriver.computeResult(partTarget2, RESOLVED_UNIT); | 857 analysisDriver.computeResult(partTarget2, RESOLVED_UNIT); |
1329 // flush | 858 CompilationUnit unit1 = |
1330 context.getCacheEntry(partTarget1).setState( | 859 context.getCacheEntry(partTarget1).getValue(RESOLVED_UNIT); |
1331 RESOLVED_UNIT, CacheState.FLUSHED); | 860 CompilationUnit unit2 = |
1332 context.getCacheEntry(partTarget2).setState( | 861 context.getCacheEntry(partTarget2).getValue(RESOLVED_UNIT); |
1333 RESOLVED_UNIT, CacheState.FLUSHED); | |
1334 // schedule recomputing | |
1335 List<CompilationUnit> units = context.ensureResolvedDartUnits(partSource); | 862 List<CompilationUnit> units = context.ensureResolvedDartUnits(partSource); |
1336 expect(units, isNull); | 863 expect(units, unorderedEquals([unit1, unit2])); |
1337 // should be the next result to compute | |
1338 TargetedResult nextResult = context.dartWorkManager.getNextResult(); | |
1339 expect(nextResult.target, anyOf(partTarget1, partTarget2)); | |
1340 expect(nextResult.result, RESOLVED_UNIT); | |
1341 } | 864 } |
1342 | 865 |
1343 void test_ensureResolvedDartUnits_partUnit_hasResolved() { | 866 void test_ensureResolvedDartUnits_partUnit_notResolved() { |
1344 Source libSource1 = addSource('/lib1.dart', r''' | 867 Source libSource1 = addSource('/lib1.dart', r''' |
1345 library lib; | 868 library lib; |
1346 part 'part.dart'; | 869 part 'part.dart'; |
1347 '''); | 870 '''); |
1348 Source libSource2 = addSource('/lib2.dart', r''' | 871 Source libSource2 = addSource('/lib2.dart', r''' |
1349 library lib; | 872 library lib; |
1350 part 'part.dart'; | 873 part 'part.dart'; |
1351 '''); | 874 '''); |
1352 Source partSource = addSource('/part.dart', r''' | 875 Source partSource = addSource('/part.dart', r''' |
1353 part of lib; | 876 part of lib; |
1354 '''); | 877 '''); |
1355 LibrarySpecificUnit partTarget1 = | 878 LibrarySpecificUnit partTarget1 = |
1356 new LibrarySpecificUnit(libSource1, partSource); | 879 new LibrarySpecificUnit(libSource1, partSource); |
1357 LibrarySpecificUnit partTarget2 = | 880 LibrarySpecificUnit partTarget2 = |
1358 new LibrarySpecificUnit(libSource2, partSource); | 881 new LibrarySpecificUnit(libSource2, partSource); |
1359 analysisDriver.computeResult(partTarget1, RESOLVED_UNIT); | 882 analysisDriver.computeResult(partTarget1, RESOLVED_UNIT); |
1360 analysisDriver.computeResult(partTarget2, RESOLVED_UNIT); | 883 analysisDriver.computeResult(partTarget2, RESOLVED_UNIT); |
1361 CompilationUnit unit1 = | 884 // flush |
1362 context.getCacheEntry(partTarget1).getValue(RESOLVED_UNIT); | 885 context.getCacheEntry(partTarget1).setState( |
1363 CompilationUnit unit2 = | 886 RESOLVED_UNIT, CacheState.FLUSHED); |
1364 context.getCacheEntry(partTarget2).getValue(RESOLVED_UNIT); | 887 context.getCacheEntry(partTarget2).setState( |
| 888 RESOLVED_UNIT, CacheState.FLUSHED); |
| 889 // schedule recomputing |
1365 List<CompilationUnit> units = context.ensureResolvedDartUnits(partSource); | 890 List<CompilationUnit> units = context.ensureResolvedDartUnits(partSource); |
1366 expect(units, unorderedEquals([unit1, unit2])); | 891 expect(units, isNull); |
| 892 // should be the next result to compute |
| 893 TargetedResult nextResult = context.dartWorkManager.getNextResult(); |
| 894 expect(nextResult.target, anyOf(partTarget1, partTarget2)); |
| 895 expect(nextResult.result, RESOLVED_UNIT); |
1367 } | 896 } |
1368 | 897 |
1369 void test_exists_false() { | 898 void test_exists_false() { |
1370 TestSource source = new TestSource(); | 899 TestSource source = new TestSource(); |
1371 source.exists2 = false; | 900 source.exists2 = false; |
1372 expect(context.exists(source), isFalse); | 901 expect(context.exists(source), isFalse); |
1373 } | 902 } |
1374 | 903 |
1375 void test_exists_null() { | 904 void test_exists_null() { |
1376 expect(context.exists(null), isFalse); | 905 expect(context.exists(null), isFalse); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 context.computeLibraryElement(sourceFactory.forUri("dart:core")); | 953 context.computeLibraryElement(sourceFactory.forUri("dart:core")); |
1425 expect(core, isNotNull); | 954 expect(core, isNotNull); |
1426 ClassElement classObject = | 955 ClassElement classObject = |
1427 _findClass(core.definingCompilationUnit, "Object"); | 956 _findClass(core.definingCompilationUnit, "Object"); |
1428 expect(classObject, isNotNull); | 957 expect(classObject, isNotNull); |
1429 ElementLocation location = classObject.location; | 958 ElementLocation location = classObject.location; |
1430 Element element = context.getElement(location); | 959 Element element = context.getElement(location); |
1431 expect(element, same(classObject)); | 960 expect(element, same(classObject)); |
1432 } | 961 } |
1433 | 962 |
| 963 void test_getElement_constructor_named() { |
| 964 Source source = addSource("/lib.dart", r''' |
| 965 class A { |
| 966 A.named() {} |
| 967 }'''); |
| 968 _analyzeAll_assertFinished(); |
| 969 LibraryElement library = context.computeLibraryElement(source); |
| 970 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); |
| 971 ConstructorElement constructor = classA.constructors[0]; |
| 972 ElementLocation location = constructor.location; |
| 973 Element element = context.getElement(location); |
| 974 expect(element, same(constructor)); |
| 975 } |
| 976 |
| 977 void test_getElement_constructor_unnamed() { |
| 978 Source source = addSource("/lib.dart", r''' |
| 979 class A { |
| 980 A() {} |
| 981 }'''); |
| 982 _analyzeAll_assertFinished(); |
| 983 LibraryElement library = context.computeLibraryElement(source); |
| 984 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); |
| 985 ConstructorElement constructor = classA.constructors[0]; |
| 986 ElementLocation location = constructor.location; |
| 987 Element element = context.getElement(location); |
| 988 expect(element, same(constructor)); |
| 989 } |
| 990 |
| 991 void test_getElement_enum() { |
| 992 Source source = addSource('/test.dart', 'enum MyEnum {A, B, C}'); |
| 993 _analyzeAll_assertFinished(); |
| 994 LibraryElement library = context.computeLibraryElement(source); |
| 995 ClassElement myEnum = library.definingCompilationUnit.getEnum('MyEnum'); |
| 996 ElementLocation location = myEnum.location; |
| 997 Element element = context.getElement(location); |
| 998 expect(element, same(myEnum)); |
| 999 } |
| 1000 |
| 1001 void test_getErrors_dart_none() { |
| 1002 Source source = addSource("/lib.dart", "library lib;"); |
| 1003 var errorInfo = context.getErrors(source); |
| 1004 expect(errorInfo, isNotNull); |
| 1005 List<AnalysisError> errors = errorInfo.errors; |
| 1006 expect(errors, hasLength(0)); |
| 1007 context.computeErrors(source); |
| 1008 errors = errorInfo.errors; |
| 1009 expect(errors, hasLength(0)); |
| 1010 } |
| 1011 |
| 1012 void test_getErrors_dart_some() { |
| 1013 Source source = addSource("/lib.dart", "library 'lib';"); |
| 1014 var errorInfo = context.getErrors(source); |
| 1015 expect(errorInfo, isNotNull); |
| 1016 List<AnalysisError> errors = errorInfo.errors; |
| 1017 expect(errors, hasLength(0)); |
| 1018 errors = context.computeErrors(source); |
| 1019 expect(errors, hasLength(1)); |
| 1020 } |
| 1021 |
| 1022 void test_getErrors_html_none() { |
| 1023 Source source = addSource("/test.html", "<html></html>"); |
| 1024 AnalysisErrorInfo errorInfo = context.getErrors(source); |
| 1025 expect(errorInfo, isNotNull); |
| 1026 List<AnalysisError> errors = errorInfo.errors; |
| 1027 expect(errors, hasLength(0)); |
| 1028 context.computeErrors(source); |
| 1029 errors = errorInfo.errors; |
| 1030 expect(errors, hasLength(0)); |
| 1031 } |
| 1032 |
| 1033 void test_getErrors_html_some() { |
| 1034 Source source = addSource("/test.html", r''' |
| 1035 <html><head> |
| 1036 <script type='application/dart' src='test.dart'/> |
| 1037 </head></html>'''); |
| 1038 AnalysisErrorInfo errorInfo = context.getErrors(source); |
| 1039 expect(errorInfo, isNotNull); |
| 1040 List<AnalysisError> errors = errorInfo.errors; |
| 1041 expect(errors, hasLength(0)); |
| 1042 errors = context.computeErrors(source); |
| 1043 expect(errors, hasLength(3)); |
| 1044 } |
| 1045 |
1434 void test_getHtmlElement_dart() { | 1046 void test_getHtmlElement_dart() { |
1435 Source source = addSource("/test.dart", ""); | 1047 Source source = addSource("/test.dart", ""); |
1436 expect(context.getHtmlElement(source), isNull); | 1048 expect(context.getHtmlElement(source), isNull); |
1437 expect(context.computeHtmlElement(source), isNull); | 1049 expect(context.computeHtmlElement(source), isNull); |
1438 expect(context.getHtmlElement(source), isNull); | 1050 expect(context.getHtmlElement(source), isNull); |
1439 } | 1051 } |
1440 | 1052 |
1441 void test_getHtmlFilesReferencing_html() { | 1053 void test_getHtmlFilesReferencing_html() { |
1442 Source htmlSource = addSource("/test.html", r''' | 1054 Source htmlSource = addSource("/test.html", r''' |
1443 <html><head> | 1055 <html><head> |
1444 <script type='application/dart' src='test.dart'/> | 1056 <script type='application/dart' src='test.dart'/> |
1445 <script type='application/dart' src='test.js'/> | 1057 <script type='application/dart' src='test.js'/> |
1446 </head></html>'''); | 1058 </head></html>'''); |
1447 Source librarySource = addSource("/test.dart", "library lib;"); | 1059 Source librarySource = addSource("/test.dart", "library lib;"); |
1448 Source secondHtmlSource = addSource("/test.html", "<html></html>"); | 1060 Source secondHtmlSource = addSource("/test.html", "<html></html>"); |
1449 context.computeLibraryElement(librarySource); | 1061 context.computeLibraryElement(librarySource); |
1450 List<Source> result = context.getHtmlFilesReferencing(secondHtmlSource); | 1062 List<Source> result = context.getHtmlFilesReferencing(secondHtmlSource); |
1451 expect(result, hasLength(0)); | 1063 expect(result, hasLength(0)); |
1452 context.parseHtmlDocument(htmlSource); | 1064 context.parseHtmlDocument(htmlSource); |
1453 result = context.getHtmlFilesReferencing(secondHtmlSource); | 1065 result = context.getHtmlFilesReferencing(secondHtmlSource); |
1454 expect(result, hasLength(0)); | 1066 expect(result, hasLength(0)); |
1455 } | 1067 } |
1456 | 1068 |
| 1069 void test_getHtmlFilesReferencing_library() { |
| 1070 Source htmlSource = addSource("/test.html", r''' |
| 1071 <!DOCTYPE html> |
| 1072 <html><head> |
| 1073 <script type='application/dart' src='test.dart'/> |
| 1074 <script type='application/dart' src='test.js'/> |
| 1075 </head></html>'''); |
| 1076 Source librarySource = addSource("/test.dart", "library lib;"); |
| 1077 context.computeLibraryElement(librarySource); |
| 1078 List<Source> result = context.getHtmlFilesReferencing(librarySource); |
| 1079 expect(result, hasLength(0)); |
| 1080 context.computeHtmlElement(htmlSource); |
| 1081 result = context.getHtmlFilesReferencing(librarySource); |
| 1082 expect(result, hasLength(1)); |
| 1083 expect(result[0], htmlSource); |
| 1084 } |
| 1085 |
| 1086 void test_getHtmlFilesReferencing_part() { |
| 1087 Source htmlSource = addSource("/test.html", r''' |
| 1088 <!DOCTYPE html> |
| 1089 <html><head> |
| 1090 <script type='application/dart' src='test.dart'/> |
| 1091 <script type='application/dart' src='test.js'/> |
| 1092 </head></html>'''); |
| 1093 Source librarySource = |
| 1094 addSource("/test.dart", "library lib; part 'part.dart';"); |
| 1095 Source partSource = addSource("/part.dart", "part of lib;"); |
| 1096 context.computeLibraryElement(librarySource); |
| 1097 List<Source> result = context.getHtmlFilesReferencing(partSource); |
| 1098 expect(result, hasLength(0)); |
| 1099 context.computeHtmlElement(htmlSource); |
| 1100 result = context.getHtmlFilesReferencing(partSource); |
| 1101 expect(result, hasLength(1)); |
| 1102 expect(result[0], htmlSource); |
| 1103 } |
| 1104 |
| 1105 void test_getHtmlSources() { |
| 1106 List<Source> sources = context.htmlSources; |
| 1107 expect(sources, hasLength(0)); |
| 1108 Source source = addSource("/test.html", ""); |
| 1109 sources = context.htmlSources; |
| 1110 expect(sources, hasLength(1)); |
| 1111 expect(sources[0], source); |
| 1112 } |
| 1113 |
1457 void test_getKindOf_html() { | 1114 void test_getKindOf_html() { |
1458 Source source = addSource("/test.html", ""); | 1115 Source source = addSource("/test.html", ""); |
1459 expect(context.getKindOf(source), same(SourceKind.HTML)); | 1116 expect(context.getKindOf(source), same(SourceKind.HTML)); |
1460 } | 1117 } |
1461 | 1118 |
1462 void test_getKindOf_library() { | 1119 void test_getKindOf_library() { |
1463 Source source = addSource("/test.dart", "library lib;"); | 1120 Source source = addSource("/test.dart", "library lib;"); |
1464 expect(context.getKindOf(source), same(SourceKind.UNKNOWN)); | 1121 expect(context.getKindOf(source), same(SourceKind.UNKNOWN)); |
1465 context.computeKindOf(source); | 1122 context.computeKindOf(source); |
1466 expect(context.getKindOf(source), same(SourceKind.LIBRARY)); | 1123 expect(context.getKindOf(source), same(SourceKind.LIBRARY)); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 Source lib2Source = addSource("/lib2.dart", r''' | 1239 Source lib2Source = addSource("/lib2.dart", r''' |
1583 library lib2; | 1240 library lib2; |
1584 import 'libB.dart'; | 1241 import 'libB.dart'; |
1585 export 'libA.dart';'''); | 1242 export 'libA.dart';'''); |
1586 context.computeLibraryElement(lib1Source); | 1243 context.computeLibraryElement(lib1Source); |
1587 context.computeLibraryElement(lib2Source); | 1244 context.computeLibraryElement(lib2Source); |
1588 List<Source> result = context.getLibrariesDependingOn(libASource); | 1245 List<Source> result = context.getLibrariesDependingOn(libASource); |
1589 expect(result, unorderedEquals([lib1Source, lib2Source])); | 1246 expect(result, unorderedEquals([lib1Source, lib2Source])); |
1590 } | 1247 } |
1591 | 1248 |
| 1249 void test_getLibrariesReferencedFromHtml() { |
| 1250 Source htmlSource = addSource("/test.html", r''' |
| 1251 <!DOCTYPE html> |
| 1252 <html><head> |
| 1253 <script type='application/dart' src='test.dart'/> |
| 1254 <script type='application/dart' src='test.js'/> |
| 1255 </head></html>'''); |
| 1256 Source librarySource = addSource("/test.dart", "library lib;"); |
| 1257 context.computeLibraryElement(librarySource); |
| 1258 context.computeHtmlElement(htmlSource); |
| 1259 List<Source> result = context.getLibrariesReferencedFromHtml(htmlSource); |
| 1260 expect(result, hasLength(1)); |
| 1261 expect(result[0], librarySource); |
| 1262 } |
| 1263 |
1592 void test_getLibrariesReferencedFromHtml_none() { | 1264 void test_getLibrariesReferencedFromHtml_none() { |
1593 Source htmlSource = addSource("/test.html", r''' | 1265 Source htmlSource = addSource("/test.html", r''' |
1594 <html><head> | 1266 <html><head> |
1595 <script type='application/dart' src='test.js'/> | 1267 <script type='application/dart' src='test.js'/> |
1596 </head></html>'''); | 1268 </head></html>'''); |
1597 addSource("/test.dart", "library lib;"); | 1269 addSource("/test.dart", "library lib;"); |
1598 context.parseHtmlDocument(htmlSource); | 1270 context.parseHtmlDocument(htmlSource); |
1599 List<Source> result = context.getLibrariesReferencedFromHtml(htmlSource); | 1271 List<Source> result = context.getLibrariesReferencedFromHtml(htmlSource); |
1600 expect(result, hasLength(0)); | 1272 expect(result, hasLength(0)); |
1601 } | 1273 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 void test_getPublicNamespace_element() { | 1327 void test_getPublicNamespace_element() { |
1656 Source source = addSource("/test.dart", "class A {}"); | 1328 Source source = addSource("/test.dart", "class A {}"); |
1657 LibraryElement library = context.computeLibraryElement(source); | 1329 LibraryElement library = context.computeLibraryElement(source); |
1658 expect(library, isNotNull); | 1330 expect(library, isNotNull); |
1659 Namespace namespace = context.getPublicNamespace(library); | 1331 Namespace namespace = context.getPublicNamespace(library); |
1660 expect(namespace, isNotNull); | 1332 expect(namespace, isNotNull); |
1661 EngineTestCase.assertInstanceOf( | 1333 EngineTestCase.assertInstanceOf( |
1662 (obj) => obj is ClassElement, ClassElement, namespace.get("A")); | 1334 (obj) => obj is ClassElement, ClassElement, namespace.get("A")); |
1663 } | 1335 } |
1664 | 1336 |
| 1337 void test_getResolvedCompilationUnit_library() { |
| 1338 Source source = addSource("/lib.dart", "library libb;"); |
| 1339 LibraryElement library = context.computeLibraryElement(source); |
| 1340 context.computeErrors(source); // Force the resolved unit to be built. |
| 1341 expect(context.getResolvedCompilationUnit(source, library), isNotNull); |
| 1342 context.setContents(source, "library lib;"); |
| 1343 expect(context.getResolvedCompilationUnit(source, library), isNull); |
| 1344 } |
| 1345 |
1665 void test_getResolvedCompilationUnit_library_null() { | 1346 void test_getResolvedCompilationUnit_library_null() { |
1666 Source source = addSource("/lib.dart", "library lib;"); | 1347 Source source = addSource("/lib.dart", "library lib;"); |
1667 expect(context.getResolvedCompilationUnit(source, null), isNull); | 1348 expect(context.getResolvedCompilationUnit(source, null), isNull); |
1668 } | 1349 } |
1669 | 1350 |
1670 void test_getResolvedCompilationUnit_source_dart() { | 1351 void test_getResolvedCompilationUnit_source_dart() { |
1671 Source source = addSource("/lib.dart", "library lib;"); | 1352 Source source = addSource("/lib.dart", "library lib;"); |
1672 expect(context.getResolvedCompilationUnit2(source, source), isNull); | 1353 expect(context.getResolvedCompilationUnit2(source, source), isNull); |
1673 context.resolveCompilationUnit2(source, source); | 1354 context.resolveCompilationUnit2(source, source); |
1674 expect(context.getResolvedCompilationUnit2(source, source), isNotNull); | 1355 expect(context.getResolvedCompilationUnit2(source, source), isNotNull); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 Source source = newSource('/test.dart'); | 1485 Source source = newSource('/test.dart'); |
1805 resourceProvider.deleteFile('/test.dart'); | 1486 resourceProvider.deleteFile('/test.dart'); |
1806 try { | 1487 try { |
1807 context.parseCompilationUnit(source); | 1488 context.parseCompilationUnit(source); |
1808 fail("Expected AnalysisException because file does not exist"); | 1489 fail("Expected AnalysisException because file does not exist"); |
1809 } on AnalysisException { | 1490 } on AnalysisException { |
1810 // Expected result | 1491 // Expected result |
1811 } | 1492 } |
1812 } | 1493 } |
1813 | 1494 |
1814 // void test_resolveCompilationUnit_sourceChangeDuringResolution() { | 1495 void test_parseHtmlDocument() { |
1815 // _context = new _AnalysisContext_sourceChangeDuringResolution(); | 1496 Source source = addSource("/lib.html", "<!DOCTYPE html><html></html>"); |
1816 // AnalysisContextFactory.initContextWithCore(_context); | 1497 Document document = context.parseHtmlDocument(source); |
1817 // _sourceFactory = _context.sourceFactory; | 1498 expect(document, isNotNull); |
1818 // Source source = _addSource("/lib.dart", "library lib;"); | 1499 } |
1819 // CompilationUnit compilationUnit = | 1500 |
1820 // _context.resolveCompilationUnit2(source, source); | 1501 void test_performAnalysisTask_addPart() { |
1821 // expect(compilationUnit, isNotNull); | 1502 Source libSource = addSource("/lib.dart", r''' |
1822 // expect(_context.getLineInfo(source), isNotNull); | 1503 library lib; |
1823 // } | 1504 part 'part.dart';'''); |
| 1505 // run all tasks without part |
| 1506 _analyzeAll_assertFinished(); |
| 1507 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libSource)), |
| 1508 isTrue, reason: "lib has errors"); |
| 1509 // add part and run all tasks |
| 1510 Source partSource = addSource("/part.dart", r''' |
| 1511 part of lib; |
| 1512 '''); |
| 1513 _analyzeAll_assertFinished(); |
| 1514 // "libSource" should be here |
| 1515 List<Source> librariesWithPart = context.getLibrariesContaining(partSource); |
| 1516 expect(librariesWithPart, unorderedEquals([libSource])); |
| 1517 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libSource)), |
| 1518 isFalse, reason: "lib doesn't have errors"); |
| 1519 expect( |
| 1520 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1521 reason: "part resolved"); |
| 1522 } |
| 1523 |
| 1524 void test_performAnalysisTask_changeLibraryContents() { |
| 1525 Source libSource = |
| 1526 addSource("/test.dart", "library lib; part 'test-part.dart';"); |
| 1527 Source partSource = addSource("/test-part.dart", "part of lib;"); |
| 1528 _analyzeAll_assertFinished(); |
| 1529 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1530 reason: "library resolved 1"); |
| 1531 expect( |
| 1532 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1533 reason: "part resolved 1"); |
| 1534 // update and analyze #1 |
| 1535 context.setContents(libSource, "library lib;"); |
| 1536 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, |
| 1537 reason: "library changed 2"); |
| 1538 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1539 reason: "part changed 2"); |
| 1540 _analyzeAll_assertFinished(); |
| 1541 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1542 reason: "library resolved 2"); |
| 1543 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1544 reason: "part resolved 2"); |
| 1545 // update and analyze #2 |
| 1546 context.setContents(libSource, "library lib; part 'test-part.dart';"); |
| 1547 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, |
| 1548 reason: "library changed 3"); |
| 1549 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1550 reason: "part changed 3"); |
| 1551 _analyzeAll_assertFinished(); |
| 1552 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1553 reason: "library resolved 2"); |
| 1554 expect( |
| 1555 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1556 reason: "part resolved 3"); |
| 1557 } |
| 1558 |
| 1559 void test_performAnalysisTask_changeLibraryThenPartContents() { |
| 1560 Source libSource = |
| 1561 addSource("/test.dart", "library lib; part 'test-part.dart';"); |
| 1562 Source partSource = addSource("/test-part.dart", "part of lib;"); |
| 1563 _analyzeAll_assertFinished(); |
| 1564 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1565 reason: "library resolved 1"); |
| 1566 expect( |
| 1567 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1568 reason: "part resolved 1"); |
| 1569 // update and analyze #1 |
| 1570 context.setContents(libSource, "library lib;"); |
| 1571 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, |
| 1572 reason: "library changed 2"); |
| 1573 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1574 reason: "part changed 2"); |
| 1575 _analyzeAll_assertFinished(); |
| 1576 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1577 reason: "library resolved 2"); |
| 1578 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1579 reason: "part resolved 2"); |
| 1580 // update and analyze #2 |
| 1581 context.setContents(partSource, "part of lib; // 1"); |
| 1582 // Assert that changing the part's content does not effect the library |
| 1583 // now that it is no longer part of that library |
| 1584 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1585 reason: "library changed 3"); |
| 1586 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1587 reason: "part changed 3"); |
| 1588 _analyzeAll_assertFinished(); |
| 1589 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1590 reason: "library resolved 3"); |
| 1591 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1592 reason: "part resolved 3"); |
| 1593 } |
| 1594 |
| 1595 void test_performAnalysisTask_changePartContents_makeItAPart() { |
| 1596 Source libSource = addSource("/lib.dart", r''' |
| 1597 library lib; |
| 1598 part 'part.dart'; |
| 1599 void f(x) {}'''); |
| 1600 Source partSource = addSource("/part.dart", "void g() { f(null); }"); |
| 1601 _analyzeAll_assertFinished(); |
| 1602 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1603 reason: "library resolved 1"); |
| 1604 expect( |
| 1605 context.getResolvedCompilationUnit2(partSource, partSource), isNotNull, |
| 1606 reason: "part resolved 1"); |
| 1607 // update and analyze |
| 1608 context.setContents(partSource, r''' |
| 1609 part of lib; |
| 1610 void g() { f(null); }'''); |
| 1611 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, |
| 1612 reason: "library changed 2"); |
| 1613 expect(context.getResolvedCompilationUnit2(partSource, partSource), isNull, |
| 1614 reason: "part changed 2"); |
| 1615 _analyzeAll_assertFinished(); |
| 1616 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1617 reason: "library resolved 2"); |
| 1618 expect( |
| 1619 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1620 reason: "part resolved 2"); |
| 1621 expect(context.getErrors(libSource).errors, hasLength(0)); |
| 1622 expect(context.getErrors(partSource).errors, hasLength(0)); |
| 1623 } |
| 1624 |
| 1625 /** |
| 1626 * https://code.google.com/p/dart/issues/detail?id=12424 |
| 1627 */ |
| 1628 void test_performAnalysisTask_changePartContents_makeItNotPart() { |
| 1629 Source libSource = addSource("/lib.dart", r''' |
| 1630 library lib; |
| 1631 part 'part.dart'; |
| 1632 void f(x) {}'''); |
| 1633 Source partSource = addSource("/part.dart", r''' |
| 1634 part of lib; |
| 1635 void g() { f(null); }'''); |
| 1636 _analyzeAll_assertFinished(); |
| 1637 expect(context.getErrors(libSource).errors, hasLength(0)); |
| 1638 expect(context.getErrors(partSource).errors, hasLength(0)); |
| 1639 // Remove 'part' directive, which should make "f(null)" an error. |
| 1640 context.setContents(partSource, r''' |
| 1641 //part of lib; |
| 1642 void g() { f(null); }'''); |
| 1643 _analyzeAll_assertFinished(); |
| 1644 expect(context.getErrors(libSource).errors.length != 0, isTrue); |
| 1645 } |
| 1646 |
| 1647 void test_performAnalysisTask_changePartContents_noSemanticChanges() { |
| 1648 Source libSource = |
| 1649 addSource("/test.dart", "library lib; part 'test-part.dart';"); |
| 1650 Source partSource = addSource("/test-part.dart", "part of lib;"); |
| 1651 _analyzeAll_assertFinished(); |
| 1652 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1653 reason: "library resolved 1"); |
| 1654 expect( |
| 1655 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1656 reason: "part resolved 1"); |
| 1657 // update and analyze #1 |
| 1658 context.setContents(partSource, "part of lib; // 1"); |
| 1659 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, |
| 1660 reason: "library changed 2"); |
| 1661 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1662 reason: "part changed 2"); |
| 1663 _analyzeAll_assertFinished(); |
| 1664 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1665 reason: "library resolved 2"); |
| 1666 expect( |
| 1667 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1668 reason: "part resolved 2"); |
| 1669 // update and analyze #2 |
| 1670 context.setContents(partSource, "part of lib; // 12"); |
| 1671 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, |
| 1672 reason: "library changed 3"); |
| 1673 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1674 reason: "part changed 3"); |
| 1675 _analyzeAll_assertFinished(); |
| 1676 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1677 reason: "library resolved 3"); |
| 1678 expect( |
| 1679 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1680 reason: "part resolved 3"); |
| 1681 } |
| 1682 |
| 1683 void test_performAnalysisTask_importedLibraryAdd() { |
| 1684 Source libASource = |
| 1685 addSource("/libA.dart", "library libA; import 'libB.dart';"); |
| 1686 _analyzeAll_assertFinished(); |
| 1687 expect( |
| 1688 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull, |
| 1689 reason: "libA resolved 1"); |
| 1690 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), |
| 1691 isTrue, reason: "libA has an error"); |
| 1692 // add libB.dart and analyze |
| 1693 Source libBSource = addSource("/libB.dart", "library libB;"); |
| 1694 _analyzeAll_assertFinished(); |
| 1695 expect( |
| 1696 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull, |
| 1697 reason: "libA resolved 2"); |
| 1698 expect( |
| 1699 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, |
| 1700 reason: "libB resolved 2"); |
| 1701 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), |
| 1702 isFalse, reason: "libA doesn't have errors"); |
| 1703 } |
| 1704 |
| 1705 void test_performAnalysisTask_importedLibraryDelete() { |
| 1706 Source libASource = |
| 1707 addSource("/libA.dart", "library libA; import 'libB.dart';"); |
| 1708 Source libBSource = addSource("/libB.dart", "library libB;"); |
| 1709 _analyzeAll_assertFinished(); |
| 1710 expect( |
| 1711 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull, |
| 1712 reason: "libA resolved 1"); |
| 1713 expect( |
| 1714 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, |
| 1715 reason: "libB resolved 1"); |
| 1716 expect(!_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), |
| 1717 isTrue, reason: "libA doesn't have errors"); |
| 1718 // remove libB.dart and analyze |
| 1719 _removeSource(libBSource); |
| 1720 _analyzeAll_assertFinished(); |
| 1721 expect( |
| 1722 context.getResolvedCompilationUnit2(libASource, libASource), isNotNull, |
| 1723 reason: "libA resolved 2"); |
| 1724 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(libASource)), |
| 1725 isTrue, reason: "libA has an error"); |
| 1726 } |
| 1727 |
| 1728 void test_performAnalysisTask_missingPart() { |
| 1729 Source source = |
| 1730 addSource("/test.dart", "library lib; part 'no-such-file.dart';"); |
| 1731 _analyzeAll_assertFinished(); |
| 1732 expect(context.getLibraryElement(source), isNotNull, |
| 1733 reason: "performAnalysisTask failed to compute an element model"); |
| 1734 } |
1824 | 1735 |
1825 void test_performAnalysisTask_modifiedAfterParse() { | 1736 void test_performAnalysisTask_modifiedAfterParse() { |
1826 // TODO(scheglov) no threads in Dart | 1737 // TODO(scheglov) no threads in Dart |
1827 // Source source = _addSource("/test.dart", "library lib;"); | 1738 // Source source = _addSource("/test.dart", "library lib;"); |
1828 // int initialTime = _context.getModificationStamp(source); | 1739 // int initialTime = _context.getModificationStamp(source); |
1829 // List<Source> sources = new List<Source>(); | 1740 // List<Source> sources = new List<Source>(); |
1830 // sources.add(source); | 1741 // sources.add(source); |
1831 // _context.analysisPriorityOrder = sources; | 1742 // _context.analysisPriorityOrder = sources; |
1832 // _context.parseCompilationUnit(source); | 1743 // _context.parseCompilationUnit(source); |
1833 // while (initialTime == JavaSystem.currentTimeMillis()) { | 1744 // while (initialTime == JavaSystem.currentTimeMillis()) { |
1834 // Thread.sleep(1); | 1745 // Thread.sleep(1); |
1835 // // Force the modification time to be different. | 1746 // // Force the modification time to be different. |
1836 // } | 1747 // } |
1837 // _context.setContents(source, "library test;"); | 1748 // _context.setContents(source, "library test;"); |
1838 // JUnitTestCase.assertTrue(initialTime != _context.getModificationStamp(sour
ce)); | 1749 // JUnitTestCase.assertTrue(initialTime != _context.getModificationStamp(sour
ce)); |
1839 // _analyzeAll_assertFinished(); | 1750 // _analyzeAll_assertFinished(); |
1840 // JUnitTestCase.assertNotNullMsg("performAnalysisTask failed to compute an e
lement model", _context.getLibraryElement(source)); | 1751 // JUnitTestCase.assertNotNullMsg("performAnalysisTask failed to compute an e
lement model", _context.getLibraryElement(source)); |
1841 } | 1752 } |
1842 | 1753 |
| 1754 void test_performAnalysisTask_onResultComputed() { |
| 1755 Set<String> libraryElementUris = new Set<String>(); |
| 1756 Set<String> parsedUnitUris = new Set<String>(); |
| 1757 Set<String> resolvedUnitUris = new Set<String>(); |
| 1758 // listen |
| 1759 context.onResultComputed(LIBRARY_ELEMENT).listen((event) { |
| 1760 Source librarySource = event.target; |
| 1761 libraryElementUris.add(librarySource.uri.toString()); |
| 1762 }); |
| 1763 context.onResultComputed(PARSED_UNIT).listen((event) { |
| 1764 Source source = event.target; |
| 1765 parsedUnitUris.add(source.uri.toString()); |
| 1766 }); |
| 1767 context.onResultComputed(RESOLVED_UNIT).listen((event) { |
| 1768 LibrarySpecificUnit target = event.target; |
| 1769 Source librarySource = target.library; |
| 1770 resolvedUnitUris.add(librarySource.uri.toString()); |
| 1771 }); |
| 1772 // analyze |
| 1773 addSource('/test.dart', 'main() {}'); |
| 1774 _analyzeAll_assertFinished(); |
| 1775 // verify |
| 1776 expect(libraryElementUris, contains('dart:core')); |
| 1777 expect(libraryElementUris, contains('file:///test.dart')); |
| 1778 expect(parsedUnitUris, contains('dart:core')); |
| 1779 expect(parsedUnitUris, contains('file:///test.dart')); |
| 1780 expect(resolvedUnitUris, contains('dart:core')); |
| 1781 expect(resolvedUnitUris, contains('file:///test.dart')); |
| 1782 } |
| 1783 |
| 1784 // void test_resolveCompilationUnit_sourceChangeDuringResolution() { |
| 1785 // _context = new _AnalysisContext_sourceChangeDuringResolution(); |
| 1786 // AnalysisContextFactory.initContextWithCore(_context); |
| 1787 // _sourceFactory = _context.sourceFactory; |
| 1788 // Source source = _addSource("/lib.dart", "library lib;"); |
| 1789 // CompilationUnit compilationUnit = |
| 1790 // _context.resolveCompilationUnit2(source, source); |
| 1791 // expect(compilationUnit, isNotNull); |
| 1792 // expect(_context.getLineInfo(source), isNotNull); |
| 1793 // } |
| 1794 |
| 1795 void test_resolveCompilationUnit_import_relative() { |
| 1796 Source sourceA = |
| 1797 addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}"); |
| 1798 addSource("/libB.dart", "library libB; class B{}"); |
| 1799 CompilationUnit compilationUnit = |
| 1800 context.resolveCompilationUnit2(sourceA, sourceA); |
| 1801 expect(compilationUnit, isNotNull); |
| 1802 LibraryElement library = compilationUnit.element.library; |
| 1803 List<LibraryElement> importedLibraries = library.importedLibraries; |
| 1804 assertNamedElements(importedLibraries, ["dart.core", "libB"]); |
| 1805 List<LibraryElement> visibleLibraries = library.visibleLibraries; |
| 1806 assertNamedElements(visibleLibraries, [ |
| 1807 "dart.core", |
| 1808 "dart.async", |
| 1809 "dart.math", |
| 1810 "libA", |
| 1811 "libB" |
| 1812 ]); |
| 1813 } |
| 1814 |
| 1815 void test_resolveCompilationUnit_import_relative_cyclic() { |
| 1816 Source sourceA = |
| 1817 addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}"); |
| 1818 addSource("/libB.dart", "library libB; import 'libA.dart'; class B{}"); |
| 1819 CompilationUnit compilationUnit = |
| 1820 context.resolveCompilationUnit2(sourceA, sourceA); |
| 1821 expect(compilationUnit, isNotNull); |
| 1822 LibraryElement library = compilationUnit.element.library; |
| 1823 List<LibraryElement> importedLibraries = library.importedLibraries; |
| 1824 assertNamedElements(importedLibraries, ["dart.core", "libB"]); |
| 1825 List<LibraryElement> visibleLibraries = library.visibleLibraries; |
| 1826 assertNamedElements(visibleLibraries, [ |
| 1827 "dart.core", |
| 1828 "dart.async", |
| 1829 "dart.math", |
| 1830 "libA", |
| 1831 "libB" |
| 1832 ]); |
| 1833 } |
| 1834 |
1843 void test_resolveCompilationUnit_library() { | 1835 void test_resolveCompilationUnit_library() { |
1844 Source source = addSource("/lib.dart", "library lib;"); | 1836 Source source = addSource("/lib.dart", "library lib;"); |
1845 LibraryElement library = context.computeLibraryElement(source); | 1837 LibraryElement library = context.computeLibraryElement(source); |
1846 CompilationUnit compilationUnit = | 1838 CompilationUnit compilationUnit = |
1847 context.resolveCompilationUnit(source, library); | 1839 context.resolveCompilationUnit(source, library); |
1848 expect(compilationUnit, isNotNull); | 1840 expect(compilationUnit, isNotNull); |
1849 expect(compilationUnit.element, isNotNull); | 1841 expect(compilationUnit.element, isNotNull); |
1850 } | 1842 } |
1851 | 1843 |
1852 void test_resolveCompilationUnit_source() { | 1844 void test_resolveCompilationUnit_source() { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1938 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( | 1930 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( |
1939 librarySource, librarySource, null, null, null, 0, 0, 0); | 1931 librarySource, librarySource, null, null, null, 0, 0, 0); |
1940 _setIncrementalAnalysisCache(context, incrementalCache); | 1932 _setIncrementalAnalysisCache(context, incrementalCache); |
1941 expect(_getIncrementalAnalysisCache(context), same(incrementalCache)); | 1933 expect(_getIncrementalAnalysisCache(context), same(incrementalCache)); |
1942 context.setContents(librarySource, null); | 1934 context.setContents(librarySource, null); |
1943 expect(context.getResolvedCompilationUnit2(librarySource, librarySource), | 1935 expect(context.getResolvedCompilationUnit2(librarySource, librarySource), |
1944 isNull); | 1936 isNull); |
1945 expect(_getIncrementalAnalysisCache(context), isNull); | 1937 expect(_getIncrementalAnalysisCache(context), isNull); |
1946 } | 1938 } |
1947 | 1939 |
| 1940 void test_setContents_unchanged_consistentModificationTime() { |
| 1941 String contents = "// foo"; |
| 1942 Source source = addSource("/test.dart", contents); |
| 1943 context.setContents(source, contents); |
| 1944 // do all, no tasks |
| 1945 _analyzeAll_assertFinished(); |
| 1946 { |
| 1947 AnalysisResult result = context.performAnalysisTask(); |
| 1948 expect(result.changeNotices, isNull); |
| 1949 } |
| 1950 // set the same contents, still no tasks |
| 1951 context.setContents(source, contents); |
| 1952 { |
| 1953 AnalysisResult result = context.performAnalysisTask(); |
| 1954 expect(result.changeNotices, isNull); |
| 1955 } |
| 1956 } |
| 1957 |
1948 void test_setSourceFactory() { | 1958 void test_setSourceFactory() { |
1949 expect(context.sourceFactory, sourceFactory); | 1959 expect(context.sourceFactory, sourceFactory); |
1950 SourceFactory factory = new SourceFactory([]); | 1960 SourceFactory factory = new SourceFactory([]); |
1951 context.sourceFactory = factory; | 1961 context.sourceFactory = factory; |
1952 expect(context.sourceFactory, factory); | 1962 expect(context.sourceFactory, factory); |
1953 } | 1963 } |
1954 | 1964 |
1955 void test_updateAnalysis() { | 1965 void test_updateAnalysis() { |
1956 expect(context.sourcesNeedingProcessing, isEmpty); | 1966 expect(context.sourcesNeedingProcessing, isEmpty); |
1957 Source source = newSource('/test.dart'); | 1967 Source source = newSource('/test.dart'); |
1958 AnalysisDelta delta = new AnalysisDelta(); | 1968 AnalysisDelta delta = new AnalysisDelta(); |
1959 delta.setAnalysisLevel(source, AnalysisLevel.ALL); | 1969 delta.setAnalysisLevel(source, AnalysisLevel.ALL); |
1960 context.applyAnalysisDelta(delta); | 1970 context.applyAnalysisDelta(delta); |
1961 expect(context.sourcesNeedingProcessing, contains(source)); | 1971 expect(context.sourcesNeedingProcessing, contains(source)); |
1962 delta = new AnalysisDelta(); | 1972 delta = new AnalysisDelta(); |
1963 delta.setAnalysisLevel(source, AnalysisLevel.NONE); | 1973 delta.setAnalysisLevel(source, AnalysisLevel.NONE); |
1964 context.applyAnalysisDelta(delta); | 1974 context.applyAnalysisDelta(delta); |
1965 expect(context.sourcesNeedingProcessing.contains(source), isFalse); | 1975 expect(context.sourcesNeedingProcessing.contains(source), isFalse); |
1966 } | 1976 } |
1967 | 1977 |
1968 Future test_computeResolvedCompilationUnitAsync() { | |
1969 Source source = addSource("/lib.dart", "library lib;"); | |
1970 // Complete all pending analysis tasks and flush the AST so that it won't | |
1971 // be available immediately. | |
1972 _performPendingAnalysisTasks(); | |
1973 _flushAst(source); | |
1974 bool completed = false; | |
1975 context | |
1976 .computeResolvedCompilationUnitAsync(source, source) | |
1977 .then((CompilationUnit unit) { | |
1978 expect(unit, isNotNull); | |
1979 completed = true; | |
1980 }); | |
1981 return pumpEventQueue().then((_) { | |
1982 expect(completed, isFalse); | |
1983 _performPendingAnalysisTasks(); | |
1984 }).then((_) => pumpEventQueue()).then((_) { | |
1985 expect(completed, isTrue); | |
1986 }); | |
1987 } | |
1988 | |
1989 Future test_computeResolvedCompilationUnitAsync_cancel() { | |
1990 Source source = addSource("/lib.dart", "library lib;"); | |
1991 // Complete all pending analysis tasks and flush the AST so that it won't | |
1992 // be available immediately. | |
1993 _performPendingAnalysisTasks(); | |
1994 _flushAst(source); | |
1995 CancelableFuture<CompilationUnit> future = | |
1996 context.computeResolvedCompilationUnitAsync(source, source); | |
1997 bool completed = false; | |
1998 future.then((CompilationUnit unit) { | |
1999 fail('Future should have been canceled'); | |
2000 }, onError: (error) { | |
2001 expect(error, new isInstanceOf<FutureCanceledError>()); | |
2002 completed = true; | |
2003 }); | |
2004 expect(completed, isFalse); | |
2005 expect(context.pendingFutureSources_forTesting, isNotEmpty); | |
2006 future.cancel(); | |
2007 expect(context.pendingFutureSources_forTesting, isEmpty); | |
2008 return pumpEventQueue().then((_) { | |
2009 expect(completed, isTrue); | |
2010 expect(context.pendingFutureSources_forTesting, isEmpty); | |
2011 }); | |
2012 } | |
2013 | |
2014 void xtest_performAnalysisTask_stress() { | 1978 void xtest_performAnalysisTask_stress() { |
2015 int maxCacheSize = 4; | 1979 int maxCacheSize = 4; |
2016 AnalysisOptionsImpl options = | 1980 AnalysisOptionsImpl options = |
2017 new AnalysisOptionsImpl.from(context.analysisOptions); | 1981 new AnalysisOptionsImpl.from(context.analysisOptions); |
2018 options.cacheSize = maxCacheSize; | 1982 options.cacheSize = maxCacheSize; |
2019 context.analysisOptions = options; | 1983 context.analysisOptions = options; |
2020 int sourceCount = maxCacheSize + 2; | 1984 int sourceCount = maxCacheSize + 2; |
2021 List<Source> sources = new List<Source>(); | 1985 List<Source> sources = new List<Source>(); |
2022 ChangeSet changeSet = new ChangeSet(); | 1986 ChangeSet changeSet = new ChangeSet(); |
2023 for (int i = 0; i < sourceCount; i++) { | 1987 for (int i = 0; i < sourceCount; i++) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2179 : super(name, pathos.toUri(name), UriKind.FILE_URI); | 2143 : super(name, pathos.toUri(name), UriKind.FILE_URI); |
2180 | 2144 |
2181 @override | 2145 @override |
2182 TimestampedData<String> get contents { | 2146 TimestampedData<String> get contents { |
2183 throw 'Read error'; | 2147 throw 'Read error'; |
2184 } | 2148 } |
2185 | 2149 |
2186 @override | 2150 @override |
2187 bool exists() => true; | 2151 bool exists() => true; |
2188 } | 2152 } |
OLD | NEW |