Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.src.context.context; | 5 library analyzer.src.context.context; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/cancelable_future.dart'; | 10 import 'package:analyzer/src/cancelable_future.dart'; |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 | 596 |
| 597 @override | 597 @override |
| 598 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( | 598 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( |
| 599 Source unitSource, Source librarySource) { | 599 Source unitSource, Source librarySource) { |
| 600 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | 600 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || |
| 601 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | 601 !AnalysisEngine.isDartFileName(librarySource.shortName)) { |
| 602 return new CancelableFuture.error(new AnalysisNotScheduledError()); | 602 return new CancelableFuture.error(new AnalysisNotScheduledError()); |
| 603 } | 603 } |
| 604 return new _AnalysisFutureHelper<CompilationUnit>(this).computeAsync( | 604 return new _AnalysisFutureHelper<CompilationUnit>(this).computeAsync( |
| 605 new LibrarySpecificUnit(librarySource, unitSource), (CacheEntry entry) { | 605 new LibrarySpecificUnit(librarySource, unitSource), (CacheEntry entry) { |
| 606 CacheState state = entry.getState(RESOLVED_UNIT); | 606 CacheState state = entry.getState(RESOLVED_UNIT6); |
|
Brian Wilkerson
2015/05/12 00:43:22
These two uses need to remain RESOLVED_UNIT.
| |
| 607 if (state == CacheState.ERROR) { | 607 if (state == CacheState.ERROR) { |
| 608 throw entry.exception; | 608 throw entry.exception; |
| 609 } else if (state == CacheState.INVALID) { | 609 } else if (state == CacheState.INVALID) { |
| 610 return null; | 610 return null; |
| 611 } | 611 } |
| 612 return entry.getValue(RESOLVED_UNIT); | 612 return entry.getValue(RESOLVED_UNIT6); |
| 613 }); | 613 }); |
| 614 } | 614 } |
| 615 | 615 |
| 616 /** | 616 /** |
| 617 * Create an analysis cache based on the given source [factory]. | 617 * Create an analysis cache based on the given source [factory]. |
| 618 */ | 618 */ |
| 619 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 619 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
| 620 if (factory == null) { | 620 if (factory == null) { |
| 621 return new AnalysisCache(<CachePartition>[_privatePartition]); | 621 return new AnalysisCache(<CachePartition>[_privatePartition]); |
| 622 } | 622 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 642 } | 642 } |
| 643 | 643 |
| 644 @override | 644 @override |
| 645 List<CompilationUnit> ensureResolvedDartUnits(Source unitSource) { | 645 List<CompilationUnit> ensureResolvedDartUnits(Source unitSource) { |
| 646 // Check every library. | 646 // Check every library. |
| 647 List<CompilationUnit> units = <CompilationUnit>[]; | 647 List<CompilationUnit> units = <CompilationUnit>[]; |
| 648 List<Source> containingLibraries = getLibrariesContaining(unitSource); | 648 List<Source> containingLibraries = getLibrariesContaining(unitSource); |
| 649 for (Source librarySource in containingLibraries) { | 649 for (Source librarySource in containingLibraries) { |
| 650 LibrarySpecificUnit target = | 650 LibrarySpecificUnit target = |
| 651 new LibrarySpecificUnit(librarySource, unitSource); | 651 new LibrarySpecificUnit(librarySource, unitSource); |
| 652 CompilationUnit unit = _cache.getValue(target, RESOLVED_UNIT); | 652 CompilationUnit unit = _cache.getValue(target, RESOLVED_UNIT6); |
|
Brian Wilkerson
2015/05/12 00:43:22
I'm fairly confident that these three uses need to
| |
| 653 if (unit == null) { | 653 if (unit == null) { |
| 654 units = null; | 654 units = null; |
| 655 break; | 655 break; |
| 656 } | 656 } |
| 657 units.add(unit); | 657 units.add(unit); |
| 658 } | 658 } |
| 659 // If we have results, then we're done. | 659 // If we have results, then we're done. |
| 660 if (units != null) { | 660 if (units != null) { |
| 661 return units; | 661 return units; |
| 662 } | 662 } |
| 663 // Schedule recomputing RESOLVED_UNIT results. | 663 // Schedule recomputing RESOLVED_UNIT results. |
| 664 for (Source librarySource in containingLibraries) { | 664 for (Source librarySource in containingLibraries) { |
| 665 LibrarySpecificUnit target = | 665 LibrarySpecificUnit target = |
| 666 new LibrarySpecificUnit(librarySource, unitSource); | 666 new LibrarySpecificUnit(librarySource, unitSource); |
| 667 if (_cache.getState(target, RESOLVED_UNIT) == CacheState.FLUSHED) { | 667 if (_cache.getState(target, RESOLVED_UNIT6) == CacheState.FLUSHED) { |
| 668 dartWorkManager.addPriorityResult(target, RESOLVED_UNIT); | 668 dartWorkManager.addPriorityResult(target, RESOLVED_UNIT6); |
| 669 } | 669 } |
| 670 } | 670 } |
| 671 return null; | 671 return null; |
| 672 } | 672 } |
| 673 | 673 |
| 674 @override | 674 @override |
| 675 bool exists(Source source) { | 675 bool exists(Source source) { |
| 676 if (source == null) { | 676 if (source == null) { |
| 677 return false; | 677 return false; |
| 678 } | 678 } |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 } | 934 } |
| 935 | 935 |
| 936 @override | 936 @override |
| 937 CompilationUnit getResolvedCompilationUnit2( | 937 CompilationUnit getResolvedCompilationUnit2( |
| 938 Source unitSource, Source librarySource) { | 938 Source unitSource, Source librarySource) { |
| 939 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | 939 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || |
| 940 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | 940 !AnalysisEngine.isDartFileName(librarySource.shortName)) { |
| 941 return null; | 941 return null; |
| 942 } | 942 } |
| 943 return _cache.getValue( | 943 return _cache.getValue( |
| 944 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); | 944 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT6); |
|
Brian Wilkerson
2015/05/12 00:43:22
This needs to remain RESOLVED_UNIT.
| |
| 945 } | 945 } |
| 946 | 946 |
| 947 @override | 947 @override |
| 948 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 948 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
| 949 // TODO(brianwilkerson) Implement this. | 949 // TODO(brianwilkerson) Implement this. |
| 950 // SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); | 950 // SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); |
| 951 // if (sourceEntry is HtmlEntry) { | 951 // if (sourceEntry is HtmlEntry) { |
| 952 // HtmlEntry htmlEntry = sourceEntry; | 952 // HtmlEntry htmlEntry = sourceEntry; |
| 953 // return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 953 // return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 954 // } | 954 // } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1104 setValue(SOURCE_KIND, SourceKind.LIBRARY); | 1104 setValue(SOURCE_KIND, SourceKind.LIBRARY); |
| 1105 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); | 1105 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); |
| 1106 setValue(UNITS, <Source>[librarySource]); | 1106 setValue(UNITS, <Source>[librarySource]); |
| 1107 | 1107 |
| 1108 LibrarySpecificUnit unit = | 1108 LibrarySpecificUnit unit = |
| 1109 new LibrarySpecificUnit(librarySource, librarySource); | 1109 new LibrarySpecificUnit(librarySource, librarySource); |
| 1110 entry = getCacheEntry(unit); | 1110 entry = getCacheEntry(unit); |
| 1111 setValue(HINTS, AnalysisError.NO_ERRORS); | 1111 setValue(HINTS, AnalysisError.NO_ERRORS); |
| 1112 // dartEntry.setValue(LINTS, AnalysisError.NO_ERRORS); | 1112 // dartEntry.setValue(LINTS, AnalysisError.NO_ERRORS); |
| 1113 entry.setState(RESOLVE_REFERENCES_ERRORS, CacheState.FLUSHED); | 1113 entry.setState(RESOLVE_REFERENCES_ERRORS, CacheState.FLUSHED); |
| 1114 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); | 1114 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); |
|
Brian Wilkerson
2015/05/12 00:43:22
This needs to remain RESOLVED_UNIT, with RESOLVED_
| |
| 1115 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); | 1115 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); |
| 1116 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); | 1116 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); |
| 1117 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); | 1117 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); |
| 1118 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); | 1118 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); |
| 1119 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); | 1119 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); |
| 1120 // USED_IMPORTED_ELEMENTS | 1120 // USED_IMPORTED_ELEMENTS |
| 1121 // USED_LOCAL_ELEMENTS | 1121 // USED_LOCAL_ELEMENTS |
| 1122 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); | 1122 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); |
| 1123 }); | 1123 }); |
| 1124 | 1124 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 @override | 1143 @override |
| 1144 CompilationUnit resolveCompilationUnit2( | 1144 CompilationUnit resolveCompilationUnit2( |
| 1145 Source unitSource, Source librarySource) { | 1145 Source unitSource, Source librarySource) { |
| 1146 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | 1146 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || |
| 1147 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | 1147 !AnalysisEngine.isDartFileName(librarySource.shortName)) { |
| 1148 return null; | 1148 return null; |
| 1149 } | 1149 } |
| 1150 return _computeResult( | 1150 return _computeResult( |
| 1151 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); | 1151 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT6); |
|
scheglov
2015/05/11 23:58:30
I think we should return RESOLVED_UNIT from Analys
Brian Wilkerson
2015/05/12 00:43:22
Yes, this needs to remain RESOLVED_UNIT.
| |
| 1152 } | 1152 } |
| 1153 | 1153 |
| 1154 @override | 1154 @override |
| 1155 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { | 1155 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { |
| 1156 computeHtmlElement(htmlSource); | 1156 computeHtmlElement(htmlSource); |
| 1157 return parseHtmlUnit(htmlSource); | 1157 return parseHtmlUnit(htmlSource); |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 @override | 1160 @override |
| 1161 void setChangedContents(Source source, String contents, int offset, | 1161 void setChangedContents(Source source, String contents, int offset, |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1498 state = libraryEntry.getState(LIBRARY_ELEMENT); | 1498 state = libraryEntry.getState(LIBRARY_ELEMENT); |
| 1499 if (state == CacheState.INVALID || | 1499 if (state == CacheState.INVALID || |
| 1500 (isPriority && state == CacheState.FLUSHED)) { | 1500 (isPriority && state == CacheState.FLUSHED)) { |
| 1501 sources.add(source); | 1501 sources.add(source); |
| 1502 return; | 1502 return; |
| 1503 } else if (state == CacheState.ERROR) { | 1503 } else if (state == CacheState.ERROR) { |
| 1504 return; | 1504 return; |
| 1505 } | 1505 } |
| 1506 CacheEntry unitEntry = | 1506 CacheEntry unitEntry = |
| 1507 _cache.get(new LibrarySpecificUnit(librarySource, source)); | 1507 _cache.get(new LibrarySpecificUnit(librarySource, source)); |
| 1508 state = unitEntry.getState(RESOLVED_UNIT); | 1508 state = unitEntry.getState(RESOLVED_UNIT6); |
|
Brian Wilkerson
2015/05/12 00:43:22
This needs to remain RESOLVED_UNIT.
| |
| 1509 if (state == CacheState.INVALID || | 1509 if (state == CacheState.INVALID || |
| 1510 (isPriority && state == CacheState.FLUSHED)) { | 1510 (isPriority && state == CacheState.FLUSHED)) { |
| 1511 sources.add(source); | 1511 sources.add(source); |
| 1512 return; | 1512 return; |
| 1513 } else if (state == CacheState.ERROR) { | 1513 } else if (state == CacheState.ERROR) { |
| 1514 return; | 1514 return; |
| 1515 } | 1515 } |
| 1516 if (_shouldErrorsBeAnalyzed(source, unitEntry)) { | 1516 if (_shouldErrorsBeAnalyzed(source, unitEntry)) { |
| 1517 state = unitEntry.getState(VERIFY_ERRORS); | 1517 state = unitEntry.getState(VERIFY_ERRORS); |
| 1518 if (state == CacheState.INVALID || | 1518 if (state == CacheState.INVALID || |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2031 PendingFuture pendingFuture = | 2031 PendingFuture pendingFuture = |
| 2032 new PendingFuture<T>(_context, target, computeValue); | 2032 new PendingFuture<T>(_context, target, computeValue); |
| 2033 if (!pendingFuture.evaluate(entry)) { | 2033 if (!pendingFuture.evaluate(entry)) { |
| 2034 _context._pendingFutureTargets | 2034 _context._pendingFutureTargets |
| 2035 .putIfAbsent(target, () => <PendingFuture>[]) | 2035 .putIfAbsent(target, () => <PendingFuture>[]) |
| 2036 .add(pendingFuture); | 2036 .add(pendingFuture); |
| 2037 } | 2037 } |
| 2038 return pendingFuture.future; | 2038 return pendingFuture.future; |
| 2039 } | 2039 } |
| 2040 } | 2040 } |
| OLD | NEW |