| Index: pkg/analyzer/test/generated/incremental_resolver_test.dart
|
| diff --git a/pkg/analyzer/test/generated/incremental_resolver_test.dart b/pkg/analyzer/test/generated/incremental_resolver_test.dart
|
| index 9e3b75a65013757cc44002b02d2e924e3edfccfc..be14808d876090caea6e4e61128948a8fad7fab8 100644
|
| --- a/pkg/analyzer/test/generated/incremental_resolver_test.dart
|
| +++ b/pkg/analyzer/test/generated/incremental_resolver_test.dart
|
| @@ -3611,13 +3611,15 @@ main() {
|
| print(x + 1);
|
| }
|
| ''');
|
| - _updateAndValidate(r'''
|
| + _updateAndValidate(
|
| + r'''
|
| int f() => 0;
|
| main() {
|
| const x = f();
|
| print(x + 2);
|
| }
|
| -''');
|
| +''',
|
| + expectCachePostConstantsValid: false);
|
| }
|
|
|
| void test_dartDoc_beforeField() {
|
| @@ -4206,6 +4208,21 @@ main() {
|
| ''');
|
| }
|
|
|
| + void test_hasElementAfter_defaultParameter() {
|
| + _resolveUnit(r'''
|
| +main() {
|
| + print(1);
|
| +}
|
| +otherFunction([p = 0]) {}
|
| +''');
|
| + _updateAndValidate(r'''
|
| +main() {
|
| + print(2);
|
| +}
|
| +otherFunction([p = 0]) {}
|
| +''');
|
| + }
|
| +
|
| void test_inBody_expression() {
|
| _resolveUnit(r'''
|
| class A {
|
| @@ -4550,11 +4567,13 @@ main() {
|
| const v = const [Unknown];
|
| }
|
| ''');
|
| - _updateAndValidate(r'''
|
| + _updateAndValidate(
|
| + r'''
|
| main() {
|
| const v = const [Unknown];
|
| }
|
| -''');
|
| +''',
|
| + expectCachePostConstantsValid: false);
|
| }
|
|
|
| void test_updateErrors_addNew_hint1() {
|
| @@ -4828,6 +4847,55 @@ class B extends A {}
|
| }
|
| }
|
|
|
| + void _assertCacheResults({bool expectCachePostConstantsValid: true}) {
|
| + _assertCacheSourceResult(PARSED_UNIT);
|
| + _assertCacheSourceResult(PARSE_ERRORS);
|
| + _assertCacheSourceResult(LIBRARY_ELEMENT1);
|
| + _assertCacheSourceResult(LIBRARY_ELEMENT2);
|
| + _assertCacheSourceResult(LIBRARY_ELEMENT3);
|
| + _assertCacheSourceResult(LIBRARY_ELEMENT4);
|
| + _assertCacheSourceResult(LIBRARY_ELEMENT5);
|
| + _assertCacheSourceResult(LIBRARY_ELEMENT6);
|
| + _assertCacheSourceResult(LIBRARY_ELEMENT7);
|
| + _assertCacheSourceResult(LIBRARY_ELEMENT8);
|
| + if (expectCachePostConstantsValid) {
|
| + _assertCacheSourceResult(LIBRARY_ELEMENT);
|
| + }
|
| + _assertCacheUnitResult(RESOLVED_UNIT1);
|
| + _assertCacheUnitResult(RESOLVED_UNIT2);
|
| + _assertCacheUnitResult(RESOLVED_UNIT3);
|
| + _assertCacheUnitResult(RESOLVED_UNIT4);
|
| + _assertCacheUnitResult(RESOLVED_UNIT5);
|
| + _assertCacheUnitResult(RESOLVED_UNIT6);
|
| + _assertCacheUnitResult(RESOLVED_UNIT7);
|
| + _assertCacheUnitResult(RESOLVED_UNIT8);
|
| + _assertCacheUnitResult(RESOLVED_UNIT9);
|
| + _assertCacheUnitResult(RESOLVED_UNIT10);
|
| + if (expectCachePostConstantsValid) {
|
| + _assertCacheUnitResult(RESOLVED_UNIT11);
|
| + _assertCacheUnitResult(RESOLVED_UNIT);
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * Assert that the [result] of [source] is not INVALID.
|
| + */
|
| + void _assertCacheSourceResult(ResultDescriptor result) {
|
| + AnalysisCache cache = analysisContext2.analysisCache;
|
| + CacheState state = cache.getState(source, result);
|
| + expect(state, isNot(CacheState.INVALID), reason: result.toString());
|
| + }
|
| +
|
| + /**
|
| + * Assert that the [result] of the defining unit [source] is not INVALID.
|
| + */
|
| + void _assertCacheUnitResult(ResultDescriptor result) {
|
| + AnalysisCache cache = analysisContext2.analysisCache;
|
| + LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
|
| + CacheState state = cache.getState(target, result);
|
| + expect(state, isNot(CacheState.INVALID), reason: result.toString());
|
| + }
|
| +
|
| void _assertEqualLineInfo(LineInfo incrLineInfo, LineInfo fullLineInfo) {
|
| for (int offset = 0; offset < 1000; offset++) {
|
| LineInfo_Location incrLocation = incrLineInfo.getLocation(offset);
|
| @@ -4871,6 +4939,7 @@ class B extends A {}
|
|
|
| void _updateAndValidate(String newCode,
|
| {bool expectedSuccess: true,
|
| + bool expectCachePostConstantsValid: true,
|
| bool compareWithFull: true,
|
| bool runTasksBeforeIncremental: true}) {
|
| // Run any pending tasks tasks.
|
| @@ -4890,6 +4959,10 @@ class B extends A {}
|
| expect(newUnit.element, isNot(same(oldUnitElement)));
|
| return;
|
| }
|
| + // The cache must still have enough results to make the incremental
|
| + // resolution useful.
|
| + _assertCacheResults(
|
| + expectCachePostConstantsValid: expectCachePostConstantsValid);
|
| // The existing CompilationUnit[Element] should be updated.
|
| expect(newUnit, same(oldUnit));
|
| expect(newUnit.element, same(oldUnitElement));
|
|
|