Skip to content

Commit

Permalink
Provide MODIFICATION_TIME as '0' for in-summary sources.
Browse files Browse the repository at this point in the history
We don't want to run GetContentTask for these sources.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2253393003 .
  • Loading branch information
scheglov committed Aug 18, 2016
1 parent 6a3e185 commit a730f03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pkg/analyzer/lib/src/summary/package_bundle_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ abstract class ResynthesizerResultProvider extends ResultProvider {
result == READY_LIBRARY_ELEMENT7) {
entry.setValue(result, true, TargetedResult.EMPTY_LIST);
return true;
} else if (result == MODIFICATION_TIME) {
entry.setValue(result, 0, TargetedResult.EMPTY_LIST);
return true;
} else if (result == SOURCE_KIND) {
if (_dataStore.linkedMap.containsKey(uriString)) {
entry.setValue(result, SourceKind.LIBRARY, TargetedResult.EMPTY_LIST);
Expand Down
18 changes: 15 additions & 3 deletions pkg/analyzer/test/src/summary/package_bundle_reader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,29 @@ class ResynthesizerResultProviderTest {
expect(entry2.getValue(CONTAINING_LIBRARIES), unorderedEquals([source1]));
}

test_compute_LINE_INFO_emptyLineStarts() {
when(unlinkedUnit1.lineStarts).thenReturn(<int>[]);
bool success = provider.compute(entry1, LINE_INFO);
expect(success, isFalse);
}

test_compute_LINE_INFO_hasLineStarts() {
when(unlinkedUnit1.lineStarts).thenReturn(<int>[10, 20, 30]);
bool success = provider.compute(entry1, LINE_INFO);
expect(success, isTrue);
expect(entry1.getValue(LINE_INFO).lineStarts, <int>[10, 20, 30]);
}

test_compute_LINE_INFO_emptyLineStarts() {
when(unlinkedUnit1.lineStarts).thenReturn(<int>[]);
bool success = provider.compute(entry1, LINE_INFO);
test_compute_MODIFICATION_TIME_hasResult() {
bool success = provider.compute(entry1, MODIFICATION_TIME);
expect(success, isTrue);
expect(entry1.getValue(MODIFICATION_TIME), 0);
}

test_compute_MODIFICATION_TIME_noResult() {
bool success = provider.compute(entry3, MODIFICATION_TIME);
expect(success, isFalse);
expect(entry3.getState(MODIFICATION_TIME), CacheState.INVALID);
}

test_compute_SOURCE_KIND_librarySource() {
Expand Down

0 comments on commit a730f03

Please sign in to comment.