| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
| 9 | 9 |
| 10 import 'package:compiler/src/elements/resolution_types.dart'; | 10 import 'package:compiler/src/elements/resolution_types.dart'; |
| (...skipping 2648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 | 2659 |
| 2660 Future setup(test(MockCompiler compiler)) { | 2660 Future setup(test(MockCompiler compiler)) { |
| 2661 MockCompiler compiler = | 2661 MockCompiler compiler = |
| 2662 new MockCompiler.internal(coreSource: ALT_SOURCE, enableAsyncAwait: true); | 2662 new MockCompiler.internal(coreSource: ALT_SOURCE, enableAsyncAwait: true); |
| 2663 return compiler.init("import 'dart:async';").then((_) => test(compiler)); | 2663 return compiler.init("import 'dart:async';").then((_) => test(compiler)); |
| 2664 } | 2664 } |
| 2665 | 2665 |
| 2666 ResolutionDartType analyzeType(MockCompiler compiler, String text) { | 2666 ResolutionDartType analyzeType(MockCompiler compiler, String text) { |
| 2667 var node = parseExpression(text); | 2667 var node = parseExpression(text); |
| 2668 TypeCheckerVisitor visitor = new TypeCheckerVisitor( | 2668 TypeCheckerVisitor visitor = new TypeCheckerVisitor( |
| 2669 compiler, new TreeElementMapping(null), compiler.types); | 2669 compiler, new TreeElementMapping(null), compiler.resolution.types); |
| 2670 return visitor.analyze(node); | 2670 return visitor.analyze(node); |
| 2671 } | 2671 } |
| 2672 | 2672 |
| 2673 analyzeTopLevel(String text, [expectedWarnings]) { | 2673 analyzeTopLevel(String text, [expectedWarnings]) { |
| 2674 if (expectedWarnings == null) expectedWarnings = []; | 2674 if (expectedWarnings == null) expectedWarnings = []; |
| 2675 if (expectedWarnings is! List) expectedWarnings = [expectedWarnings]; | 2675 if (expectedWarnings is! List) expectedWarnings = [expectedWarnings]; |
| 2676 | 2676 |
| 2677 MockCompiler compiler = new MockCompiler.internal(enableAsyncAwait: true); | 2677 MockCompiler compiler = new MockCompiler.internal(enableAsyncAwait: true); |
| 2678 compiler.diagnosticHandler = createHandler(compiler, text); | 2678 compiler.diagnosticHandler = createHandler(compiler, text); |
| 2679 | 2679 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2703 } | 2703 } |
| 2704 }); | 2704 }); |
| 2705 } else { | 2705 } else { |
| 2706 node = element.parseNode(compiler.parsingContext); | 2706 node = element.parseNode(compiler.parsingContext); |
| 2707 compiler.resolver.resolve(element); | 2707 compiler.resolver.resolve(element); |
| 2708 mapping = element.treeElements; | 2708 mapping = element.treeElements; |
| 2709 } | 2709 } |
| 2710 } | 2710 } |
| 2711 // Type check last class declaration or member. | 2711 // Type check last class declaration or member. |
| 2712 TypeCheckerVisitor checker = | 2712 TypeCheckerVisitor checker = |
| 2713 new TypeCheckerVisitor(compiler, mapping, compiler.types); | 2713 new TypeCheckerVisitor(compiler, mapping, compiler.resolution.types); |
| 2714 DiagnosticCollector collector = compiler.diagnosticCollector; | 2714 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 2715 collector.clear(); | 2715 collector.clear(); |
| 2716 checker.analyze(node, mustHaveType: false); | 2716 checker.analyze(node, mustHaveType: false); |
| 2717 compareWarningKinds(text, expectedWarnings, collector.warnings); | 2717 compareWarningKinds(text, expectedWarnings, collector.warnings); |
| 2718 | 2718 |
| 2719 compiler.diagnosticHandler = null; | 2719 compiler.diagnosticHandler = null; |
| 2720 }); | 2720 }); |
| 2721 } | 2721 } |
| 2722 | 2722 |
| 2723 /** | 2723 /** |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2740 new NodeListener(const ScannerOptions(), compiler.reporter, null); | 2740 new NodeListener(const ScannerOptions(), compiler.reporter, null); |
| 2741 Parser parser = new Parser(listener); | 2741 Parser parser = new Parser(listener); |
| 2742 parser.parseStatement(tokens); | 2742 parser.parseStatement(tokens); |
| 2743 Node node = listener.popNode(); | 2743 Node node = listener.popNode(); |
| 2744 Element compilationUnit = new CompilationUnitElementX( | 2744 Element compilationUnit = new CompilationUnitElementX( |
| 2745 new Script(null, null, null), compiler.mainApp); | 2745 new Script(null, null, null), compiler.mainApp); |
| 2746 Element function = new MockElement(compilationUnit); | 2746 Element function = new MockElement(compilationUnit); |
| 2747 TreeElements elements = compiler.resolveNodeStatement(node, function); | 2747 TreeElements elements = compiler.resolveNodeStatement(node, function); |
| 2748 compiler.enqueuer.resolution.emptyDeferredQueueForTesting(); | 2748 compiler.enqueuer.resolution.emptyDeferredQueueForTesting(); |
| 2749 TypeCheckerVisitor checker = | 2749 TypeCheckerVisitor checker = |
| 2750 new TypeCheckerVisitor(compiler, elements, compiler.types); | 2750 new TypeCheckerVisitor(compiler, elements, compiler.resolution.types); |
| 2751 DiagnosticCollector collector = compiler.diagnosticCollector; | 2751 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 2752 collector.clear(); | 2752 collector.clear(); |
| 2753 checker.analyze(node, mustHaveType: false); | 2753 checker.analyze(node, mustHaveType: false); |
| 2754 if (flushDeferred) { | 2754 if (flushDeferred) { |
| 2755 compiler.enqueuer.resolution.emptyDeferredQueueForTesting(); | 2755 compiler.enqueuer.resolution.emptyDeferredQueueForTesting(); |
| 2756 } | 2756 } |
| 2757 compareWarningKinds(text, warnings, collector.warnings); | 2757 compareWarningKinds(text, warnings, collector.warnings); |
| 2758 compareWarningKinds(text, errors, collector.errors); | 2758 compareWarningKinds(text, errors, collector.errors); |
| 2759 if (hints != null) compareWarningKinds(text, hints, collector.hints); | 2759 if (hints != null) compareWarningKinds(text, hints, collector.hints); |
| 2760 if (infos != null) compareWarningKinds(text, infos, collector.infos); | 2760 if (infos != null) compareWarningKinds(text, infos, collector.infos); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2781 compiler.resolver.resolve(element); | 2781 compiler.resolver.resolve(element); |
| 2782 Token tokens = scan(text); | 2782 Token tokens = scan(text); |
| 2783 NodeListener listener = | 2783 NodeListener listener = |
| 2784 new NodeListener(const ScannerOptions(), compiler.reporter, null); | 2784 new NodeListener(const ScannerOptions(), compiler.reporter, null); |
| 2785 Parser parser = new Parser(listener) | 2785 Parser parser = new Parser(listener) |
| 2786 ..asyncState = element.asyncMarker.asyncParserState; | 2786 ..asyncState = element.asyncMarker.asyncParserState; |
| 2787 parser.parseStatement(tokens); | 2787 parser.parseStatement(tokens); |
| 2788 Node node = listener.popNode(); | 2788 Node node = listener.popNode(); |
| 2789 TreeElements elements = compiler.resolveNodeStatement(node, element); | 2789 TreeElements elements = compiler.resolveNodeStatement(node, element); |
| 2790 TypeCheckerVisitor checker = | 2790 TypeCheckerVisitor checker = |
| 2791 new TypeCheckerVisitor(compiler, elements, compiler.types); | 2791 new TypeCheckerVisitor(compiler, elements, compiler.resolution.types); |
| 2792 DiagnosticCollector collector = compiler.diagnosticCollector; | 2792 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 2793 collector.clear(); | 2793 collector.clear(); |
| 2794 checker.analyze(node, mustHaveType: false); | 2794 checker.analyze(node, mustHaveType: false); |
| 2795 generateOutput(compiler, text); | 2795 generateOutput(compiler, text); |
| 2796 compareWarningKinds(text, warnings, collector.warnings); | 2796 compareWarningKinds(text, warnings, collector.warnings); |
| 2797 compareWarningKinds(text, hints, collector.hints); | 2797 compareWarningKinds(text, hints, collector.hints); |
| 2798 } | 2798 } |
| OLD | NEW |