| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.generated.resolver_test_case; | 5 library analyzer.test.generated.resolver_test_case; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 * | 728 * |
| 729 * @param source the source of the compilation unit to be returned | 729 * @param source the source of the compilation unit to be returned |
| 730 * @param library the library in which the compilation unit is to be resolved | 730 * @param library the library in which the compilation unit is to be resolved |
| 731 * @return the resolved compilation unit | 731 * @return the resolved compilation unit |
| 732 * @throws Exception if the compilation unit could not be resolved | 732 * @throws Exception if the compilation unit could not be resolved |
| 733 */ | 733 */ |
| 734 CompilationUnit resolveCompilationUnit( | 734 CompilationUnit resolveCompilationUnit( |
| 735 Source source, LibraryElement library) => | 735 Source source, LibraryElement library) => |
| 736 analysisContext2.resolveCompilationUnit(source, library); | 736 analysisContext2.resolveCompilationUnit(source, library); |
| 737 | 737 |
| 738 CompilationUnit resolveSource(String sourceText) => | 738 Future<CompilationUnit> resolveSource2( |
| 739 resolveSource2("/test.dart", sourceText); | 739 String fileName, String sourceText) async { |
| 740 Source source = addNamedSource(fileName, sourceText); |
| 741 TestAnalysisResult analysisResult = await computeAnalysisResult(source); |
| 742 return analysisResult.unit; |
| 743 } |
| 740 | 744 |
| 741 CompilationUnit resolveSource2(String fileName, String sourceText) { | 745 Future<CompilationUnit> resolveSource(String sourceText) => |
| 742 Source source = addNamedSource(fileName, sourceText); | 746 resolveSource2('/test.dart', sourceText); |
| 743 LibraryElement library = analysisContext.computeLibraryElement(source); | |
| 744 return analysisContext.resolveCompilationUnit(source, library); | |
| 745 } | |
| 746 | 747 |
| 747 Future<Source> resolveSources(List<String> sourceTexts) async { | 748 Future<Source> resolveSources(List<String> sourceTexts) async { |
| 748 for (int i = 0; i < sourceTexts.length; i++) { | 749 for (int i = 0; i < sourceTexts.length; i++) { |
| 749 Source source = addNamedSource('/lib${i + 1}.dart', sourceTexts[i]); | 750 Source source = addNamedSource('/lib${i + 1}.dart', sourceTexts[i]); |
| 750 await computeAnalysisResult(source); | 751 await computeAnalysisResult(source); |
| 751 // reference the source if this is the last source | 752 // reference the source if this is the last source |
| 752 if (i + 1 == sourceTexts.length) { | 753 if (i + 1 == sourceTexts.length) { |
| 753 return source; | 754 return source; |
| 754 } | 755 } |
| 755 } | 756 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 } | 927 } |
| 927 } | 928 } |
| 928 } | 929 } |
| 929 | 930 |
| 930 class TestAnalysisResult { | 931 class TestAnalysisResult { |
| 931 final Source source; | 932 final Source source; |
| 932 final CompilationUnit unit; | 933 final CompilationUnit unit; |
| 933 final List<AnalysisError> errors; | 934 final List<AnalysisError> errors; |
| 934 TestAnalysisResult(this.source, this.unit, this.errors); | 935 TestAnalysisResult(this.source, this.unit, this.errors); |
| 935 } | 936 } |
| OLD | NEW |