| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.engine_test; | 8 library engine.engine_test; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * Verify that if multiple Source objects refer to the same file via | 102 * Verify that if multiple Source objects refer to the same file via |
| 103 * different URIs, they are treated as separate entries in the cache. | 103 * different URIs, they are treated as separate entries in the cache. |
| 104 */ | 104 */ |
| 105 void test_lookup_distinguishes_uris() { | 105 void test_lookup_distinguishes_uris() { |
| 106 CachePartition partition = | 106 CachePartition partition = |
| 107 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); | 107 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); |
| 108 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); | 108 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); |
| 109 JavaFile file = new JavaFile('baz.dart'); | 109 JavaFile file = new JavaFile('baz.dart'); |
| 110 Source source1 = new FileBasedSource.con1(file); | 110 Source source1 = new FileBasedSource(file); |
| 111 Source source2 = | 111 Source source2 = |
| 112 new FileBasedSource.con2(Uri.parse('package:foo/baz.dart'), file); | 112 new FileBasedSource(file, Uri.parse('package:foo/baz.dart')); |
| 113 Source source3 = | 113 Source source3 = |
| 114 new FileBasedSource.con2(Uri.parse('package:bar/baz.dart'), file); | 114 new FileBasedSource(file, Uri.parse('package:bar/baz.dart')); |
| 115 DartEntry entry1 = new DartEntry(); | 115 DartEntry entry1 = new DartEntry(); |
| 116 DartEntry entry2 = new DartEntry(); | 116 DartEntry entry2 = new DartEntry(); |
| 117 DartEntry entry3 = new DartEntry(); | 117 DartEntry entry3 = new DartEntry(); |
| 118 cache.put(source1, entry1); | 118 cache.put(source1, entry1); |
| 119 cache.put(source2, entry2); | 119 cache.put(source2, entry2); |
| 120 cache.put(source3, entry3); | 120 cache.put(source3, entry3); |
| 121 expect(cache.get(source1), same(entry1)); | 121 expect(cache.get(source1), same(entry1)); |
| 122 expect(cache.get(source2), same(entry2)); | 122 expect(cache.get(source2), same(entry2)); |
| 123 expect(cache.get(source3), same(entry3)); | 123 expect(cache.get(source3), same(entry3)); |
| 124 } | 124 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 @override | 229 @override |
| 230 void setUp() { | 230 void setUp() { |
| 231 _context = new AnalysisContextImpl(); | 231 _context = new AnalysisContextImpl(); |
| 232 _sourceFactory = new SourceFactory([ | 232 _sourceFactory = new SourceFactory([ |
| 233 new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), | 233 new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), |
| 234 new FileUriResolver() | 234 new FileUriResolver() |
| 235 ]); | 235 ]); |
| 236 _context.sourceFactory = _sourceFactory; | 236 _context.sourceFactory = _sourceFactory; |
| 237 AnalysisOptionsImpl options = | 237 AnalysisOptionsImpl options = |
| 238 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 238 new AnalysisOptionsImpl.from(_context.analysisOptions); |
| 239 options.cacheSize = 256; | 239 options.cacheSize = 256; |
| 240 _context.analysisOptions = options; | 240 _context.analysisOptions = options; |
| 241 } | 241 } |
| 242 | 242 |
| 243 @override | 243 @override |
| 244 void tearDown() { | 244 void tearDown() { |
| 245 _context = null; | 245 _context = null; |
| 246 _sourceFactory = null; | 246 _sourceFactory = null; |
| 247 super.tearDown(); | 247 super.tearDown(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 Future test_applyChanges_add() { | 250 Future test_applyChanges_add() { |
| 251 SourcesChangedListener listener = new SourcesChangedListener(); | 251 SourcesChangedListener listener = new SourcesChangedListener(); |
| 252 _context.onSourcesChanged.listen(listener.onData); | 252 _context.onSourcesChanged.listen(listener.onData); |
| 253 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); | 253 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); |
| 254 Source source = | 254 Source source = |
| 255 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 255 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 256 ChangeSet changeSet = new ChangeSet(); | 256 ChangeSet changeSet = new ChangeSet(); |
| 257 changeSet.addedSource(source); | 257 changeSet.addedSource(source); |
| 258 _context.applyChanges(changeSet); | 258 _context.applyChanges(changeSet); |
| 259 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); | 259 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); |
| 260 return pumpEventQueue().then((_) { | 260 return pumpEventQueue().then((_) { |
| 261 listener.assertEvent(wereSourcesAdded: true); | 261 listener.assertEvent(wereSourcesAdded: true); |
| 262 listener.assertNoMoreEvents(); | 262 listener.assertNoMoreEvents(); |
| 263 }); | 263 }); |
| 264 } | 264 } |
| 265 | 265 |
| 266 Future test_applyChanges_change() { | 266 Future test_applyChanges_change() { |
| 267 SourcesChangedListener listener = new SourcesChangedListener(); | 267 SourcesChangedListener listener = new SourcesChangedListener(); |
| 268 _context.onSourcesChanged.listen(listener.onData); | 268 _context.onSourcesChanged.listen(listener.onData); |
| 269 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); | 269 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); |
| 270 Source source = | 270 Source source = |
| 271 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 271 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 272 ChangeSet changeSet1 = new ChangeSet(); | 272 ChangeSet changeSet1 = new ChangeSet(); |
| 273 changeSet1.addedSource(source); | 273 changeSet1.addedSource(source); |
| 274 _context.applyChanges(changeSet1); | 274 _context.applyChanges(changeSet1); |
| 275 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); | 275 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); |
| 276 Source source2 = | 276 Source source2 = |
| 277 new FileBasedSource.con1(FileUtilities2.createFile("/test2.dart")); | 277 new FileBasedSource(FileUtilities2.createFile("/test2.dart")); |
| 278 ChangeSet changeSet2 = new ChangeSet(); | 278 ChangeSet changeSet2 = new ChangeSet(); |
| 279 changeSet2.addedSource(source2); | 279 changeSet2.addedSource(source2); |
| 280 changeSet2.changedSource(source); | 280 changeSet2.changedSource(source); |
| 281 _context.applyChanges(changeSet2); | 281 _context.applyChanges(changeSet2); |
| 282 return pumpEventQueue().then((_) { | 282 return pumpEventQueue().then((_) { |
| 283 listener.assertEvent(wereSourcesAdded: true); | 283 listener.assertEvent(wereSourcesAdded: true); |
| 284 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); | 284 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); |
| 285 listener.assertNoMoreEvents(); | 285 listener.assertNoMoreEvents(); |
| 286 }); | 286 }); |
| 287 } | 287 } |
| 288 | 288 |
| 289 Future test_applyChanges_change_content() { | 289 Future test_applyChanges_change_content() { |
| 290 SourcesChangedListener listener = new SourcesChangedListener(); | 290 SourcesChangedListener listener = new SourcesChangedListener(); |
| 291 _context.onSourcesChanged.listen(listener.onData); | 291 _context.onSourcesChanged.listen(listener.onData); |
| 292 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); | 292 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); |
| 293 Source source = | 293 Source source = |
| 294 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 294 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 295 ChangeSet changeSet1 = new ChangeSet(); | 295 ChangeSet changeSet1 = new ChangeSet(); |
| 296 changeSet1.addedSource(source); | 296 changeSet1.addedSource(source); |
| 297 _context.applyChanges(changeSet1); | 297 _context.applyChanges(changeSet1); |
| 298 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); | 298 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); |
| 299 Source source2 = | 299 Source source2 = |
| 300 new FileBasedSource.con1(FileUtilities2.createFile("/test2.dart")); | 300 new FileBasedSource(FileUtilities2.createFile("/test2.dart")); |
| 301 ChangeSet changeSet2 = new ChangeSet(); | 301 ChangeSet changeSet2 = new ChangeSet(); |
| 302 changeSet2.addedSource(source2); | 302 changeSet2.addedSource(source2); |
| 303 changeSet2.changedContent(source, 'library test;'); | 303 changeSet2.changedContent(source, 'library test;'); |
| 304 _context.applyChanges(changeSet2); | 304 _context.applyChanges(changeSet2); |
| 305 return pumpEventQueue().then((_) { | 305 return pumpEventQueue().then((_) { |
| 306 listener.assertEvent(wereSourcesAdded: true); | 306 listener.assertEvent(wereSourcesAdded: true); |
| 307 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); | 307 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); |
| 308 listener.assertNoMoreEvents(); | 308 listener.assertNoMoreEvents(); |
| 309 }); | 309 }); |
| 310 } | 310 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 listener.assertEvent(changedSources: [partSource]); | 369 listener.assertEvent(changedSources: [partSource]); |
| 370 listener.assertNoMoreEvents(); | 370 listener.assertNoMoreEvents(); |
| 371 }); | 371 }); |
| 372 } | 372 } |
| 373 | 373 |
| 374 Future test_applyChanges_change_range() { | 374 Future test_applyChanges_change_range() { |
| 375 SourcesChangedListener listener = new SourcesChangedListener(); | 375 SourcesChangedListener listener = new SourcesChangedListener(); |
| 376 _context.onSourcesChanged.listen(listener.onData); | 376 _context.onSourcesChanged.listen(listener.onData); |
| 377 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); | 377 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); |
| 378 Source source = | 378 Source source = |
| 379 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 379 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 380 ChangeSet changeSet1 = new ChangeSet(); | 380 ChangeSet changeSet1 = new ChangeSet(); |
| 381 changeSet1.addedSource(source); | 381 changeSet1.addedSource(source); |
| 382 _context.applyChanges(changeSet1); | 382 _context.applyChanges(changeSet1); |
| 383 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); | 383 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); |
| 384 Source source2 = | 384 Source source2 = |
| 385 new FileBasedSource.con1(FileUtilities2.createFile("/test2.dart")); | 385 new FileBasedSource(FileUtilities2.createFile("/test2.dart")); |
| 386 ChangeSet changeSet2 = new ChangeSet(); | 386 ChangeSet changeSet2 = new ChangeSet(); |
| 387 changeSet2.addedSource(source2); | 387 changeSet2.addedSource(source2); |
| 388 changeSet2.changedRange(source, 'library test;', 0, 0, 13); | 388 changeSet2.changedRange(source, 'library test;', 0, 0, 13); |
| 389 _context.applyChanges(changeSet2); | 389 _context.applyChanges(changeSet2); |
| 390 return pumpEventQueue().then((_) { | 390 return pumpEventQueue().then((_) { |
| 391 listener.assertEvent(wereSourcesAdded: true); | 391 listener.assertEvent(wereSourcesAdded: true); |
| 392 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); | 392 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); |
| 393 listener.assertNoMoreEvents(); | 393 listener.assertNoMoreEvents(); |
| 394 }); | 394 }); |
| 395 } | 395 } |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 | 1363 |
| 1364 void test_parseCompilationUnit_noErrors() { | 1364 void test_parseCompilationUnit_noErrors() { |
| 1365 Source source = _addSource("/lib.dart", "library lib;"); | 1365 Source source = _addSource("/lib.dart", "library lib;"); |
| 1366 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); | 1366 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); |
| 1367 expect(compilationUnit, isNotNull); | 1367 expect(compilationUnit, isNotNull); |
| 1368 expect(_context.getErrors(source).errors, hasLength(0)); | 1368 expect(_context.getErrors(source).errors, hasLength(0)); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 void test_parseCompilationUnit_nonExistentSource() { | 1371 void test_parseCompilationUnit_nonExistentSource() { |
| 1372 Source source = | 1372 Source source = |
| 1373 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 1373 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 1374 try { | 1374 try { |
| 1375 _context.parseCompilationUnit(source); | 1375 _context.parseCompilationUnit(source); |
| 1376 fail("Expected AnalysisException because file does not exist"); | 1376 fail("Expected AnalysisException because file does not exist"); |
| 1377 } on AnalysisException { | 1377 } on AnalysisException { |
| 1378 // Expected result | 1378 // Expected result |
| 1379 } | 1379 } |
| 1380 } | 1380 } |
| 1381 | 1381 |
| 1382 void test_parseHtmlUnit_noErrors() { | 1382 void test_parseHtmlUnit_noErrors() { |
| 1383 Source source = _addSource("/lib.html", "<html></html>"); | 1383 Source source = _addSource("/lib.html", "<html></html>"); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 options.hint = false; | 1821 options.hint = false; |
| 1822 _context.analysisOptions = options; | 1822 _context.analysisOptions = options; |
| 1823 AnalysisOptions result = _context.analysisOptions; | 1823 AnalysisOptions result = _context.analysisOptions; |
| 1824 expect(result.cacheSize, options.cacheSize); | 1824 expect(result.cacheSize, options.cacheSize); |
| 1825 expect(result.dart2jsHint, options.dart2jsHint); | 1825 expect(result.dart2jsHint, options.dart2jsHint); |
| 1826 expect(result.hint, options.hint); | 1826 expect(result.hint, options.hint); |
| 1827 } | 1827 } |
| 1828 | 1828 |
| 1829 void test_setAnalysisOptions_reduceAnalysisPriorityOrder() { | 1829 void test_setAnalysisOptions_reduceAnalysisPriorityOrder() { |
| 1830 AnalysisOptionsImpl options = | 1830 AnalysisOptionsImpl options = |
| 1831 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 1831 new AnalysisOptionsImpl.from(_context.analysisOptions); |
| 1832 List<Source> sources = new List<Source>(); | 1832 List<Source> sources = new List<Source>(); |
| 1833 for (int index = 0; index < options.cacheSize; index++) { | 1833 for (int index = 0; index < options.cacheSize; index++) { |
| 1834 sources.add(_addSource("/lib.dart$index", "")); | 1834 sources.add(_addSource("/lib.dart$index", "")); |
| 1835 } | 1835 } |
| 1836 _context.analysisPriorityOrder = sources; | 1836 _context.analysisPriorityOrder = sources; |
| 1837 int oldPriorityOrderSize = _getPriorityOrder(_context).length; | 1837 int oldPriorityOrderSize = _getPriorityOrder(_context).length; |
| 1838 options.cacheSize = options.cacheSize - 10; | 1838 options.cacheSize = options.cacheSize - 10; |
| 1839 _context.analysisOptions = options; | 1839 _context.analysisOptions = options; |
| 1840 expect(oldPriorityOrderSize > _getPriorityOrder(_context).length, isTrue); | 1840 expect(oldPriorityOrderSize > _getPriorityOrder(_context).length, isTrue); |
| 1841 } | 1841 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 listener.assertEvent(wereSourcesAdded: true); | 1901 listener.assertEvent(wereSourcesAdded: true); |
| 1902 listener.assertEvent(changedSources: [partSource]); | 1902 listener.assertEvent(changedSources: [partSource]); |
| 1903 listener.assertEvent(changedSources: [librarySource]); | 1903 listener.assertEvent(changedSources: [librarySource]); |
| 1904 listener.assertNoMoreEvents(); | 1904 listener.assertNoMoreEvents(); |
| 1905 }); | 1905 }); |
| 1906 } | 1906 } |
| 1907 | 1907 |
| 1908 void test_setChangedContents_notResolved() { | 1908 void test_setChangedContents_notResolved() { |
| 1909 _context = AnalysisContextFactory.contextWithCore(); | 1909 _context = AnalysisContextFactory.contextWithCore(); |
| 1910 AnalysisOptionsImpl options = | 1910 AnalysisOptionsImpl options = |
| 1911 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 1911 new AnalysisOptionsImpl.from(_context.analysisOptions); |
| 1912 options.incremental = true; | 1912 options.incremental = true; |
| 1913 _context.analysisOptions = options; | 1913 _context.analysisOptions = options; |
| 1914 _sourceFactory = _context.sourceFactory; | 1914 _sourceFactory = _context.sourceFactory; |
| 1915 String oldCode = r''' | 1915 String oldCode = r''' |
| 1916 library lib; | 1916 library lib; |
| 1917 int a = 0;'''; | 1917 int a = 0;'''; |
| 1918 Source librarySource = _addSource("/lib.dart", oldCode); | 1918 Source librarySource = _addSource("/lib.dart", oldCode); |
| 1919 int offset = oldCode.indexOf("int a") + 4; | 1919 int offset = oldCode.indexOf("int a") + 4; |
| 1920 String newCode = r''' | 1920 String newCode = r''' |
| 1921 library lib; | 1921 library lib; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 // test1 and test2 should have been successfully analyzed | 2018 // test1 and test2 should have been successfully analyzed |
| 2019 // despite the fact that test3 couldn't be read. | 2019 // despite the fact that test3 couldn't be read. |
| 2020 expect(_context.computeLibraryElement(test1), isNotNull); | 2020 expect(_context.computeLibraryElement(test1), isNotNull); |
| 2021 expect(_context.computeLibraryElement(test2), isNotNull); | 2021 expect(_context.computeLibraryElement(test2), isNotNull); |
| 2022 expect(_context.computeLibraryElement(test3), isNull); | 2022 expect(_context.computeLibraryElement(test3), isNull); |
| 2023 } | 2023 } |
| 2024 | 2024 |
| 2025 void test_updateAnalysis() { | 2025 void test_updateAnalysis() { |
| 2026 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); | 2026 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); |
| 2027 Source source = | 2027 Source source = |
| 2028 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 2028 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 2029 AnalysisDelta delta = new AnalysisDelta(); | 2029 AnalysisDelta delta = new AnalysisDelta(); |
| 2030 delta.setAnalysisLevel(source, AnalysisLevel.ALL); | 2030 delta.setAnalysisLevel(source, AnalysisLevel.ALL); |
| 2031 _context.applyAnalysisDelta(delta); | 2031 _context.applyAnalysisDelta(delta); |
| 2032 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); | 2032 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); |
| 2033 delta = new AnalysisDelta(); | 2033 delta = new AnalysisDelta(); |
| 2034 delta.setAnalysisLevel(source, AnalysisLevel.NONE); | 2034 delta.setAnalysisLevel(source, AnalysisLevel.NONE); |
| 2035 _context.applyAnalysisDelta(delta); | 2035 _context.applyAnalysisDelta(delta); |
| 2036 expect(_context.sourcesNeedingProcessing.contains(source), isFalse); | 2036 expect(_context.sourcesNeedingProcessing.contains(source), isFalse); |
| 2037 } | 2037 } |
| 2038 | 2038 |
| 2039 void xtest_performAnalysisTask_stress() { | 2039 void xtest_performAnalysisTask_stress() { |
| 2040 int maxCacheSize = 4; | 2040 int maxCacheSize = 4; |
| 2041 AnalysisOptionsImpl options = | 2041 AnalysisOptionsImpl options = |
| 2042 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 2042 new AnalysisOptionsImpl.from(_context.analysisOptions); |
| 2043 options.cacheSize = maxCacheSize; | 2043 options.cacheSize = maxCacheSize; |
| 2044 _context.analysisOptions = options; | 2044 _context.analysisOptions = options; |
| 2045 int sourceCount = maxCacheSize + 2; | 2045 int sourceCount = maxCacheSize + 2; |
| 2046 List<Source> sources = new List<Source>(); | 2046 List<Source> sources = new List<Source>(); |
| 2047 ChangeSet changeSet = new ChangeSet(); | 2047 ChangeSet changeSet = new ChangeSet(); |
| 2048 for (int i = 0; i < sourceCount; i++) { | 2048 for (int i = 0; i < sourceCount; i++) { |
| 2049 Source source = _addSource("/lib$i.dart", "library lib$i;"); | 2049 Source source = _addSource("/lib$i.dart", "library lib$i;"); |
| 2050 sources.add(source); | 2050 sources.add(source); |
| 2051 changeSet.addedSource(source); | 2051 changeSet.addedSource(source); |
| 2052 } | 2052 } |
| 2053 _context.applyChanges(changeSet); | 2053 _context.applyChanges(changeSet); |
| 2054 _context.analysisPriorityOrder = sources; | 2054 _context.analysisPriorityOrder = sources; |
| 2055 for (int i = 0; i < 1000; i++) { | 2055 for (int i = 0; i < 1000; i++) { |
| 2056 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; | 2056 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; |
| 2057 if (notice == null) { | 2057 if (notice == null) { |
| 2058 //System.out.println("test_performAnalysisTask_stress: " + i); | 2058 //System.out.println("test_performAnalysisTask_stress: " + i); |
| 2059 break; | 2059 break; |
| 2060 } | 2060 } |
| 2061 } | 2061 } |
| 2062 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; | 2062 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; |
| 2063 if (notice != null) { | 2063 if (notice != null) { |
| 2064 fail( | 2064 fail( |
| 2065 "performAnalysisTask failed to terminate after analyzing all sources")
; | 2065 "performAnalysisTask failed to terminate after analyzing all sources")
; |
| 2066 } | 2066 } |
| 2067 } | 2067 } |
| 2068 | 2068 |
| 2069 Source _addSource(String fileName, String contents) { | 2069 Source _addSource(String fileName, String contents) { |
| 2070 Source source = | 2070 Source source = new FileBasedSource(FileUtilities2.createFile(fileName)); |
| 2071 new FileBasedSource.con1(FileUtilities2.createFile(fileName)); | |
| 2072 ChangeSet changeSet = new ChangeSet(); | 2071 ChangeSet changeSet = new ChangeSet(); |
| 2073 changeSet.addedSource(source); | 2072 changeSet.addedSource(source); |
| 2074 _context.applyChanges(changeSet); | 2073 _context.applyChanges(changeSet); |
| 2075 _context.setContents(source, contents); | 2074 _context.setContents(source, contents); |
| 2076 return source; | 2075 return source; |
| 2077 } | 2076 } |
| 2078 | 2077 |
| 2079 TestSource _addSourceWithException(String fileName) { | 2078 TestSource _addSourceWithException(String fileName) { |
| 2080 return _addSourceWithException2(fileName, ""); | 2079 return _addSourceWithException2(fileName, ""); |
| 2081 } | 2080 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 options.analyzeFunctionBodies = booleanValue; | 2207 options.analyzeFunctionBodies = booleanValue; |
| 2209 options.cacheSize = i; | 2208 options.cacheSize = i; |
| 2210 options.dart2jsHint = booleanValue; | 2209 options.dart2jsHint = booleanValue; |
| 2211 options.enableNullAwareOperators = booleanValue; | 2210 options.enableNullAwareOperators = booleanValue; |
| 2212 options.enableStrictCallChecks = booleanValue; | 2211 options.enableStrictCallChecks = booleanValue; |
| 2213 options.generateImplicitErrors = booleanValue; | 2212 options.generateImplicitErrors = booleanValue; |
| 2214 options.generateSdkErrors = booleanValue; | 2213 options.generateSdkErrors = booleanValue; |
| 2215 options.hint = booleanValue; | 2214 options.hint = booleanValue; |
| 2216 options.incremental = booleanValue; | 2215 options.incremental = booleanValue; |
| 2217 options.preserveComments = booleanValue; | 2216 options.preserveComments = booleanValue; |
| 2218 AnalysisOptionsImpl copy = new AnalysisOptionsImpl.con1(options); | 2217 AnalysisOptionsImpl copy = new AnalysisOptionsImpl.from(options); |
| 2219 expect(copy.analyzeFunctionBodies, options.analyzeFunctionBodies); | 2218 expect(copy.analyzeFunctionBodies, options.analyzeFunctionBodies); |
| 2220 expect(copy.cacheSize, options.cacheSize); | 2219 expect(copy.cacheSize, options.cacheSize); |
| 2221 expect(copy.dart2jsHint, options.dart2jsHint); | 2220 expect(copy.dart2jsHint, options.dart2jsHint); |
| 2222 expect(copy.enableNullAwareOperators, options.enableNullAwareOperators); | 2221 expect(copy.enableNullAwareOperators, options.enableNullAwareOperators); |
| 2223 expect(copy.enableStrictCallChecks, options.enableStrictCallChecks); | 2222 expect(copy.enableStrictCallChecks, options.enableStrictCallChecks); |
| 2224 expect(copy.generateImplicitErrors, options.generateImplicitErrors); | 2223 expect(copy.generateImplicitErrors, options.generateImplicitErrors); |
| 2225 expect(copy.generateSdkErrors, options.generateSdkErrors); | 2224 expect(copy.generateSdkErrors, options.generateSdkErrors); |
| 2226 expect(copy.hint, options.hint); | 2225 expect(copy.hint, options.hint); |
| 2227 expect(copy.incremental, options.incremental); | 2226 expect(copy.incremental, options.incremental); |
| 2228 expect(copy.preserveComments, options.preserveComments); | 2227 expect(copy.preserveComments, options.preserveComments); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2317 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2316 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2318 } | 2317 } |
| 2319 | 2318 |
| 2320 @reflectiveTest | 2319 @reflectiveTest |
| 2321 class DartEntryTest extends EngineTestCase { | 2320 class DartEntryTest extends EngineTestCase { |
| 2322 void test_allErrors() { | 2321 void test_allErrors() { |
| 2323 Source source = new TestSource(); | 2322 Source source = new TestSource(); |
| 2324 DartEntry entry = new DartEntry(); | 2323 DartEntry entry = new DartEntry(); |
| 2325 expect(entry.allErrors, hasLength(0)); | 2324 expect(entry.allErrors, hasLength(0)); |
| 2326 entry.setValue(SourceEntry.CONTENT_ERRORS, <AnalysisError>[ | 2325 entry.setValue(SourceEntry.CONTENT_ERRORS, <AnalysisError>[ |
| 2327 new AnalysisError.con1( | 2326 new AnalysisError(source, 0, 0, ScannerErrorCode.UNABLE_GET_CONTENT, |
| 2328 source, ScannerErrorCode.UNABLE_GET_CONTENT, ['exception details']) | 2327 ['exception details']) |
| 2329 ]); | 2328 ]); |
| 2330 entry.setValue(DartEntry.SCAN_ERRORS, <AnalysisError>[ | 2329 entry.setValue(DartEntry.SCAN_ERRORS, <AnalysisError>[ |
| 2331 new AnalysisError.con1( | 2330 new AnalysisError( |
| 2332 source, ScannerErrorCode.UNTERMINATED_STRING_LITERAL) | 2331 source, 0, 0, ScannerErrorCode.UNTERMINATED_STRING_LITERAL) |
| 2333 ]); | 2332 ]); |
| 2334 entry.setValue(DartEntry.PARSE_ERRORS, <AnalysisError>[ | 2333 entry.setValue(DartEntry.PARSE_ERRORS, <AnalysisError>[ |
| 2335 new AnalysisError.con1(source, ParserErrorCode.ABSTRACT_CLASS_MEMBER) | 2334 new AnalysisError(source, 0, 0, ParserErrorCode.ABSTRACT_CLASS_MEMBER) |
| 2336 ]); | 2335 ]); |
| 2337 entry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, source, | 2336 entry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, source, |
| 2338 <AnalysisError>[ | 2337 <AnalysisError>[ |
| 2339 new AnalysisError.con1( | 2338 new AnalysisError( |
| 2340 source, CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION) | 2339 source, 0, 0, CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION) |
| 2341 ]); | 2340 ]); |
| 2342 entry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, source, | 2341 entry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, source, |
| 2343 <AnalysisError>[ | 2342 <AnalysisError>[ |
| 2344 new AnalysisError.con1( | 2343 new AnalysisError( |
| 2345 source, StaticWarningCode.CASE_BLOCK_NOT_TERMINATED) | 2344 source, 0, 0, StaticWarningCode.CASE_BLOCK_NOT_TERMINATED) |
| 2346 ]); | 2345 ]); |
| 2347 entry.setValueInLibrary(DartEntry.HINTS, source, | 2346 entry.setValueInLibrary(DartEntry.HINTS, source, |
| 2348 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE)]); | 2347 <AnalysisError>[new AnalysisError(source, 0, 0, HintCode.DEAD_CODE)]); |
| 2349 expect(entry.allErrors, hasLength(6)); | 2348 expect(entry.allErrors, hasLength(6)); |
| 2350 } | 2349 } |
| 2351 | 2350 |
| 2352 void test_creation() { | 2351 void test_creation() { |
| 2353 Source librarySource = new TestSource(); | 2352 Source librarySource = new TestSource(); |
| 2354 DartEntry entry = new DartEntry(); | 2353 DartEntry entry = new DartEntry(); |
| 2355 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); | 2354 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); |
| 2356 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); | 2355 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); |
| 2357 expect(entry.getState(DartEntry.CONTAINING_LIBRARIES), | 2356 expect(entry.getState(DartEntry.CONTAINING_LIBRARIES), |
| 2358 same(CacheState.INVALID)); | 2357 same(CacheState.INVALID)); |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3379 _setValue(DartEntry.ELEMENT, new LibraryElementImpl.forNode( | 3378 _setValue(DartEntry.ELEMENT, new LibraryElementImpl.forNode( |
| 3380 null, AstFactory.libraryIdentifier2(["lib"]))); | 3379 null, AstFactory.libraryIdentifier2(["lib"]))); |
| 3381 } | 3380 } |
| 3382 | 3381 |
| 3383 void test_setValue_exportedLibraries() { | 3382 void test_setValue_exportedLibraries() { |
| 3384 _setValue(DartEntry.EXPORTED_LIBRARIES, <Source>[new TestSource()]); | 3383 _setValue(DartEntry.EXPORTED_LIBRARIES, <Source>[new TestSource()]); |
| 3385 } | 3384 } |
| 3386 | 3385 |
| 3387 void test_setValue_hints() { | 3386 void test_setValue_hints() { |
| 3388 _setValueInLibrary(DartEntry.HINTS, | 3387 _setValueInLibrary(DartEntry.HINTS, |
| 3389 <AnalysisError>[new AnalysisError.con1(null, HintCode.DEAD_CODE)]); | 3388 <AnalysisError>[new AnalysisError(null, 0, 0, HintCode.DEAD_CODE)]); |
| 3390 } | 3389 } |
| 3391 | 3390 |
| 3392 void test_setValue_importedLibraries() { | 3391 void test_setValue_importedLibraries() { |
| 3393 _setValue(DartEntry.IMPORTED_LIBRARIES, <Source>[new TestSource()]); | 3392 _setValue(DartEntry.IMPORTED_LIBRARIES, <Source>[new TestSource()]); |
| 3394 } | 3393 } |
| 3395 | 3394 |
| 3396 void test_setValue_includedParts() { | 3395 void test_setValue_includedParts() { |
| 3397 _setValue(DartEntry.INCLUDED_PARTS, <Source>[new TestSource()]); | 3396 _setValue(DartEntry.INCLUDED_PARTS, <Source>[new TestSource()]); |
| 3398 } | 3397 } |
| 3399 | 3398 |
| 3400 void test_setValue_isClient() { | 3399 void test_setValue_isClient() { |
| 3401 _setValue(DartEntry.IS_CLIENT, true); | 3400 _setValue(DartEntry.IS_CLIENT, true); |
| 3402 } | 3401 } |
| 3403 | 3402 |
| 3404 void test_setValue_isLaunchable() { | 3403 void test_setValue_isLaunchable() { |
| 3405 _setValue(DartEntry.IS_LAUNCHABLE, true); | 3404 _setValue(DartEntry.IS_LAUNCHABLE, true); |
| 3406 } | 3405 } |
| 3407 | 3406 |
| 3408 void test_setValue_lineInfo() { | 3407 void test_setValue_lineInfo() { |
| 3409 _setValue(SourceEntry.LINE_INFO, new LineInfo(<int>[0])); | 3408 _setValue(SourceEntry.LINE_INFO, new LineInfo(<int>[0])); |
| 3410 } | 3409 } |
| 3411 | 3410 |
| 3412 void test_setValue_parsedUnit() { | 3411 void test_setValue_parsedUnit() { |
| 3413 _setValue(DartEntry.PARSED_UNIT, AstFactory.compilationUnit()); | 3412 _setValue(DartEntry.PARSED_UNIT, AstFactory.compilationUnit()); |
| 3414 } | 3413 } |
| 3415 | 3414 |
| 3416 void test_setValue_parseErrors() { | 3415 void test_setValue_parseErrors() { |
| 3417 _setValue(DartEntry.PARSE_ERRORS, <AnalysisError>[ | 3416 _setValue(DartEntry.PARSE_ERRORS, <AnalysisError>[ |
| 3418 new AnalysisError.con1(null, ParserErrorCode.ABSTRACT_CLASS_MEMBER) | 3417 new AnalysisError(null, 0, 0, ParserErrorCode.ABSTRACT_CLASS_MEMBER) |
| 3419 ]); | 3418 ]); |
| 3420 } | 3419 } |
| 3421 | 3420 |
| 3422 void test_setValue_publicNamespace() { | 3421 void test_setValue_publicNamespace() { |
| 3423 _setValue(DartEntry.PUBLIC_NAMESPACE, | 3422 _setValue(DartEntry.PUBLIC_NAMESPACE, |
| 3424 new Namespace(new HashMap<String, Element>())); | 3423 new Namespace(new HashMap<String, Element>())); |
| 3425 } | 3424 } |
| 3426 | 3425 |
| 3427 void test_setValue_resolutionErrors() { | 3426 void test_setValue_resolutionErrors() { |
| 3428 _setValueInLibrary(DartEntry.RESOLUTION_ERRORS, <AnalysisError>[ | 3427 _setValueInLibrary(DartEntry.RESOLUTION_ERRORS, <AnalysisError>[ |
| 3429 new AnalysisError.con1( | 3428 new AnalysisError( |
| 3430 null, CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION) | 3429 null, 0, 0, CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION) |
| 3431 ]); | 3430 ]); |
| 3432 } | 3431 } |
| 3433 | 3432 |
| 3434 void test_setValue_resolvedUnit() { | 3433 void test_setValue_resolvedUnit() { |
| 3435 _setValueInLibrary(DartEntry.RESOLVED_UNIT, AstFactory.compilationUnit()); | 3434 _setValueInLibrary(DartEntry.RESOLVED_UNIT, AstFactory.compilationUnit()); |
| 3436 } | 3435 } |
| 3437 | 3436 |
| 3438 void test_setValue_scanErrors() { | 3437 void test_setValue_scanErrors() { |
| 3439 _setValue(DartEntry.SCAN_ERRORS, <AnalysisError>[ | 3438 _setValue(DartEntry.SCAN_ERRORS, <AnalysisError>[ |
| 3440 new AnalysisError.con1( | 3439 new AnalysisError( |
| 3441 null, ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT) | 3440 null, 0, 0, ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT) |
| 3442 ]); | 3441 ]); |
| 3443 } | 3442 } |
| 3444 | 3443 |
| 3445 void test_setValue_sourceKind() { | 3444 void test_setValue_sourceKind() { |
| 3446 _setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 3445 _setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 3447 } | 3446 } |
| 3448 | 3447 |
| 3449 void test_setValue_tokenStream() { | 3448 void test_setValue_tokenStream() { |
| 3450 _setValue(DartEntry.TOKEN_STREAM, new Token(TokenType.LT, 5)); | 3449 _setValue(DartEntry.TOKEN_STREAM, new Token(TokenType.LT, 5)); |
| 3451 } | 3450 } |
| 3452 | 3451 |
| 3453 void test_setValue_verificationErrors() { | 3452 void test_setValue_verificationErrors() { |
| 3454 _setValueInLibrary(DartEntry.VERIFICATION_ERRORS, <AnalysisError>[ | 3453 _setValueInLibrary(DartEntry.VERIFICATION_ERRORS, <AnalysisError>[ |
| 3455 new AnalysisError.con1(null, StaticWarningCode.CASE_BLOCK_NOT_TERMINATED) | 3454 new AnalysisError(null, 0, 0, StaticWarningCode.CASE_BLOCK_NOT_TERMINATED) |
| 3456 ]); | 3455 ]); |
| 3457 } | 3456 } |
| 3458 | 3457 |
| 3459 DartEntry _entryWithValidState([Source firstLibrary, Source secondLibrary]) { | 3458 DartEntry _entryWithValidState([Source firstLibrary, Source secondLibrary]) { |
| 3460 DartEntry entry = new DartEntry(); | 3459 DartEntry entry = new DartEntry(); |
| 3461 entry.setValue(SourceEntry.CONTENT, null); | 3460 entry.setValue(SourceEntry.CONTENT, null); |
| 3462 entry.setValue(SourceEntry.CONTENT_ERRORS, null); | 3461 entry.setValue(SourceEntry.CONTENT_ERRORS, null); |
| 3463 entry.setValue(SourceEntry.LINE_INFO, null); | 3462 entry.setValue(SourceEntry.LINE_INFO, null); |
| 3464 entry.setValue(DartEntry.CONTAINING_LIBRARIES, null); | 3463 entry.setValue(DartEntry.CONTAINING_LIBRARIES, null); |
| 3465 entry.setValue(DartEntry.ELEMENT, null); | 3464 entry.setValue(DartEntry.ELEMENT, null); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3602 void test_getLibraryElement() { | 3601 void test_getLibraryElement() { |
| 3603 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3602 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3604 LibraryElement element = ElementFactory.library(context, "lib"); | 3603 LibraryElement element = ElementFactory.library(context, "lib"); |
| 3605 GenerateDartErrorsTask task = | 3604 GenerateDartErrorsTask task = |
| 3606 new GenerateDartErrorsTask(context, null, null, element); | 3605 new GenerateDartErrorsTask(context, null, null, element); |
| 3607 expect(task.libraryElement, same(element)); | 3606 expect(task.libraryElement, same(element)); |
| 3608 } | 3607 } |
| 3609 | 3608 |
| 3610 void test_getSource() { | 3609 void test_getSource() { |
| 3611 Source source = | 3610 Source source = |
| 3612 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 3611 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 3613 GenerateDartErrorsTask task = | 3612 GenerateDartErrorsTask task = |
| 3614 new GenerateDartErrorsTask(null, source, null, null); | 3613 new GenerateDartErrorsTask(null, source, null, null); |
| 3615 expect(task.source, same(source)); | 3614 expect(task.source, same(source)); |
| 3616 } | 3615 } |
| 3617 | 3616 |
| 3618 void test_perform() { | 3617 void test_perform() { |
| 3619 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3618 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3620 Source source = | 3619 Source source = |
| 3621 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 3620 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 3622 ChangeSet changeSet = new ChangeSet(); | 3621 ChangeSet changeSet = new ChangeSet(); |
| 3623 changeSet.addedSource(source); | 3622 changeSet.addedSource(source); |
| 3624 context.applyChanges(changeSet); | 3623 context.applyChanges(changeSet); |
| 3625 context.setContents(source, r''' | 3624 context.setContents(source, r''' |
| 3626 library lib; | 3625 library lib; |
| 3627 class A { | 3626 class A { |
| 3628 int f = new A(); | 3627 int f = new A(); |
| 3629 }'''); | 3628 }'''); |
| 3630 LibraryElement libraryElement = context.computeLibraryElement(source); | 3629 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3631 CompilationUnit unit = | 3630 CompilationUnit unit = |
| 3632 context.getResolvedCompilationUnit(source, libraryElement); | 3631 context.getResolvedCompilationUnit(source, libraryElement); |
| 3633 GenerateDartErrorsTask task = | 3632 GenerateDartErrorsTask task = |
| 3634 new GenerateDartErrorsTask(context, source, unit, libraryElement); | 3633 new GenerateDartErrorsTask(context, source, unit, libraryElement); |
| 3635 task.perform( | 3634 task.perform( |
| 3636 new GenerateDartErrorsTaskTestTV_perform(libraryElement, source)); | 3635 new GenerateDartErrorsTaskTestTV_perform(libraryElement, source)); |
| 3637 } | 3636 } |
| 3638 | 3637 |
| 3639 void test_perform_validateDirectives() { | 3638 void test_perform_validateDirectives() { |
| 3640 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3639 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3641 Source source = | 3640 Source source = |
| 3642 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 3641 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 3643 ChangeSet changeSet = new ChangeSet(); | 3642 ChangeSet changeSet = new ChangeSet(); |
| 3644 changeSet.addedSource(source); | 3643 changeSet.addedSource(source); |
| 3645 context.applyChanges(changeSet); | 3644 context.applyChanges(changeSet); |
| 3646 // TODO(scheglov) "import" causes second error reported | 3645 // TODO(scheglov) "import" causes second error reported |
| 3647 // context.setContents(source, EngineTestCase.createSource([ | 3646 // context.setContents(source, EngineTestCase.createSource([ |
| 3648 // "library lib;", | 3647 // "library lib;", |
| 3649 // "import 'invaliduri^.dart';", | 3648 // "import 'invaliduri^.dart';", |
| 3650 // "export '\${a}lib3.dart';", | 3649 // "export '\${a}lib3.dart';", |
| 3651 // "part '/does/not/exist.dart';", | 3650 // "part '/does/not/exist.dart';", |
| 3652 // "class A {}"])); | 3651 // "class A {}"])); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3726 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3725 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3727 LibraryElement element = ElementFactory.library(context, "lib"); | 3726 LibraryElement element = ElementFactory.library(context, "lib"); |
| 3728 GenerateDartHintsTask task = | 3727 GenerateDartHintsTask task = |
| 3729 new GenerateDartHintsTask(context, null, element); | 3728 new GenerateDartHintsTask(context, null, element); |
| 3730 expect(task.libraryElement, same(element)); | 3729 expect(task.libraryElement, same(element)); |
| 3731 } | 3730 } |
| 3732 void test_perform() { | 3731 void test_perform() { |
| 3733 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3732 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3734 ChangeSet changeSet = new ChangeSet(); | 3733 ChangeSet changeSet = new ChangeSet(); |
| 3735 Source librarySource = | 3734 Source librarySource = |
| 3736 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 3735 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 3737 changeSet.addedSource(librarySource); | 3736 changeSet.addedSource(librarySource); |
| 3738 Source unusedSource = | 3737 Source unusedSource = |
| 3739 new FileBasedSource.con1(FileUtilities2.createFile("/unused.dart")); | 3738 new FileBasedSource(FileUtilities2.createFile("/unused.dart")); |
| 3740 changeSet.addedSource(unusedSource); | 3739 changeSet.addedSource(unusedSource); |
| 3741 Source partSource = | 3740 Source partSource = |
| 3742 new FileBasedSource.con1(FileUtilities2.createFile("/part.dart")); | 3741 new FileBasedSource(FileUtilities2.createFile("/part.dart")); |
| 3743 changeSet.addedSource(partSource); | 3742 changeSet.addedSource(partSource); |
| 3744 context.applyChanges(changeSet); | 3743 context.applyChanges(changeSet); |
| 3745 context.setContents(librarySource, r''' | 3744 context.setContents(librarySource, r''' |
| 3746 library lib; | 3745 library lib; |
| 3747 import 'unused.dart'; | 3746 import 'unused.dart'; |
| 3748 part 'part.dart';'''); | 3747 part 'part.dart';'''); |
| 3749 context.setContents(unusedSource, "library unused;"); | 3748 context.setContents(unusedSource, "library unused;"); |
| 3750 context.setContents(partSource, "part of lib;"); | 3749 context.setContents(partSource, "part of lib;"); |
| 3751 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(2); | 3750 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(2); |
| 3752 units[0] = new TimestampedData<CompilationUnit>( | 3751 units[0] = new TimestampedData<CompilationUnit>( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3805 } | 3804 } |
| 3806 void test_lintMap() { | 3805 void test_lintMap() { |
| 3807 GenerateDartLintsTask task = new GenerateDartLintsTask(null, null, null); | 3806 GenerateDartLintsTask task = new GenerateDartLintsTask(null, null, null); |
| 3808 expect(task.lintMap, isNull); | 3807 expect(task.lintMap, isNull); |
| 3809 } | 3808 } |
| 3810 | 3809 |
| 3811 void test_perform() { | 3810 void test_perform() { |
| 3812 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3811 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3813 ChangeSet changeSet = new ChangeSet(); | 3812 ChangeSet changeSet = new ChangeSet(); |
| 3814 Source librarySource = | 3813 Source librarySource = |
| 3815 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 3814 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 3816 changeSet.addedSource(librarySource); | 3815 changeSet.addedSource(librarySource); |
| 3817 context.applyChanges(changeSet); | 3816 context.applyChanges(changeSet); |
| 3818 context.setContents(librarySource, r''' | 3817 context.setContents(librarySource, r''' |
| 3819 library lib; | 3818 library lib; |
| 3820 '''); | 3819 '''); |
| 3821 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(1); | 3820 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(1); |
| 3822 units[0] = new TimestampedData<CompilationUnit>( | 3821 units[0] = new TimestampedData<CompilationUnit>( |
| 3823 context.getModificationStamp(librarySource), | 3822 context.getModificationStamp(librarySource), |
| 3824 context.resolveCompilationUnit2(librarySource, librarySource)); | 3823 context.resolveCompilationUnit2(librarySource, librarySource)); |
| 3825 GenerateDartLintsTask task = new GenerateDartLintsTask( | 3824 GenerateDartLintsTask task = new GenerateDartLintsTask( |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3932 void test_creation() { | 3931 void test_creation() { |
| 3933 HtmlEntry entry = new HtmlEntry(); | 3932 HtmlEntry entry = new HtmlEntry(); |
| 3934 expect(entry, isNotNull); | 3933 expect(entry, isNotNull); |
| 3935 } | 3934 } |
| 3936 | 3935 |
| 3937 void test_getAllErrors() { | 3936 void test_getAllErrors() { |
| 3938 Source source = new TestSource(); | 3937 Source source = new TestSource(); |
| 3939 HtmlEntry entry = new HtmlEntry(); | 3938 HtmlEntry entry = new HtmlEntry(); |
| 3940 expect(entry.allErrors, hasLength(0)); | 3939 expect(entry.allErrors, hasLength(0)); |
| 3941 entry.setValue(HtmlEntry.PARSE_ERRORS, <AnalysisError>[ | 3940 entry.setValue(HtmlEntry.PARSE_ERRORS, <AnalysisError>[ |
| 3942 new AnalysisError.con1(source, ParserErrorCode.EXPECTED_TOKEN, [";"]) | 3941 new AnalysisError(source, 0, 0, ParserErrorCode.EXPECTED_TOKEN, [";"]) |
| 3943 ]); | 3942 ]); |
| 3944 entry.setValue(HtmlEntry.RESOLUTION_ERRORS, <AnalysisError>[ | 3943 entry.setValue(HtmlEntry.RESOLUTION_ERRORS, <AnalysisError>[ |
| 3945 new AnalysisError.con1(source, HtmlWarningCode.INVALID_URI, ["-"]) | 3944 new AnalysisError(source, 0, 0, HtmlWarningCode.INVALID_URI, ["-"]) |
| 3946 ]); | 3945 ]); |
| 3947 entry.setValue(HtmlEntry.HINTS, | 3946 entry.setValue(HtmlEntry.HINTS, |
| 3948 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE)]); | 3947 <AnalysisError>[new AnalysisError(source, 0, 0, HintCode.DEAD_CODE)]); |
| 3949 expect(entry.allErrors, hasLength(3)); | 3948 expect(entry.allErrors, hasLength(3)); |
| 3950 } | 3949 } |
| 3951 | 3950 |
| 3952 void test_invalidateAllResolutionInformation() { | 3951 void test_invalidateAllResolutionInformation() { |
| 3953 HtmlEntry entry = _entryWithValidState(); | 3952 HtmlEntry entry = _entryWithValidState(); |
| 3954 entry.invalidateAllResolutionInformation(false); | 3953 entry.invalidateAllResolutionInformation(false); |
| 3955 expect(entry.getState(HtmlEntry.ELEMENT), same(CacheState.INVALID)); | 3954 expect(entry.getState(HtmlEntry.ELEMENT), same(CacheState.INVALID)); |
| 3956 expect(entry.getState(HtmlEntry.HINTS), same(CacheState.INVALID)); | 3955 expect(entry.getState(HtmlEntry.HINTS), same(CacheState.INVALID)); |
| 3957 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.VALID)); | 3956 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.VALID)); |
| 3958 expect(entry.getState(HtmlEntry.PARSE_ERRORS), same(CacheState.VALID)); | 3957 expect(entry.getState(HtmlEntry.PARSE_ERRORS), same(CacheState.VALID)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4004 void test_setState_resolutionErrors() { | 4003 void test_setState_resolutionErrors() { |
| 4005 state = HtmlEntry.RESOLUTION_ERRORS; | 4004 state = HtmlEntry.RESOLUTION_ERRORS; |
| 4006 } | 4005 } |
| 4007 | 4006 |
| 4008 void test_setValue_element() { | 4007 void test_setValue_element() { |
| 4009 _setValue(HtmlEntry.ELEMENT, new HtmlElementImpl(null, "test.html")); | 4008 _setValue(HtmlEntry.ELEMENT, new HtmlElementImpl(null, "test.html")); |
| 4010 } | 4009 } |
| 4011 | 4010 |
| 4012 void test_setValue_hints() { | 4011 void test_setValue_hints() { |
| 4013 _setValue(HtmlEntry.HINTS, | 4012 _setValue(HtmlEntry.HINTS, |
| 4014 <AnalysisError>[new AnalysisError.con1(null, HintCode.DEAD_CODE)]); | 4013 <AnalysisError>[new AnalysisError(null, 0, 0, HintCode.DEAD_CODE)]); |
| 4015 } | 4014 } |
| 4016 | 4015 |
| 4017 void test_setValue_illegal() { | 4016 void test_setValue_illegal() { |
| 4018 HtmlEntry entry = new HtmlEntry(); | 4017 HtmlEntry entry = new HtmlEntry(); |
| 4019 try { | 4018 try { |
| 4020 entry.setValue(DartEntry.ELEMENT, null); | 4019 entry.setValue(DartEntry.ELEMENT, null); |
| 4021 fail("Expected ArgumentError for DartEntry.ELEMENT"); | 4020 fail("Expected ArgumentError for DartEntry.ELEMENT"); |
| 4022 } on ArgumentError {} | 4021 } on ArgumentError {} |
| 4023 } | 4022 } |
| 4024 | 4023 |
| 4025 void test_setValue_lineInfo() { | 4024 void test_setValue_lineInfo() { |
| 4026 _setValue(SourceEntry.LINE_INFO, new LineInfo(<int>[0])); | 4025 _setValue(SourceEntry.LINE_INFO, new LineInfo(<int>[0])); |
| 4027 } | 4026 } |
| 4028 | 4027 |
| 4029 void test_setValue_parsedUnit() { | 4028 void test_setValue_parsedUnit() { |
| 4030 _setValue(HtmlEntry.PARSED_UNIT, new ht.HtmlUnit(null, null, null)); | 4029 _setValue(HtmlEntry.PARSED_UNIT, new ht.HtmlUnit(null, null, null)); |
| 4031 } | 4030 } |
| 4032 | 4031 |
| 4033 void test_setValue_parseErrors() { | 4032 void test_setValue_parseErrors() { |
| 4034 _setValue(HtmlEntry.PARSE_ERRORS, <AnalysisError>[ | 4033 _setValue(HtmlEntry.PARSE_ERRORS, <AnalysisError>[ |
| 4035 new AnalysisError.con1(null, HtmlWarningCode.INVALID_URI, ["-"]) | 4034 new AnalysisError(null, 0, 0, HtmlWarningCode.INVALID_URI, ["-"]) |
| 4036 ]); | 4035 ]); |
| 4037 } | 4036 } |
| 4038 | 4037 |
| 4039 void test_setValue_referencedLibraries() { | 4038 void test_setValue_referencedLibraries() { |
| 4040 _setValue(HtmlEntry.REFERENCED_LIBRARIES, <Source>[new TestSource()]); | 4039 _setValue(HtmlEntry.REFERENCED_LIBRARIES, <Source>[new TestSource()]); |
| 4041 } | 4040 } |
| 4042 | 4041 |
| 4043 void test_setValue_resolutionErrors() { | 4042 void test_setValue_resolutionErrors() { |
| 4044 _setValue(HtmlEntry.RESOLUTION_ERRORS, <AnalysisError>[ | 4043 _setValue(HtmlEntry.RESOLUTION_ERRORS, <AnalysisError>[ |
| 4045 new AnalysisError.con1(null, HtmlWarningCode.INVALID_URI, ["-"]) | 4044 new AnalysisError(null, 0, 0, HtmlWarningCode.INVALID_URI, ["-"]) |
| 4046 ]); | 4045 ]); |
| 4047 } | 4046 } |
| 4048 | 4047 |
| 4049 HtmlEntry _entryWithValidState() { | 4048 HtmlEntry _entryWithValidState() { |
| 4050 HtmlEntry entry = new HtmlEntry(); | 4049 HtmlEntry entry = new HtmlEntry(); |
| 4051 entry.setValue(HtmlEntry.ELEMENT, null); | 4050 entry.setValue(HtmlEntry.ELEMENT, null); |
| 4052 entry.setValue(HtmlEntry.HINTS, null); | 4051 entry.setValue(HtmlEntry.HINTS, null); |
| 4053 entry.setValue(SourceEntry.LINE_INFO, null); | 4052 entry.setValue(SourceEntry.LINE_INFO, null); |
| 4054 entry.setValue(HtmlEntry.PARSE_ERRORS, null); | 4053 entry.setValue(HtmlEntry.PARSE_ERRORS, null); |
| 4055 entry.setValue(HtmlEntry.PARSED_UNIT, null); | 4054 entry.setValue(HtmlEntry.PARSED_UNIT, null); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4446 CompilationUnit visitIncrementalAnalysisTask( | 4445 CompilationUnit visitIncrementalAnalysisTask( |
| 4447 IncrementalAnalysisTask incrementalAnalysisTask) => task.compilationUnit; | 4446 IncrementalAnalysisTask incrementalAnalysisTask) => task.compilationUnit; |
| 4448 } | 4447 } |
| 4449 | 4448 |
| 4450 @reflectiveTest | 4449 @reflectiveTest |
| 4451 class LintGeneratorTest extends EngineTestCase { | 4450 class LintGeneratorTest extends EngineTestCase { |
| 4452 void test_generate() { | 4451 void test_generate() { |
| 4453 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 4452 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 4454 ChangeSet changeSet = new ChangeSet(); | 4453 ChangeSet changeSet = new ChangeSet(); |
| 4455 Source librarySource = | 4454 Source librarySource = |
| 4456 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 4455 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 4457 changeSet.addedSource(librarySource); | 4456 changeSet.addedSource(librarySource); |
| 4458 context.applyChanges(changeSet); | 4457 context.applyChanges(changeSet); |
| 4459 context.setContents(librarySource, r''' | 4458 context.setContents(librarySource, r''' |
| 4460 library lib; | 4459 library lib; |
| 4461 '''); | 4460 '''); |
| 4462 | 4461 |
| 4463 CompilationUnit unit = | 4462 CompilationUnit unit = |
| 4464 context.resolveCompilationUnit2(librarySource, librarySource); | 4463 context.resolveCompilationUnit2(librarySource, librarySource); |
| 4465 List<CompilationUnit> units = <CompilationUnit>[]; | 4464 List<CompilationUnit> units = <CompilationUnit>[]; |
| 4466 units.add(unit); | 4465 units.add(unit); |
| 4467 | 4466 |
| 4468 RecordingErrorListener errorListener = new RecordingErrorListener(); | 4467 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 4469 | 4468 |
| 4470 LintGeneratorTest_Linter linter = new LintGeneratorTest_Linter(); | 4469 LintGeneratorTest_Linter linter = new LintGeneratorTest_Linter(); |
| 4471 | 4470 |
| 4472 LintGenerator lintGenerator = | 4471 LintGenerator lintGenerator = |
| 4473 new LintGenerator(units, errorListener, [linter]); | 4472 new LintGenerator(units, errorListener, [linter]); |
| 4474 lintGenerator.generate(); | 4473 lintGenerator.generate(); |
| 4475 | 4474 |
| 4476 linter.testExpectations(); | 4475 linter.testExpectations(); |
| 4477 } | 4476 } |
| 4478 | 4477 |
| 4479 void test_generate_null_visitor() { | 4478 void test_generate_null_visitor() { |
| 4480 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 4479 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 4481 ChangeSet changeSet = new ChangeSet(); | 4480 ChangeSet changeSet = new ChangeSet(); |
| 4482 Source librarySource = | 4481 Source librarySource = |
| 4483 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 4482 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 4484 changeSet.addedSource(librarySource); | 4483 changeSet.addedSource(librarySource); |
| 4485 context.applyChanges(changeSet); | 4484 context.applyChanges(changeSet); |
| 4486 context.setContents(librarySource, r''' | 4485 context.setContents(librarySource, r''' |
| 4487 library lib; | 4486 library lib; |
| 4488 '''); | 4487 '''); |
| 4489 | 4488 |
| 4490 CompilationUnit unit = | 4489 CompilationUnit unit = |
| 4491 context.resolveCompilationUnit2(librarySource, librarySource); | 4490 context.resolveCompilationUnit2(librarySource, librarySource); |
| 4492 List<CompilationUnit> units = <CompilationUnit>[]; | 4491 List<CompilationUnit> units = <CompilationUnit>[]; |
| 4493 units.add(unit); | 4492 units.add(unit); |
| (...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6593 @override | 6592 @override |
| 6594 bool exists() => true; | 6593 bool exists() => true; |
| 6595 } | 6594 } |
| 6596 | 6595 |
| 6597 class _UniversalCachePartitionTest_test_setMaxCacheSize | 6596 class _UniversalCachePartitionTest_test_setMaxCacheSize |
| 6598 implements CacheRetentionPolicy { | 6597 implements CacheRetentionPolicy { |
| 6599 @override | 6598 @override |
| 6600 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => | 6599 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => |
| 6601 RetentionPriority.LOW; | 6600 RetentionPriority.LOW; |
| 6602 } | 6601 } |
| OLD | NEW |