| 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/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 2397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2408 expectedKind: ReferenceKind.propertyAccessor, | 2408 expectedKind: ReferenceKind.propertyAccessor, |
| 2409 prefixExpectations: [ | 2409 prefixExpectations: [ |
| 2410 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2410 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2411 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2411 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
| 2412 new _PrefixExpectation(ReferenceKind.prefix, 'p', | 2412 new _PrefixExpectation(ReferenceKind.prefix, 'p', |
| 2413 inLibraryDefiningUnit: true), | 2413 inLibraryDefiningUnit: true), |
| 2414 ]) | 2414 ]) |
| 2415 ]); | 2415 ]); |
| 2416 } | 2416 } |
| 2417 | 2417 |
| 2418 test_constExpr_pushReference_field_simpleIdentifier() { |
| 2419 UnlinkedVariable variable = serializeClassText(''' |
| 2420 class C { |
| 2421 static const a = b; |
| 2422 static const b = null; |
| 2423 } |
| 2424 ''').fields[0]; |
| 2425 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2426 UnlinkedConstOperation.pushReference |
| 2427 ], referenceValidators: [ |
| 2428 (EntityRef r) => checkTypeRef(r, null, null, 'b', |
| 2429 expectedKind: ReferenceKind.propertyAccessor, |
| 2430 prefixExpectations: [ |
| 2431 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2432 ]) |
| 2433 ]); |
| 2434 } |
| 2435 |
| 2418 test_constExpr_pushReference_staticMethod() { | 2436 test_constExpr_pushReference_staticMethod() { |
| 2419 UnlinkedVariable variable = serializeVariableText(''' | 2437 UnlinkedVariable variable = serializeVariableText(''' |
| 2420 class C { | 2438 class C { |
| 2421 static m() {} | 2439 static m() {} |
| 2422 } | 2440 } |
| 2423 const v = C.m; | 2441 const v = C.m; |
| 2424 '''); | 2442 '''); |
| 2425 _assertUnlinkedConst(variable.constExpr, operators: [ | 2443 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2426 UnlinkedConstOperation.pushReference | 2444 UnlinkedConstOperation.pushReference |
| 2427 ], referenceValidators: [ | 2445 ], referenceValidators: [ |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 expectedKind: ReferenceKind.method, | 2494 expectedKind: ReferenceKind.method, |
| 2477 prefixExpectations: [ | 2495 prefixExpectations: [ |
| 2478 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 2496 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2479 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 2497 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
| 2480 new _PrefixExpectation(ReferenceKind.prefix, 'p', | 2498 new _PrefixExpectation(ReferenceKind.prefix, 'p', |
| 2481 inLibraryDefiningUnit: true) | 2499 inLibraryDefiningUnit: true) |
| 2482 ]) | 2500 ]) |
| 2483 ]); | 2501 ]); |
| 2484 } | 2502 } |
| 2485 | 2503 |
| 2504 test_constExpr_pushReference_staticMethod_simpleIdentifier() { |
| 2505 UnlinkedVariable variable = serializeClassText(''' |
| 2506 class C { |
| 2507 static const a = m; |
| 2508 static m() {} |
| 2509 } |
| 2510 ''').fields[0]; |
| 2511 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2512 UnlinkedConstOperation.pushReference |
| 2513 ], referenceValidators: [ |
| 2514 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
| 2515 expectedKind: ReferenceKind.method, |
| 2516 prefixExpectations: [ |
| 2517 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2518 ]) |
| 2519 ]); |
| 2520 } |
| 2521 |
| 2486 test_constExpr_pushReference_topLevelFunction() { | 2522 test_constExpr_pushReference_topLevelFunction() { |
| 2487 UnlinkedVariable variable = serializeVariableText(''' | 2523 UnlinkedVariable variable = serializeVariableText(''' |
| 2488 f() {} | 2524 f() {} |
| 2489 const v = f; | 2525 const v = f; |
| 2490 '''); | 2526 '''); |
| 2491 _assertUnlinkedConst(variable.constExpr, operators: [ | 2527 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2492 UnlinkedConstOperation.pushReference | 2528 UnlinkedConstOperation.pushReference |
| 2493 ], referenceValidators: [ | 2529 ], referenceValidators: [ |
| 2494 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 2530 (EntityRef r) => checkTypeRef(r, null, null, 'f', |
| 2495 expectedKind: ReferenceKind.topLevelFunction) | 2531 expectedKind: ReferenceKind.topLevelFunction) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2573 UnlinkedConstOperation.pushReference | 2609 UnlinkedConstOperation.pushReference |
| 2574 ], referenceValidators: [ | 2610 ], referenceValidators: [ |
| 2575 (EntityRef r) { | 2611 (EntityRef r) { |
| 2576 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 2612 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', |
| 2577 expectedKind: ReferenceKind.topLevelPropertyAccessor, | 2613 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
| 2578 expectedPrefix: 'p'); | 2614 expectedPrefix: 'p'); |
| 2579 } | 2615 } |
| 2580 ]); | 2616 ]); |
| 2581 } | 2617 } |
| 2582 | 2618 |
| 2619 test_constExpr_pushReference_typeParameter() { |
| 2620 String text = ''' |
| 2621 class C<T> { |
| 2622 static const a = T; |
| 2623 } |
| 2624 '''; |
| 2625 UnlinkedVariable variable = serializeClassText( |
| 2626 text, |
| 2627 allowErrors: true) |
| 2628 .fields[0]; |
| 2629 _assertUnlinkedConst(variable.constExpr, isInvalid: true); |
| 2630 } |
| 2631 |
| 2583 test_constExpr_pushString_adjacent() { | 2632 test_constExpr_pushString_adjacent() { |
| 2584 UnlinkedVariable variable = | 2633 UnlinkedVariable variable = |
| 2585 serializeVariableText('const v = "aaa" "b" "ccc";'); | 2634 serializeVariableText('const v = "aaa" "b" "ccc";'); |
| 2586 _assertUnlinkedConst(variable.constExpr, | 2635 _assertUnlinkedConst(variable.constExpr, |
| 2587 operators: [UnlinkedConstOperation.pushString], strings: ['aaabccc']); | 2636 operators: [UnlinkedConstOperation.pushString], strings: ['aaabccc']); |
| 2588 } | 2637 } |
| 2589 | 2638 |
| 2590 test_constExpr_pushString_adjacent_interpolation() { | 2639 test_constExpr_pushString_adjacent_interpolation() { |
| 2591 UnlinkedVariable variable = | 2640 UnlinkedVariable variable = |
| 2592 serializeVariableText(r'const v = "aaa" "bb ${42} bbb" "cccc";'); | 2641 serializeVariableText(r'const v = "aaa" "bb ${42} bbb" "cccc";'); |
| (...skipping 3313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5906 final String absoluteUri; | 5955 final String absoluteUri; |
| 5907 final String relativeUri; | 5956 final String relativeUri; |
| 5908 final int numTypeParameters; | 5957 final int numTypeParameters; |
| 5909 | 5958 |
| 5910 _PrefixExpectation(this.kind, this.name, | 5959 _PrefixExpectation(this.kind, this.name, |
| 5911 {this.inLibraryDefiningUnit: false, | 5960 {this.inLibraryDefiningUnit: false, |
| 5912 this.absoluteUri, | 5961 this.absoluteUri, |
| 5913 this.relativeUri, | 5962 this.relativeUri, |
| 5914 this.numTypeParameters: 0}); | 5963 this.numTypeParameters: 0}); |
| 5915 } | 5964 } |
| OLD | NEW |