Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: tests/compiler/dart2js/semantic_visitor_test.dart

Issue 1047673002: Add SemanticDeclVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More renaming Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/use_unused_api.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 dart2js.semantics_visitor_test; 5 library dart2js.semantics_visitor_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import 'package:compiler/src/constants/expressions.dart'; 10 import 'package:compiler/src/constants/expressions.dart';
(...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 ''', 2252 ''',
2253 const Visit( 2253 const Visit(
2254 VisitKind.ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE, 2254 VisitKind.ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
2255 element: 'function(Class#)', 2255 element: 'function(Class#)',
2256 arguments: '(true,42)', 2256 arguments: '(true,42)',
2257 type: 'Class', 2257 type: 'Class',
2258 selector: 'Selector(call, , arity=2)')), 2258 selector: 'Selector(call, , arity=2)')),
2259 ], 2259 ],
2260 }; 2260 };
2261 2261
2262 const Map<String, List<Test>> DECL_TESTS = const {
2263 'Function declarations': const [
2264 const Test(
2265 '''
2266 m(a, b) {}
2267 ''',
2268 const [
2269 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2270 element: 'function(m)',
2271 parameters: '(a,b)',
2272 body: '{}'),
2273 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2274 element: 'parameter(m#a)',
2275 index: 0),
2276 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2277 element: 'parameter(m#b)',
2278 index: 1),
2279 ]),
2280 const Test(
2281 '''
2282 m(a, [b]) {}
2283 ''',
2284 const [
2285 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2286 element: 'function(m)',
2287 parameters: '(a,[b])',
2288 body: '{}'),
2289 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2290 element: 'parameter(m#a)',
2291 index: 0),
2292 const Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
2293 element: 'parameter(m#b)',
2294 index: 1),
2295 ]),
2296 const Test(
2297 '''
2298 m(a, [b = null]) {}
2299 ''',
2300 const [
2301 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2302 element: 'function(m)',
2303 parameters: '(a,[b=null])',
2304 body: '{}'),
2305 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2306 element: 'parameter(m#a)',
2307 index: 0),
2308 const Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
2309 element: 'parameter(m#b)',
2310 constant: 'null',
2311 index: 1),
2312 ]),
2313 const Test(
2314 '''
2315 m(a, [b = 42]) {}
2316 ''',
2317 const [
2318 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2319 element: 'function(m)',
2320 parameters: '(a,[b=42])',
2321 body: '{}'),
2322 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2323 element: 'parameter(m#a)',
2324 index: 0),
2325 const Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
2326 element: 'parameter(m#b)',
2327 constant: 42,
2328 index: 1),
2329 ]),
2330 const Test(
2331 '''
2332 m(a, {b}) {}
2333 ''',
2334 const [
2335 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2336 element: 'function(m)',
2337 parameters: '(a,{b})',
2338 body: '{}'),
2339 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2340 element: 'parameter(m#a)',
2341 index: 0),
2342 const Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
2343 element: 'parameter(m#b)'),
2344 ]),
2345 const Test(
2346 '''
2347 m(a, {b: null}) {}
2348 ''',
2349 const [
2350 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2351 element: 'function(m)',
2352 parameters: '(a,{b: null})',
2353 body: '{}'),
2354 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2355 element: 'parameter(m#a)',
2356 index: 0),
2357 const Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
2358 element: 'parameter(m#b)',
2359 constant: 'null'),
2360 ]),
2361 const Test(
2362 '''
2363 m(a, {b:42}) {}
2364 ''',
2365 const [
2366 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2367 element: 'function(m)',
2368 parameters: '(a,{b: 42})',
2369 body: '{}'),
2370 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2371 element: 'parameter(m#a)',
2372 index: 0),
2373 const Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
2374 element: 'parameter(m#b)',
2375 constant: 42),
2376 ]),
2377 const Test(
2378 '''
2379 get m => null;
2380 ''',
2381 const [
2382 const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_DECL,
2383 element: 'getter(m)',
2384 body: '=>null;'),
2385 ]),
2386 const Test(
2387 '''
2388 set m(a) {}
2389 ''',
2390 const [
2391 const Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_DECL,
2392 element: 'setter(m)',
2393 parameters: '(a)',
2394 body: '{}'),
2395 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2396 element: 'parameter(m#a)',
2397 index: 0),
2398 ]),
2399 const Test.clazz(
2400 '''
2401 class C {
2402 static m(a, b) {}
2403 }
2404 ''',
2405 const [
2406 const Visit(VisitKind.VISIT_STATIC_FUNCTION_DECL,
2407 element: 'function(C#m)',
2408 parameters: '(a,b)',
2409 body: '{}'),
2410 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2411 element: 'parameter(m#a)',
2412 index: 0),
2413 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2414 element: 'parameter(m#b)',
2415 index: 1),
2416 ]),
2417 const Test.clazz(
2418 '''
2419 class C {
2420 static get m => null;
2421 }
2422 ''',
2423 const [
2424 const Visit(VisitKind.VISIT_STATIC_GETTER_DECL,
2425 element: 'getter(C#m)',
2426 body: '=>null;'),
2427 ]),
2428 const Test.clazz(
2429 '''
2430 class C {
2431 static set m(a) {}
2432 }
2433 ''',
2434 const [
2435 const Visit(VisitKind.VISIT_STATIC_SETTER_DECL,
2436 element: 'setter(C#m)',
2437 parameters: '(a)',
2438 body: '{}'),
2439 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2440 element: 'parameter(m#a)',
2441 index: 0),
2442 ]),
2443 const Test.clazz(
2444 '''
2445 class C {
2446 m(a, b) {}
2447 }
2448 ''',
2449 const [
2450 const Visit(VisitKind.VISIT_INSTANCE_METHOD_DECL,
2451 element: 'function(C#m)',
2452 parameters: '(a,b)',
2453 body: '{}'),
2454 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2455 element: 'parameter(m#a)',
2456 index: 0),
2457 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2458 element: 'parameter(m#b)',
2459 index: 1),
2460 ]),
2461 const Test.clazz(
2462 '''
2463 class C {
2464 get m => null;
2465 }
2466 ''',
2467 const [
2468 const Visit(VisitKind.VISIT_INSTANCE_GETTER_DECL,
2469 element: 'getter(C#m)',
2470 body: '=>null;'),
2471 ]),
2472 const Test.clazz(
2473 '''
2474 class C {
2475 set m(a) {}
2476 }
2477 ''',
2478 const [
2479 const Visit(VisitKind.VISIT_INSTANCE_SETTER_DECL,
2480 element: 'setter(C#m)',
2481 parameters: '(a)',
2482 body: '{}'),
2483 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2484 element: 'parameter(m#a)',
2485 index: 0),
2486 ]),
2487 const Test.clazz(
2488 '''
2489 abstract class C {
2490 m(a, b);
2491 }
2492 ''',
2493 const [
2494 const Visit(VisitKind.VISIT_ABSTRACT_METHOD_DECL,
2495 element: 'function(C#m)',
2496 parameters: '(a,b)'),
2497 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2498 element: 'parameter(m#a)',
2499 index: 0),
2500 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2501 element: 'parameter(m#b)',
2502 index: 1),
2503 ]),
2504 const Test.clazz(
2505 '''
2506 abstract class C {
2507 get m;
2508 }
2509 ''',
2510 const [
2511 const Visit(VisitKind.VISIT_ABSTRACT_GETTER_DECL,
2512 element: 'getter(C#m)'),
2513 ]),
2514 const Test.clazz(
2515 '''
2516 abstract class C {
2517 set m(a);
2518 }
2519 ''',
2520 const [
2521 const Visit(VisitKind.VISIT_ABSTRACT_SETTER_DECL,
2522 element: 'setter(C#m)',
2523 parameters: '(a)'),
2524 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2525 element: 'parameter(m#a)',
2526 index: 0),
2527 ]),
2528 const Test(
2529 '''
2530 m(a, b) {}
2531 ''',
2532 const [
2533 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2534 element: 'function(m)',
2535 parameters: '(a,b)',
2536 body: '{}'),
2537 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2538 element: 'parameter(m#a)',
2539 index: 0),
2540 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2541 element: 'parameter(m#b)',
2542 index: 1),
2543 ]),
2544 const Test(
2545 '''
2546 m() {
2547 local(a, b) {}
2548 }
2549 ''',
2550 const [
2551 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2552 element: 'function(m)',
2553 parameters: '()',
2554 body: '{local(a,b){}}'),
2555 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_DECL,
2556 element: 'function(m#local)',
2557 parameters: '(a,b)',
2558 body: '{}'),
2559 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2560 element: 'parameter(local#a)',
2561 index: 0),
2562 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2563 element: 'parameter(local#b)',
2564 index: 1),
2565 ]),
2566 const Test(
2567 '''
2568 m() => (a, b) {};
2569 ''',
2570 const [
2571 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2572 element: 'function(m)',
2573 parameters: '()',
2574 body: '=>(a,b){};'),
2575 const Visit(VisitKind.VISIT_CLOSURE_DECL,
2576 element: 'function(m#)',
2577 parameters: '(a,b)',
2578 body: '{}'),
2579 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2580 element: 'parameter(#a)',
2581 index: 0),
2582 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2583 element: 'parameter(#b)',
2584 index: 1),
2585 ]),
2586 ],
2587 'Constructor declarations': const [
2588 const Test.clazz(
2589 '''
2590 class C {
2591 C(a, b);
2592 }
2593 ''',
2594 const [
2595 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2596 element: 'generative_constructor(C#)',
2597 parameters: '(a,b)',
2598 body: ';'),
2599 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2600 element: 'parameter(#a)',
2601 index: 0),
2602 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2603 element: 'parameter(#b)',
2604 index: 1),
2605 ],
2606 method: ''),
2607 const Test.clazz(
2608 '''
2609 class C {
2610 var b;
2611 C(a, this.b);
2612 }
2613 ''',
2614 const [
2615 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2616 element: 'generative_constructor(C#)',
2617 parameters: '(a,this.b)',
2618 body: ';'),
2619 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2620 element: 'parameter(#a)',
2621 index: 0),
2622 const Visit(VisitKind.VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
2623 element: 'initializing_formal(#b)',
2624 index: 1),
2625 ],
2626 method: ''),
2627 const Test.clazz(
2628 '''
2629 class C {
2630 var b;
2631 C(a, [this.b = 42]);
2632 }
2633 ''',
2634 const [
2635 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2636 element: 'generative_constructor(C#)',
2637 parameters: '(a,[this.b=42])',
2638 body: ';'),
2639 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2640 element: 'parameter(#a)',
2641 index: 0),
2642 const Visit(VisitKind.VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
2643 element: 'initializing_formal(#b)',
2644 constant: 42,
2645 index: 1),
2646 ],
2647 method: ''),
2648 const Test.clazz(
2649 '''
2650 class C {
2651 var b;
2652 C(a, {this.b: 42});
2653 }
2654 ''',
2655 const [
2656 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2657 element: 'generative_constructor(C#)',
2658 parameters: '(a,{this.b: 42})',
2659 body: ';'),
2660 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2661 element: 'parameter(#a)',
2662 index: 0),
2663 const Visit(VisitKind.VISIT_NAMED_INITIALIZING_FORMAL_DECL,
2664 element: 'initializing_formal(#b)',
2665 constant: 42),
2666 ],
2667 method: ''),
2668 const Test.clazz(
2669 '''
2670 class C {
2671 C(a, b) : super();
2672 }
2673 ''',
2674 const [
2675 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2676 element: 'generative_constructor(C#)',
2677 parameters: '(a,b)',
2678 body: ';'),
2679 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2680 element: 'parameter(#a)',
2681 index: 0),
2682 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2683 element: 'parameter(#b)',
2684 index: 1),
2685 const Visit(VisitKind.VISIT_SUPER_CONSTRUCTOR_INVOKE,
2686 element: 'generative_constructor(Object#)',
2687 type: 'Object',
2688 arguments: '()',
2689 selector: 'Selector(call, super, arity=0)'),
2690 ],
2691 method: ''),
2692 const Test.clazz(
2693 '''
2694 class C {
2695 var field;
2696 C(a, b) : this.field = a;
2697 }
2698 ''',
2699 const [
2700 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2701 element: 'generative_constructor(C#)',
2702 parameters: '(a,b)',
2703 body: ';'),
2704 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2705 element: 'parameter(#a)',
2706 index: 0),
2707 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2708 element: 'parameter(#b)',
2709 index: 1),
2710 const Visit(VisitKind.VISIT_FIELD_INITIALIZER,
2711 element: 'field(C#field)',
2712 rhs: 'a'),
2713 ],
2714 method: ''),
2715 const Test.clazz(
2716 '''
2717 class C {
2718 C(a, b) : this._(a, b);
2719 C._(a, b);
2720 }
2721 ''',
2722 const [
2723 const Visit(VisitKind.VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_DECL,
2724 element: 'generative_constructor(C#)',
2725 parameters: '(a,b)',
2726 initializers: ':this._(a,b)'),
2727 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2728 element: 'parameter(#a)',
2729 index: 0),
2730 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2731 element: 'parameter(#b)',
2732 index: 1),
2733 const Visit(VisitKind.VISIT_THIS_CONSTRUCTOR_INVOKE,
2734 element: 'generative_constructor(C#_)',
2735 arguments: '(a,b)',
2736 selector: 'Selector(call, _, arity=2)'),
2737 ],
2738 method: ''),
2739 const Test.clazz(
2740 '''
2741 class C {
2742 factory C(a, b) => null;
2743 }
2744 ''',
2745 const [
2746 const Visit(VisitKind.VISIT_FACTORY_CONSTRUCTOR_DECL,
2747 element: 'function(C#)',
2748 parameters: '(a,b)',
2749 body: '=>null;'),
2750 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2751 element: 'parameter(#a)',
2752 index: 0),
2753 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2754 element: 'parameter(#b)',
2755 index: 1),
2756 ],
2757 method: ''),
2758 const Test.clazz(
2759 '''
2760 class C {
2761 factory C(a, b) = C._;
2762 C._(a, b);
2763 }
2764 ''',
2765 const [
2766 const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
2767 element: 'function(C#)',
2768 parameters: '(a,b)',
2769 target: 'generative_constructor(C#_)',
2770 type: 'C'),
2771 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2772 element: 'parameter(#a)',
2773 index: 0),
2774 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2775 element: 'parameter(#b)',
2776 index: 1),
2777 ],
2778 method: ''),
2779 const Test.clazz(
2780 '''
2781 class C {
2782 factory C(a, b) = D;
2783 }
2784 class D<T> {
2785 D(a, b);
2786 }
2787 ''',
2788 const [
2789 const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
2790 element: 'function(C#)',
2791 parameters: '(a,b)',
2792 target: 'generative_constructor(D#)',
2793 type: 'D'),
2794 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2795 element: 'parameter(#a)',
2796 index: 0),
2797 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2798 element: 'parameter(#b)',
2799 index: 1),
2800 ],
2801 method: ''),
2802 const Test.clazz(
2803 '''
2804 class C {
2805 factory C(a, b) = D<int>;
2806 }
2807 class D<T> {
2808 D(a, b);
2809 }
2810 ''',
2811 const [
2812 const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
2813 element: 'function(C#)',
2814 parameters: '(a,b)',
2815 target: 'generative_constructor(D#)',
2816 type: 'D<int>'),
2817 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2818 element: 'parameter(#a)',
2819 index: 0),
2820 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2821 element: 'parameter(#b)',
2822 index: 1),
2823 ],
2824 method: ''),
2825 const Test.clazz(
2826 '''
2827 class C {
2828 factory C(a, b) = D<int>;
2829 }
2830 class D<T> {
2831 factory D(a, b) = E<D<T>>;
2832 }
2833 class E<S> {
2834 E(a, b);
2835 }
2836 ''',
2837 const [
2838 const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
2839 element: 'function(C#)',
2840 parameters: '(a,b)',
2841 target: 'function(D#)',
2842 type: 'D<int>'),
2843 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2844 element: 'parameter(#a)',
2845 index: 0),
2846 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2847 element: 'parameter(#b)',
2848 index: 1),
2849 ],
2850 method: ''),
2851 ],
2852 "Field declarations": const [
2853 const Test.clazz(
2854 '''
2855 class C {
2856 var m;
2857 }
2858 ''',
2859 const [
2860 const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
2861 element: 'field(C#m)'),
2862 ]),
2863 const Test.clazz(
2864 '''
2865 class C {
2866 var m, n;
2867 }
2868 ''',
2869 const [
2870 const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
2871 element: 'field(C#m)'),
2872 ]),
2873 const Test.clazz(
2874 '''
2875 class C {
2876 var m = 42;
2877 }
2878 ''',
2879 const [
2880 const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
2881 element: 'field(C#m)',
2882 rhs: 42),
2883 ]),
2884 const Test(
2885 '''
2886 m() {
2887 var local;
2888 }
2889 ''',
2890 const [
2891 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2892 element: 'function(m)',
2893 parameters: '()',
2894 body: '{var local;}'),
2895 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2896 element: 'variable(m#local)'),
2897 ]),
2898 const Test(
2899 '''
2900 m() {
2901 var local = 42;
2902 }
2903 ''',
2904 const [
2905 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2906 element: 'function(m)',
2907 parameters: '()',
2908 body: '{var local=42;}'),
2909 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2910 element: 'variable(m#local)',
2911 rhs: 42),
2912 ]),
2913 const Test(
2914 '''
2915 m() {
2916 const local = 42;
2917 }
2918 ''',
2919 const [
2920 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2921 element: 'function(m)',
2922 parameters: '()',
2923 body: '{const local=42;}'),
2924 const Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
2925 element: 'variable(m#local)',
2926 constant: 42),
2927 ]),
2928 const Test(
2929 '''
2930 m() {
2931 var local1, local2;
2932 }
2933 ''',
2934 const [
2935 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2936 element: 'function(m)',
2937 parameters: '()',
2938 body: '{var local1,local2;}'),
2939 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2940 element: 'variable(m#local1)'),
2941 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2942 element: 'variable(m#local2)'),
2943 ]),
2944 const Test(
2945 '''
2946 m() {
2947 var local1 = 42, local2 = true;
2948 }
2949 ''',
2950 const [
2951 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2952 element: 'function(m)',
2953 parameters: '()',
2954 body: '{var local1=42,local2=true;}'),
2955 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2956 element: 'variable(m#local1)',
2957 rhs: 42),
2958 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2959 element: 'variable(m#local2)',
2960 rhs: true),
2961 ]),
2962 const Test(
2963 '''
2964 m() {
2965 const local1 = 42, local2 = true;
2966 }
2967 ''',
2968 const [
2969 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2970 element: 'function(m)',
2971 parameters: '()',
2972 body: '{const local1=42,local2=true;}'),
2973 const Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
2974 element: 'variable(m#local1)',
2975 constant: 42),
2976 const Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
2977 element: 'variable(m#local2)',
2978 constant: true),
2979 ]),
2980 const Test.clazz(
2981 '''
2982 class C {
2983 static var m;
2984 }
2985 ''',
2986 const [
2987 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
2988 element: 'field(C#m)'),
2989 ]),
2990 const Test.clazz(
2991 '''
2992 class C {
2993 static var m, n;
2994 }
2995 ''',
2996 const [
2997 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
2998 element: 'field(C#m)'),
2999 ]),
3000 const Test.clazz(
3001 '''
3002 class C {
3003 static var k, l, m, n;
3004 }
3005 ''',
3006 const [
3007 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
3008 element: 'field(C#m)'),
3009 ]),
3010 const Test.clazz(
3011 '''
3012 class C {
3013 static var m = 42;
3014 }
3015 ''',
3016 const [
3017 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
3018 element: 'field(C#m)',
3019 rhs: 42),
3020 ]),
3021 const Test.clazz(
3022 '''
3023 class C {
3024 static var m = 42, n = true;
3025 }
3026 ''',
3027 const [
3028 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
3029 element: 'field(C#m)',
3030 rhs: 42),
3031 ]),
3032 const Test.clazz(
3033 '''
3034 class C {
3035 static const m = 42;
3036 }
3037 ''',
3038 const [
3039 const Visit(VisitKind.VISIT_STATIC_CONSTANT_DECL,
3040 element: 'field(C#m)',
3041 constant: 42),
3042 ]),
3043 const Test(
3044 '''
3045 var m;
3046 ''',
3047 const [
3048 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
3049 element: 'field(m)'),
3050 ]),
3051 const Test(
3052 '''
3053 var m, n;
3054 ''',
3055 const [
3056 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
3057 element: 'field(m)'),
3058 ]),
3059 const Test(
3060 '''
3061 var m = 42;
3062 ''',
3063 const [
3064 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
3065 element: 'field(m)',
3066 rhs: 42),
3067 ]),
3068 const Test(
3069 '''
3070 const m = 42;
3071 ''',
3072 const [
3073 const Visit(VisitKind.VISIT_TOP_LEVEL_CONSTANT_DECL,
3074 element: 'field(m)',
3075 constant: 42),
3076 ]),
3077 ],
3078 };
3079
2262 main(List<String> arguments) { 3080 main(List<String> arguments) {
2263 asyncTest(() => Future.forEach([ 3081 asyncTest(() => Future.forEach([
2264 () { 3082 () {
2265 return test( 3083 return test(
2266 arguments, 3084 arguments,
2267 SEND_TESTS, 3085 SEND_TESTS,
2268 (elements) => new SemanticSendTestVisitor(elements)); 3086 (elements) => new SemanticSendTestVisitor(elements));
2269 }, 3087 },
3088 () {
3089 return test(
3090 arguments,
3091 DECL_TESTS,
3092 (elements) => new SemanticDeclarationTestVisitor(elements));
3093 },
2270 ], (f) => f())); 3094 ], (f) => f()));
2271 } 3095 }
2272 3096
2273 Future test(List<String> arguments, 3097 Future test(List<String> arguments,
2274 Map<String, List<Test>> TESTS, 3098 Map<String, List<Test>> TESTS,
2275 SemanticTestVisitor createVisitor(TreeElements elements)) { 3099 SemanticTestVisitor createVisitor(TreeElements elements)) {
2276 Map<String, String> sourceFiles = {}; 3100 Map<String, String> sourceFiles = {};
2277 Map<String, Test> testMap = {}; 3101 Map<String, Test> testMap = {};
2278 StringBuffer mainSource = new StringBuffer(); 3102 StringBuffer mainSource = new StringBuffer();
2279 int index = 0; 3103 int index = 0;
(...skipping 22 matching lines...) Expand all
2302 Compiler compiler = compilerFor(sourceFiles, 3126 Compiler compiler = compilerFor(sourceFiles,
2303 options: ['--analyze-all', '--analyze-only']); 3127 options: ['--analyze-all', '--analyze-only']);
2304 return compiler.run(Uri.parse('memory:main.dart')).then((_) { 3128 return compiler.run(Uri.parse('memory:main.dart')).then((_) {
2305 testMap.forEach((String filename, Test test) { 3129 testMap.forEach((String filename, Test test) {
2306 LibraryElement library = compiler.libraryLoader.lookupLibrary( 3130 LibraryElement library = compiler.libraryLoader.lookupLibrary(
2307 Uri.parse('memory:$filename')); 3131 Uri.parse('memory:$filename'));
2308 var expectedVisits = test.expectedVisits; 3132 var expectedVisits = test.expectedVisits;
2309 if (expectedVisits is! List) { 3133 if (expectedVisits is! List) {
2310 expectedVisits = [expectedVisits]; 3134 expectedVisits = [expectedVisits];
2311 } 3135 }
2312 AstElement element; 3136 Element element;
2313 String cls = test.cls; 3137 String cls = test.cls;
2314 String method = test.method; 3138 String method = test.method;
2315 if (cls == null) { 3139 if (cls == null) {
2316 element = library.find(method); 3140 element = library.find(method);
2317 } else { 3141 } else {
2318 ClassElement classElement = library.find(cls); 3142 ClassElement classElement = library.find(cls);
2319 Expect.isNotNull(classElement, 3143 Expect.isNotNull(classElement,
2320 "Class '$cls' not found in:\n" 3144 "Class '$cls' not found in:\n"
2321 "${library.compilationUnit.script.text}"); 3145 "${library.compilationUnit.script.text}");
2322 element = classElement.localLookup(method); 3146 element = classElement.localLookup(method);
2323 } 3147 }
2324 Expect.isNotNull(element, "Element '$method' not found in:\n" 3148
2325 "${library.compilationUnit.script.text}"); 3149 void testAstElement(AstElement astElement) {
2326 ResolvedAst resolvedAst = element.resolvedAst; 3150 Expect.isNotNull(astElement, "Element '$method' not found in:\n"
2327 SemanticTestVisitor visitor = createVisitor(resolvedAst.elements); 3151 "${library.compilationUnit.script.text}");
2328 try { 3152 ResolvedAst resolvedAst = astElement.resolvedAst;
2329 compiler.withCurrentElement(resolvedAst.element, () { 3153 SemanticTestVisitor visitor = createVisitor(resolvedAst.elements);
2330 //print(resolvedAst.node.toDebugString()); 3154 try {
2331 resolvedAst.node.accept(visitor); 3155 compiler.withCurrentElement(resolvedAst.element, () {
2332 }); 3156 //print(resolvedAst.node.toDebugString());
2333 } catch (e, s) { 3157 resolvedAst.node.accept(visitor);
2334 Expect.fail("$e:\n$s\nIn test:\n" 3158 });
2335 "${library.compilationUnit.script.text}"); 3159 } catch (e, s) {
3160 Expect.fail("$e:\n$s\nIn test:\n"
3161 "${library.compilationUnit.script.text}");
3162 }
3163 Expect.listEquals(expectedVisits, visitor.visits,
3164 "In test:\n"
3165 "${library.compilationUnit.script.text}");
2336 } 3166 }
2337 Expect.listEquals(expectedVisits, visitor.visits, 3167 if (element.isAbstractField) {
2338 "In test:\n" 3168 AbstractFieldElement abstractFieldElement = element;
2339 "${library.compilationUnit.script.text}"); 3169 if (abstractFieldElement.getter != null) {
3170 testAstElement(abstractFieldElement.getter);
3171 } else if (abstractFieldElement.setter != null) {
3172 testAstElement(abstractFieldElement.setter);
3173 }
3174 } else {
3175 testAstElement(element);
3176 }
2340 }); 3177 });
2341 }); 3178 });
2342 } 3179 }
2343 3180
2344
2345 abstract class SemanticTestVisitor extends TraversalVisitor { 3181 abstract class SemanticTestVisitor extends TraversalVisitor {
2346 List<Visit> visits = <Visit>[]; 3182 List<Visit> visits = <Visit>[];
2347 3183
2348 SemanticTestVisitor(TreeElements elements) : super(elements); 3184 SemanticTestVisitor(TreeElements elements) : super(elements);
2349 3185
2350 apply(Node node, arg) => node.accept(this); 3186 apply(Node node, arg) => node.accept(this);
2351 3187
2352 internalError(Spannable spannable, String message) { 3188 internalError(Spannable spannable, String message) {
2353 throw new SpannableAssertionFailure(spannable, message); 3189 throw new SpannableAssertionFailure(spannable, message);
2354 } 3190 }
(...skipping 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after
4283 Node index, 5119 Node index,
4284 IncDecOperator operator, 5120 IncDecOperator operator,
4285 arg) { 5121 arg) {
4286 visits.add(new Visit(VisitKind.VISIT_SUPER_INDEX_PREFIX, 5122 visits.add(new Visit(VisitKind.VISIT_SUPER_INDEX_PREFIX,
4287 getter: indexFunction, setter: indexSetFunction, 5123 getter: indexFunction, setter: indexSetFunction,
4288 index: index, operator: operator)); 5124 index: index, operator: operator));
4289 apply(index, arg); 5125 apply(index, arg);
4290 } 5126 }
4291 5127
4292 @override 5128 @override
5129 errorUnresolvedClassConstructorInvoke(
5130 NewExpression node,
5131 Element constructor,
5132 MalformedType type,
5133 NodeList arguments,
5134 Selector selector,
5135 arg) {
5136 // TODO(johnniwinther): Test [type] and [selector].
5137 visits.add(new Visit(
5138 VisitKind.ERROR_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE,
5139 arguments: arguments));
5140 apply(arguments, arg);
5141 }
5142
5143 @override
5144 errorUnresolvedConstructorInvoke(
5145 NewExpression node,
5146 Element constructor,
5147 DartType type,
5148 NodeList arguments,
5149 Selector selector,
5150 arg) {
5151 // TODO(johnniwinther): Test [type] and [selector].
5152 visits.add(new Visit(
5153 VisitKind.ERROR_UNRESOLVED_CONSTRUCTOR_INVOKE,
5154 arguments: arguments));
5155 apply(arguments, arg);
5156 }
5157
5158 @override
5159 visitConstConstructorInvoke(
5160 NewExpression node,
5161 ConstructedConstantExpression constant,
5162 arg) {
5163 visits.add(new Visit(VisitKind.VISIT_CONST_CONSTRUCTOR_INVOKE,
5164 constant: constant.getText()));
5165 }
5166
5167 @override
5168 visitFactoryConstructorInvoke(
5169 NewExpression node,
5170 ConstructorElement constructor,
5171 InterfaceType type,
5172 NodeList arguments,
5173 Selector selector,
5174 arg) {
5175 visits.add(new Visit(
5176 VisitKind.VISIT_FACTORY_CONSTRUCTOR_INVOKE,
5177 element: constructor,
5178 type: type,
5179 arguments: arguments,
5180 selector: selector));
5181 apply(arguments, arg);
5182 }
5183
5184 @override
5185 visitGenerativeConstructorInvoke(
5186 NewExpression node,
5187 ConstructorElement constructor,
5188 InterfaceType type,
5189 NodeList arguments,
5190 Selector selector,
5191 arg) {
5192 visits.add(new Visit(
5193 VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_INVOKE,
5194 element: constructor,
5195 type: type,
5196 arguments: arguments,
5197 selector: selector));
5198 apply(arguments, arg);
5199 }
5200
5201 @override
5202 visitRedirectingFactoryConstructorInvoke(
5203 NewExpression node,
5204 ConstructorElement constructor,
5205 InterfaceType type,
5206 ConstructorElement effectiveTarget,
5207 InterfaceType effectiveTargetType,
5208 NodeList arguments,
5209 Selector selector,
5210 arg) {
5211 visits.add(new Visit(
5212 VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
5213 element: constructor,
5214 type: type,
5215 target: effectiveTarget,
5216 targetType: effectiveTargetType,
5217 arguments: arguments,
5218 selector: selector));
5219 apply(arguments, arg);
5220 }
5221
5222 @override
5223 visitRedirectingGenerativeConstructorInvoke(
5224 NewExpression node,
5225 ConstructorElement constructor,
5226 InterfaceType type,
5227 NodeList arguments,
5228 Selector selector,
5229 arg) {
5230 visits.add(new Visit(
5231 VisitKind.VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_INVOKE,
5232 element: constructor,
5233 type: type,
5234 arguments: arguments,
5235 selector: selector));
5236 apply(arguments, arg);
5237 }
5238
5239 @override
5240 errorAbstractClassConstructorInvoke(
5241 NewExpression node,
5242 ConstructorElement constructor,
5243 InterfaceType type,
5244 NodeList arguments,
5245 Selector selector,
5246 arg) {
5247 visits.add(new Visit(
5248 VisitKind.ERROR_ABSTRACT_CLASS_CONSTRUCTOR_INVOKE,
5249 element: constructor,
5250 type: type,
5251 arguments: arguments,
5252 selector: selector));
5253 apply(arguments, arg);
5254 }
5255
5256 @override
5257 errorUnresolvedRedirectingFactoryConstructorInvoke(
5258 NewExpression node,
5259 ConstructorElement constructor,
5260 InterfaceType type,
5261 NodeList arguments,
5262 Selector selector,
5263 arg) {
5264 visits.add(new Visit(
5265 VisitKind.ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
5266 element: constructor,
5267 type: type,
5268 arguments: arguments,
5269 selector: selector));
5270 apply(arguments, arg);
5271 }
5272 }
5273
5274 class SemanticDeclarationTestVisitor extends SemanticTestVisitor {
5275
5276 SemanticDeclarationTestVisitor(TreeElements elements) : super(elements);
5277
5278 @override
5279 errorUnresolvedSuperConstructorInvoke(
5280 Send node,
5281 Element element,
5282 NodeList arguments,
5283 Selector selector,
5284 arg) {
5285 // TODO: implement errorUnresolvedSuperConstructorInvoke
5286 }
5287
5288 @override
5289 errorUnresolvedThisConstructorInvoke(
5290 Send node,
5291 Element element,
5292 NodeList arguments,
5293 Selector selector,
5294 arg) {
5295 // TODO: implement errorUnresolvedThisConstructorInvoke
5296 }
5297
5298 @override
5299 visitAbstractMethodDeclaration(
5300 FunctionExpression node,
5301 MethodElement method,
5302 NodeList parameters,
5303 arg) {
5304 visits.add(new Visit(VisitKind.VISIT_ABSTRACT_METHOD_DECL,
5305 element: method, parameters: parameters));
5306 applyParameters(parameters, arg);
5307 }
5308
5309 @override
5310 visitClosureDeclaration(
5311 FunctionExpression node,
5312 LocalFunctionElement function,
5313 NodeList parameters,
5314 Node body,
5315 arg) {
5316 visits.add(new Visit(VisitKind.VISIT_CLOSURE_DECL,
5317 element: function, parameters: parameters, body: body));
5318 applyParameters(parameters, arg);
5319 apply(body, arg);
5320 }
5321
5322 @override
5323 visitFactoryConstructorDeclaration(
5324 FunctionExpression node,
5325 ConstructorElement constructor,
5326 NodeList parameters,
5327 Node body,
5328 arg) {
5329 visits.add(new Visit(VisitKind.VISIT_FACTORY_CONSTRUCTOR_DECL,
5330 element: constructor, parameters: parameters, body: body));
5331 applyParameters(parameters, arg);
5332 apply(body, arg);
5333 }
5334
5335 @override
5336 visitFieldInitializer(
5337 SendSet node,
5338 FieldElement field,
5339 Node initializer,
5340 arg) {
5341 visits.add(new Visit(VisitKind.VISIT_FIELD_INITIALIZER,
5342 element: field, rhs: initializer));
5343 apply(initializer, arg);
5344 }
5345
5346 @override
5347 visitGenerativeConstructorDeclaration(
5348 FunctionExpression node,
5349 ConstructorElement constructor,
5350 NodeList parameters,
5351 NodeList initializers,
5352 Node body,
5353 arg) {
5354 visits.add(new Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
5355 element: constructor, parameters: parameters, body: body));
5356 applyParameters(parameters, arg);
5357 applyInitializers(initializers, arg);
5358 apply(body, arg);
5359 }
5360
5361 @override
5362 visitInstanceMethodDeclaration(
5363 FunctionExpression node,
5364 MethodElement method,
5365 NodeList parameters,
5366 Node body,
5367 arg) {
5368 visits.add(new Visit(VisitKind.VISIT_INSTANCE_METHOD_DECL,
5369 element: method, parameters: parameters, body: body));
5370 applyParameters(parameters, arg);
5371 apply(body, arg);
5372 }
5373
5374 @override
5375 visitLocalFunctionDeclaration(
5376 FunctionExpression node,
5377 LocalFunctionElement function,
5378 NodeList parameters,
5379 Node body,
5380 arg) {
5381 visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_DECL,
5382 element: function, parameters: parameters, body: body));
5383 applyParameters(parameters, arg);
5384 apply(body, arg);
5385 }
5386
5387 @override
5388 visitRedirectingFactoryConstructorDeclaration(
5389 FunctionExpression node,
5390 ConstructorElement constructor,
5391 NodeList parameters,
5392 InterfaceType redirectionType,
5393 ConstructorElement redirectionTarget,
5394 arg) {
5395 visits.add(new Visit(
5396 VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
5397 element: constructor,
5398 parameters: parameters,
5399 target: redirectionTarget,
5400 type: redirectionType));
5401 applyParameters(parameters, arg);
5402 }
5403
5404 @override
5405 visitRedirectingGenerativeConstructorDeclaration(
5406 FunctionExpression node,
5407 ConstructorElement constructor,
5408 NodeList parameters,
5409 NodeList initializers,
5410 arg) {
5411 visits.add(new Visit(
5412 VisitKind.VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_DECL,
5413 element: constructor,
5414 parameters: parameters,
5415 initializers: initializers));
5416 applyParameters(parameters, arg);
5417 applyInitializers(initializers, arg);
5418 }
5419
5420 @override
5421 visitStaticFunctionDeclaration(
5422 FunctionExpression node,
5423 MethodElement function,
5424 NodeList parameters,
5425 Node body,
5426 arg) {
5427 visits.add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_DECL,
5428 element: function, parameters: parameters, body: body));
5429 applyParameters(parameters, arg);
5430 apply(body, arg);
5431 }
5432
5433 @override
5434 visitSuperConstructorInvoke(
5435 Send node,
5436 ConstructorElement superConstructor,
5437 InterfaceType type,
5438 NodeList arguments,
5439 Selector selector,
5440 arg) {
5441 visits.add(new Visit(VisitKind.VISIT_SUPER_CONSTRUCTOR_INVOKE,
5442 element: superConstructor, type: type,
5443 arguments: arguments, selector: selector));
5444 apply(arguments, arg);
5445 }
5446
5447 @override
5448 visitThisConstructorInvoke(
5449 Send node,
5450 ConstructorElement thisConstructor,
5451 NodeList arguments,
5452 Selector selector,
5453 arg) {
5454 visits.add(new Visit(VisitKind.VISIT_THIS_CONSTRUCTOR_INVOKE,
5455 element: thisConstructor, arguments: arguments, selector: selector));
5456 apply(arguments, arg);
5457 }
5458
5459 @override
5460 visitTopLevelFunctionDeclaration(
5461 FunctionExpression node,
5462 MethodElement function,
5463 NodeList parameters,
5464 Node body,
5465 arg) {
5466 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
5467 element: function, parameters: parameters, body: body));
5468 applyParameters(parameters, arg);
5469 apply(body, arg);
5470 }
5471
5472 @override
5473 errorUnresolvedFieldInitializer(
5474 SendSet node,
5475 Element element,
5476 Node initializer,
5477 arg) {
5478 // TODO: implement errorUnresolvedFieldInitializer
5479 }
5480
5481 @override
5482 visitOptionalParameterDeclaration(
5483 VariableDefinitions node,
5484 Node definition,
5485 ParameterElement parameter,
5486 ConstantExpression defaultValue,
5487 int index,
5488 arg) {
5489 visits.add(new Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
5490 element: parameter,
5491 constant: defaultValue != null ? defaultValue.getText() : null,
5492 index: index));
5493 }
5494
5495 @override
5496 visitParameterDeclaration(
5497 VariableDefinitions node,
5498 Node definition,
5499 ParameterElement parameter,
5500 int index,
5501 arg) {
5502 visits.add(new Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
5503 element: parameter, index: index));
5504 }
5505
5506 @override
5507 visitInitializingFormalDeclaration(
5508 VariableDefinitions node,
5509 Node definition,
5510 InitializingFormalElement initializingFormal,
5511 int index,
5512 arg) {
5513 visits.add(new Visit(VisitKind.VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
5514 element: initializingFormal, index: index));
5515 }
5516
5517 @override
5518 visitLocalVariableDeclaration(
5519 VariableDefinitions node,
5520 Node definition,
5521 LocalVariableElement variable,
5522 Node initializer,
5523 arg) {
5524 visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
5525 element: variable, rhs: initializer));
5526 if (initializer != null) {
5527 apply(initializer, arg);
5528 }
5529 return null;
5530 }
5531
5532 @override
5533 visitLocalConstantDeclaration(
5534 VariableDefinitions node,
5535 Node definition,
5536 LocalVariableElement variable,
5537 ConstantExpression constant,
5538 arg) {
5539 visits.add(new Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
5540 element: variable, constant: constant.getText()));
5541 return null;
5542 }
5543
5544 @override
5545 visitNamedInitializingFormalDeclaration(
5546 VariableDefinitions node,
5547 Node definition,
5548 InitializingFormalElement initializingFormal,
5549 ConstantExpression defaultValue,
5550 arg) {
5551 visits.add(new Visit(VisitKind.VISIT_NAMED_INITIALIZING_FORMAL_DECL,
5552 element: initializingFormal,
5553 constant: defaultValue != null ? defaultValue.getText() : null));
5554 }
5555
5556 @override
5557 visitNamedParameterDeclaration(
5558 VariableDefinitions node,
5559 Node definition,
5560 ParameterElement parameter,
5561 ConstantExpression defaultValue,
5562 arg) {
5563 visits.add(new Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
5564 element: parameter,
5565 constant: defaultValue != null ? defaultValue.getText() : null));
5566 }
5567
5568 @override
5569 visitOptionalInitializingFormalDeclaration(
5570 VariableDefinitions node,
5571 Node definition,
5572 InitializingFormalElement initializingFormal,
5573 ConstantExpression defaultValue,
5574 int index,
5575 arg) {
5576 visits.add(new Visit(VisitKind.VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
5577 element: initializingFormal,
5578 constant: defaultValue != null ? defaultValue.getText() : null,
5579 index: index));
5580 }
5581
5582 @override
5583 visitInstanceFieldDeclaration(
5584 VariableDefinitions node,
5585 Node definition,
5586 FieldElement field,
5587 Node initializer,
5588 arg) {
5589 visits.add(new Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
5590 element: field, rhs: initializer));
5591 if (initializer != null) {
5592 apply(initializer, arg);
5593 }
5594 return null;
5595 }
5596
5597 @override
5598 visitStaticConstantDeclaration(
5599 VariableDefinitions node,
5600 Node definition,
5601 FieldElement field,
5602 ConstantExpression constant,
5603 arg) {
5604 visits.add(new Visit(VisitKind.VISIT_STATIC_CONSTANT_DECL,
5605 element: field, constant: constant.getText()));
5606 return null;
5607 }
5608
5609 @override
5610 visitStaticFieldDeclaration(
5611 VariableDefinitions node,
5612 Node definition,
5613 FieldElement field,
5614 Node initializer,
5615 arg) {
5616 visits.add(new Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
5617 element: field, rhs: initializer));
5618 if (initializer != null) {
5619 apply(initializer, arg);
5620 }
5621 return null;
5622 }
5623
5624 @override
5625 visitTopLevelConstantDeclaration(
5626 VariableDefinitions node,
5627 Node definition,
5628 FieldElement field,
5629 ConstantExpression constant,
5630 arg) {
5631 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_CONSTANT_DECL,
5632 element: field, constant: constant.getText()));
5633 return null;
5634 }
5635
5636 @override
5637 visitTopLevelFieldDeclaration(
5638 VariableDefinitions node,
5639 Node definition,
5640 FieldElement field,
5641 Node initializer,
5642 arg) {
5643 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
5644 element: field, rhs: initializer));
5645 if (initializer != null) {
5646 apply(initializer, arg);
5647 }
5648 return null;
5649 }
5650
5651 @override
5652 visitAbstractGetterDeclaration(
5653 FunctionExpression node,
5654 MethodElement getter,
5655 arg) {
5656 visits.add(new Visit(VisitKind.VISIT_ABSTRACT_GETTER_DECL,
5657 element: getter));
5658 return null;
5659 }
5660
5661 @override
5662 visitAbstractSetterDeclaration(
5663 FunctionExpression node,
5664 MethodElement setter,
5665 NodeList parameters,
5666 arg) {
5667 visits.add(new Visit(VisitKind.VISIT_ABSTRACT_SETTER_DECL,
5668 element: setter, parameters: parameters));
5669 applyParameters(parameters, arg);
5670 return null;
5671 }
5672
5673 @override
5674 visitInstanceGetterDeclaration(
5675 FunctionExpression node,
5676 MethodElement getter,
5677 Node body,
5678 arg) {
5679 visits.add(new Visit(VisitKind.VISIT_INSTANCE_GETTER_DECL,
5680 element: getter, body: body));
5681 apply(body, arg);
5682 return null;
5683 }
5684
5685 @override
5686 visitInstanceSetterDeclaration(
5687 FunctionExpression node,
5688 MethodElement setter,
5689 NodeList parameters,
5690 Node body,
5691 arg) {
5692 visits.add(new Visit(VisitKind.VISIT_INSTANCE_SETTER_DECL,
5693 element: setter, parameters: parameters, body: body));
5694 applyParameters(parameters, arg);
5695 apply(body, arg);
5696 return null;
5697 }
5698
5699 @override
5700 visitTopLevelGetterDeclaration(
5701 FunctionExpression node,
5702 MethodElement getter,
5703 Node body,
5704 arg) {
5705 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_DECL,
5706 element: getter, body: body));
5707 apply(body, arg);
5708 return null;
5709 }
5710
5711 @override
5712 visitTopLevelSetterDeclaration(
5713 FunctionExpression node,
5714 MethodElement setter,
5715 NodeList parameters,
5716 Node body,
5717 arg) {
5718 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_DECL,
5719 element: setter, parameters: parameters, body: body));
5720 applyParameters(parameters, arg);
5721 apply(body, arg);
5722 return null;
5723 }
5724
5725 @override
5726 visitStaticGetterDeclaration(
5727 FunctionExpression node,
5728 MethodElement getter,
5729 Node body,
5730 arg) {
5731 visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_DECL,
5732 element: getter, body: body));
5733 apply(body, arg);
5734 return null;
5735 }
5736
5737 @override
5738 visitStaticSetterDeclaration(
5739 FunctionExpression node,
5740 MethodElement setter,
5741 NodeList parameters,
5742 Node body,
5743 arg) {
5744 visits.add(new Visit(VisitKind.VISIT_STATIC_SETTER_DECL,
5745 element: setter, parameters: parameters, body: body));
5746 applyParameters(parameters, arg);
5747 apply(body, arg);
5748 return null;
5749 }
5750
5751 @override
4293 errorUnresolvedClassConstructorInvoke( 5752 errorUnresolvedClassConstructorInvoke(
4294 NewExpression node, 5753 NewExpression node,
4295 Element constructor, 5754 Element constructor,
4296 MalformedType type, 5755 MalformedType type,
4297 NodeList arguments, 5756 NodeList arguments,
4298 Selector selector, 5757 Selector selector,
4299 arg) { 5758 arg) {
4300 // TODO(johnniwinther): Test [type] and [selector]. 5759 // TODO(johnniwinther): Test [type] and [selector].
4301 visits.add(new Visit( 5760 visits.add(new Visit(
4302 VisitKind.ERROR_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE, 5761 VisitKind.ERROR_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4442 VISIT_PARAMETER_COMPOUND, 5901 VISIT_PARAMETER_COMPOUND,
4443 VISIT_PARAMETER_PREFIX, 5902 VISIT_PARAMETER_PREFIX,
4444 VISIT_PARAMETER_POSTFIX, 5903 VISIT_PARAMETER_POSTFIX,
4445 5904
4446 VISIT_LOCAL_VARIABLE_GET, 5905 VISIT_LOCAL_VARIABLE_GET,
4447 VISIT_LOCAL_VARIABLE_SET, 5906 VISIT_LOCAL_VARIABLE_SET,
4448 VISIT_LOCAL_VARIABLE_INVOKE, 5907 VISIT_LOCAL_VARIABLE_INVOKE,
4449 VISIT_LOCAL_VARIABLE_COMPOUND, 5908 VISIT_LOCAL_VARIABLE_COMPOUND,
4450 VISIT_LOCAL_VARIABLE_PREFIX, 5909 VISIT_LOCAL_VARIABLE_PREFIX,
4451 VISIT_LOCAL_VARIABLE_POSTFIX, 5910 VISIT_LOCAL_VARIABLE_POSTFIX,
5911 VISIT_LOCAL_VARIABLE_DECL,
5912 VISIT_LOCAL_CONSTANT_DECL,
4452 5913
4453 VISIT_LOCAL_FUNCTION_GET, 5914 VISIT_LOCAL_FUNCTION_GET,
4454 VISIT_LOCAL_FUNCTION_INVOKE, 5915 VISIT_LOCAL_FUNCTION_INVOKE,
5916 VISIT_LOCAL_FUNCTION_DECL,
5917 VISIT_CLOSURE_DECL,
4455 5918
4456 VISIT_STATIC_FIELD_GET, 5919 VISIT_STATIC_FIELD_GET,
4457 VISIT_STATIC_FIELD_SET, 5920 VISIT_STATIC_FIELD_SET,
4458 VISIT_STATIC_FIELD_INVOKE, 5921 VISIT_STATIC_FIELD_INVOKE,
4459 VISIT_STATIC_FIELD_COMPOUND, 5922 VISIT_STATIC_FIELD_COMPOUND,
4460 VISIT_STATIC_FIELD_PREFIX, 5923 VISIT_STATIC_FIELD_PREFIX,
4461 VISIT_STATIC_FIELD_POSTFIX, 5924 VISIT_STATIC_FIELD_POSTFIX,
5925 VISIT_STATIC_FIELD_DECL,
5926 VISIT_STATIC_CONSTANT_DECL,
4462 5927
4463 VISIT_STATIC_GETTER_GET, 5928 VISIT_STATIC_GETTER_GET,
4464 VISIT_STATIC_SETTER_SET, 5929 VISIT_STATIC_SETTER_SET,
4465 VISIT_STATIC_GETTER_INVOKE, 5930 VISIT_STATIC_GETTER_INVOKE,
4466 VISIT_STATIC_GETTER_SETTER_COMPOUND, 5931 VISIT_STATIC_GETTER_SETTER_COMPOUND,
4467 VISIT_STATIC_METHOD_SETTER_COMPOUND, 5932 VISIT_STATIC_METHOD_SETTER_COMPOUND,
4468 VISIT_STATIC_GETTER_SETTER_PREFIX, 5933 VISIT_STATIC_GETTER_SETTER_PREFIX,
4469 VISIT_STATIC_GETTER_SETTER_POSTFIX, 5934 VISIT_STATIC_GETTER_SETTER_POSTFIX,
5935 VISIT_STATIC_GETTER_DECL,
5936 VISIT_STATIC_SETTER_DECL,
4470 5937
4471 VISIT_STATIC_FUNCTION_GET, 5938 VISIT_STATIC_FUNCTION_GET,
4472 VISIT_STATIC_FUNCTION_INVOKE, 5939 VISIT_STATIC_FUNCTION_INVOKE,
5940 VISIT_STATIC_FUNCTION_DECL,
4473 5941
4474 VISIT_TOP_LEVEL_FIELD_GET, 5942 VISIT_TOP_LEVEL_FIELD_GET,
4475 VISIT_TOP_LEVEL_FIELD_SET, 5943 VISIT_TOP_LEVEL_FIELD_SET,
4476 VISIT_TOP_LEVEL_FIELD_INVOKE, 5944 VISIT_TOP_LEVEL_FIELD_INVOKE,
4477 VISIT_TOP_LEVEL_FIELD_COMPOUND, 5945 VISIT_TOP_LEVEL_FIELD_COMPOUND,
4478 VISIT_TOP_LEVEL_FIELD_PREFIX, 5946 VISIT_TOP_LEVEL_FIELD_PREFIX,
4479 VISIT_TOP_LEVEL_FIELD_POSTFIX, 5947 VISIT_TOP_LEVEL_FIELD_POSTFIX,
5948 VISIT_TOP_LEVEL_FIELD_DECL,
5949 VISIT_TOP_LEVEL_CONSTANT_DECL,
4480 5950
4481 VISIT_TOP_LEVEL_GETTER_GET, 5951 VISIT_TOP_LEVEL_GETTER_GET,
4482 VISIT_TOP_LEVEL_SETTER_SET, 5952 VISIT_TOP_LEVEL_SETTER_SET,
4483 VISIT_TOP_LEVEL_GETTER_INVOKE, 5953 VISIT_TOP_LEVEL_GETTER_INVOKE,
4484 VISIT_TOP_LEVEL_GETTER_SETTER_COMPOUND, 5954 VISIT_TOP_LEVEL_GETTER_SETTER_COMPOUND,
4485 VISIT_TOP_LEVEL_GETTER_SETTER_PREFIX, 5955 VISIT_TOP_LEVEL_GETTER_SETTER_PREFIX,
4486 VISIT_TOP_LEVEL_GETTER_SETTER_POSTFIX, 5956 VISIT_TOP_LEVEL_GETTER_SETTER_POSTFIX,
5957 VISIT_TOP_LEVEL_GETTER_DECL,
5958 VISIT_TOP_LEVEL_SETTER_DECL,
4487 5959
4488 VISIT_TOP_LEVEL_FUNCTION_GET, 5960 VISIT_TOP_LEVEL_FUNCTION_GET,
4489 VISIT_TOP_LEVEL_FUNCTION_INVOKE, 5961 VISIT_TOP_LEVEL_FUNCTION_INVOKE,
5962 VISIT_TOP_LEVEL_FUNCTION_DECL,
4490 5963
4491 VISIT_DYNAMIC_PROPERTY_GET, 5964 VISIT_DYNAMIC_PROPERTY_GET,
4492 VISIT_DYNAMIC_PROPERTY_SET, 5965 VISIT_DYNAMIC_PROPERTY_SET,
4493 VISIT_DYNAMIC_PROPERTY_INVOKE, 5966 VISIT_DYNAMIC_PROPERTY_INVOKE,
4494 VISIT_DYNAMIC_PROPERTY_COMPOUND, 5967 VISIT_DYNAMIC_PROPERTY_COMPOUND,
4495 VISIT_DYNAMIC_PROPERTY_PREFIX, 5968 VISIT_DYNAMIC_PROPERTY_PREFIX,
4496 VISIT_DYNAMIC_PROPERTY_POSTFIX, 5969 VISIT_DYNAMIC_PROPERTY_POSTFIX,
4497 5970
4498 VISIT_THIS_GET, 5971 VISIT_THIS_GET,
4499 VISIT_THIS_INVOKE, 5972 VISIT_THIS_INVOKE,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
4591 VISIT_IS, 6064 VISIT_IS,
4592 VISIT_IS_NOT, 6065 VISIT_IS_NOT,
4593 VISIT_AS, 6066 VISIT_AS,
4594 6067
4595 VISIT_CONST_CONSTRUCTOR_INVOKE, 6068 VISIT_CONST_CONSTRUCTOR_INVOKE,
4596 VISIT_GENERATIVE_CONSTRUCTOR_INVOKE, 6069 VISIT_GENERATIVE_CONSTRUCTOR_INVOKE,
4597 VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_INVOKE, 6070 VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_INVOKE,
4598 VISIT_FACTORY_CONSTRUCTOR_INVOKE, 6071 VISIT_FACTORY_CONSTRUCTOR_INVOKE,
4599 VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE, 6072 VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
4600 6073
6074 VISIT_SUPER_CONSTRUCTOR_INVOKE,
6075 VISIT_THIS_CONSTRUCTOR_INVOKE,
6076 VISIT_FIELD_INITIALIZER,
6077
4601 ERROR_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE, 6078 ERROR_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE,
4602 ERROR_UNRESOLVED_CONSTRUCTOR_INVOKE, 6079 ERROR_UNRESOLVED_CONSTRUCTOR_INVOKE,
4603 ERROR_ABSTRACT_CLASS_CONSTRUCTOR_INVOKE, 6080 ERROR_ABSTRACT_CLASS_CONSTRUCTOR_INVOKE,
4604 ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE, 6081 ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
4605 6082
6083 VISIT_INSTANCE_GETTER_DECL,
6084 VISIT_INSTANCE_SETTER_DECL,
6085 VISIT_INSTANCE_METHOD_DECL,
6086 VISIT_ABSTRACT_GETTER_DECL,
6087 VISIT_ABSTRACT_SETTER_DECL,
6088 VISIT_ABSTRACT_METHOD_DECL,
6089 VISIT_INSTANCE_FIELD_DECL,
6090
6091 VISIT_GENERATIVE_CONSTRUCTOR_DECL,
6092 VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_DECL,
6093 VISIT_FACTORY_CONSTRUCTOR_DECL,
6094 VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
6095
6096 VISIT_REQUIRED_PARAMETER_DECL,
6097 VISIT_OPTIONAL_PARAMETER_DECL,
6098 VISIT_NAMED_PARAMETER_DECL,
6099 VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
6100 VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
6101 VISIT_NAMED_INITIALIZING_FORMAL_DECL,
6102
4606 ERROR_UNRESOLVED_POSTFIX, 6103 ERROR_UNRESOLVED_POSTFIX,
4607 6104
4608 // TODO(johnniwinther): Add tests for more error cases. 6105 // TODO(johnniwinther): Add tests for more error cases.
4609 } 6106 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/use_unused_api.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698