| 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.test.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/error/listener.dart'; | 9 import 'package:analyzer/error/listener.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 * explicit reference. If the type reference in question is an implicit | 482 * explicit reference. If the type reference in question is an implicit |
| 483 * reference, return `null`. | 483 * reference, return `null`. |
| 484 */ | 484 */ |
| 485 UnlinkedReference checkReferenceIndex( | 485 UnlinkedReference checkReferenceIndex( |
| 486 int referenceIndex, String absoluteUri, String expectedName, | 486 int referenceIndex, String absoluteUri, String expectedName, |
| 487 {ReferenceKind expectedKind: ReferenceKind.classOrEnum, | 487 {ReferenceKind expectedKind: ReferenceKind.classOrEnum, |
| 488 int expectedTargetUnit: 0, | 488 int expectedTargetUnit: 0, |
| 489 LinkedUnit linkedSourceUnit, | 489 LinkedUnit linkedSourceUnit, |
| 490 UnlinkedUnit unlinkedSourceUnit, | 490 UnlinkedUnit unlinkedSourceUnit, |
| 491 int numTypeParameters: 0, | 491 int numTypeParameters: 0, |
| 492 int localIndex: 0, | |
| 493 bool unresolvedHasName: false}) { | 492 bool unresolvedHasName: false}) { |
| 494 linkedSourceUnit ??= definingUnit; | 493 linkedSourceUnit ??= definingUnit; |
| 495 unlinkedSourceUnit ??= unlinkedUnits[0]; | 494 unlinkedSourceUnit ??= unlinkedUnits[0]; |
| 496 LinkedReference referenceResolution = | 495 LinkedReference referenceResolution = |
| 497 linkedSourceUnit.references[referenceIndex]; | 496 linkedSourceUnit.references[referenceIndex]; |
| 498 String name; | 497 String name; |
| 499 UnlinkedReference reference; | 498 UnlinkedReference reference; |
| 500 if (referenceIndex < unlinkedSourceUnit.references.length) { | 499 if (referenceIndex < unlinkedSourceUnit.references.length) { |
| 501 // This is an explicit reference, so its name and prefix should be in | 500 // This is an explicit reference, so its name and prefix should be in |
| 502 // [UnlinkedUnit.references]. | 501 // [UnlinkedUnit.references]. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 521 checkDependency(referenceResolution.dependency, absoluteUri); | 520 checkDependency(referenceResolution.dependency, absoluteUri); |
| 522 } | 521 } |
| 523 if (expectedName == null) { | 522 if (expectedName == null) { |
| 524 expect(name, isEmpty); | 523 expect(name, isEmpty); |
| 525 } else { | 524 } else { |
| 526 expect(name, expectedName); | 525 expect(name, expectedName); |
| 527 } | 526 } |
| 528 expect(referenceResolution.kind, expectedKind); | 527 expect(referenceResolution.kind, expectedKind); |
| 529 expect(referenceResolution.unit, expectedTargetUnit); | 528 expect(referenceResolution.unit, expectedTargetUnit); |
| 530 expect(referenceResolution.numTypeParameters, numTypeParameters); | 529 expect(referenceResolution.numTypeParameters, numTypeParameters); |
| 531 expect(referenceResolution.localIndex, localIndex); | |
| 532 return reference; | 530 return reference; |
| 533 } | 531 } |
| 534 | 532 |
| 535 /** | 533 /** |
| 536 * Verify that the given [typeRef] represents a reference to a type declared | 534 * Verify that the given [typeRef] represents a reference to a type declared |
| 537 * in a file reachable via [absoluteUri], having name [expectedName]. | 535 * in a file reachable via [absoluteUri], having name [expectedName]. |
| 538 * If [expectedPrefix] is supplied, verify that the type is reached via the | 536 * If [expectedPrefix] is supplied, verify that the type is reached via the |
| 539 * given prefix. Verify that the number of type arguments is equal to | 537 * given prefix. Verify that the number of type arguments is equal to |
| 540 * [numTypeArguments]. [expectedKind] is the kind of object referenced. | 538 * [numTypeArguments]. [expectedKind] is the kind of object referenced. |
| 541 * [linkedSourceUnit] and [unlinkedSourceUnit] refer to the compilation unit | 539 * [linkedSourceUnit] and [unlinkedSourceUnit] refer to the compilation unit |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 } | 1563 } |
| 1566 '''); | 1564 '''); |
| 1567 expect(executable.localFunctions, hasLength(2)); | 1565 expect(executable.localFunctions, hasLength(2)); |
| 1568 EntityRef closureType = | 1566 EntityRef closureType = |
| 1569 getTypeRefForSlot(executable.localFunctions[1].inferredReturnTypeSlot); | 1567 getTypeRefForSlot(executable.localFunctions[1].inferredReturnTypeSlot); |
| 1570 checkLinkedTypeRef(closureType, null, '', | 1568 checkLinkedTypeRef(closureType, null, '', |
| 1571 expectedKind: ReferenceKind.function); | 1569 expectedKind: ReferenceKind.function); |
| 1572 int outerClosureIndex = | 1570 int outerClosureIndex = |
| 1573 definingUnit.references[closureType.reference].containingReference; | 1571 definingUnit.references[closureType.reference].containingReference; |
| 1574 checkReferenceIndex(outerClosureIndex, null, '', | 1572 checkReferenceIndex(outerClosureIndex, null, '', |
| 1575 expectedKind: ReferenceKind.function, localIndex: 1); | 1573 expectedKind: ReferenceKind.function); |
| 1576 int topLevelFunctionIndex = | 1574 int topLevelFunctionIndex = |
| 1577 definingUnit.references[outerClosureIndex].containingReference; | 1575 definingUnit.references[outerClosureIndex].containingReference; |
| 1578 checkReferenceIndex(topLevelFunctionIndex, null, 'f', | 1576 checkReferenceIndex(topLevelFunctionIndex, null, 'f', |
| 1579 expectedKind: ReferenceKind.topLevelFunction); | 1577 expectedKind: ReferenceKind.topLevelFunction); |
| 1580 expect( | 1578 expect( |
| 1581 definingUnit.references[topLevelFunctionIndex].containingReference, 0); | 1579 definingUnit.references[topLevelFunctionIndex].containingReference, 0); |
| 1582 } | 1580 } |
| 1583 | 1581 |
| 1584 test_closure_executable_with_unimported_return_type() { | 1582 test_closure_executable_with_unimported_return_type() { |
| 1585 addNamedSource('/a.dart', 'import "b.dart"; class C { D d; }'); | 1583 addNamedSource('/a.dart', 'import "b.dart"; class C { D d; }'); |
| (...skipping 7674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9260 // Element zero of the references table should be populated in a standard | 9258 // Element zero of the references table should be populated in a standard |
| 9261 // way. | 9259 // way. |
| 9262 serializeLibraryText(''); | 9260 serializeLibraryText(''); |
| 9263 UnlinkedReference unlinkedReference0 = unlinkedUnits[0].references[0]; | 9261 UnlinkedReference unlinkedReference0 = unlinkedUnits[0].references[0]; |
| 9264 expect(unlinkedReference0.name, ''); | 9262 expect(unlinkedReference0.name, ''); |
| 9265 expect(unlinkedReference0.prefixReference, 0); | 9263 expect(unlinkedReference0.prefixReference, 0); |
| 9266 LinkedReference linkedReference0 = linked.units[0].references[0]; | 9264 LinkedReference linkedReference0 = linked.units[0].references[0]; |
| 9267 expect(linkedReference0.containingReference, 0); | 9265 expect(linkedReference0.containingReference, 0); |
| 9268 expect(linkedReference0.dependency, 0); | 9266 expect(linkedReference0.dependency, 0); |
| 9269 expect(linkedReference0.kind, ReferenceKind.unresolved); | 9267 expect(linkedReference0.kind, ReferenceKind.unresolved); |
| 9270 expect(linkedReference0.localIndex, 0); | |
| 9271 expect(linkedReference0.name, ''); | 9268 expect(linkedReference0.name, ''); |
| 9272 expect(linkedReference0.numTypeParameters, 0); | 9269 expect(linkedReference0.numTypeParameters, 0); |
| 9273 expect(linkedReference0.unit, 0); | 9270 expect(linkedReference0.unit, 0); |
| 9274 } | 9271 } |
| 9275 | 9272 |
| 9276 test_setter_documented() { | 9273 test_setter_documented() { |
| 9277 if (!includeInformative) return; | 9274 if (!includeInformative) return; |
| 9278 String text = ''' | 9275 String text = ''' |
| 9279 // Extra comment so doc comment offset != 0 | 9276 // Extra comment so doc comment offset != 0 |
| 9280 /** | 9277 /** |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10299 */ | 10296 */ |
| 10300 class _PrefixExpectation { | 10297 class _PrefixExpectation { |
| 10301 final ReferenceKind kind; | 10298 final ReferenceKind kind; |
| 10302 final String name; | 10299 final String name; |
| 10303 final String absoluteUri; | 10300 final String absoluteUri; |
| 10304 final int numTypeParameters; | 10301 final int numTypeParameters; |
| 10305 | 10302 |
| 10306 _PrefixExpectation(this.kind, this.name, | 10303 _PrefixExpectation(this.kind, this.name, |
| 10307 {this.absoluteUri, this.numTypeParameters: 0}); | 10304 {this.absoluteUri, this.numTypeParameters: 0}); |
| 10308 } | 10305 } |
| OLD | NEW |