| 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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 String content = args[1]; | 679 String content = args[1]; |
| 680 File file = resourceProvider.newFile(path, content); | 680 File file = resourceProvider.newFile(path, content); |
| 681 packageMap[name] = <Folder>[file.parent]; | 681 packageMap[name] = <Folder>[file.parent]; |
| 682 }); | 682 }); |
| 683 resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap)); | 683 resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap)); |
| 684 } | 684 } |
| 685 SourceFactory sourceFactory = new SourceFactory(resolvers); | 685 SourceFactory sourceFactory = new SourceFactory(resolvers); |
| 686 | 686 |
| 687 PerformanceLog log = new PerformanceLog(_logBuffer); | 687 PerformanceLog log = new PerformanceLog(_logBuffer); |
| 688 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log); | 688 AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log); |
| 689 driver = new AnalysisDriver(scheduler, log, resourceProvider, | 689 driver = new AnalysisDriver( |
| 690 new MemoryByteStore(), fileContentOverlay, sourceFactory, options); | 690 scheduler, |
| 691 log, |
| 692 resourceProvider, |
| 693 new MemoryByteStore(), |
| 694 fileContentOverlay, |
| 695 'test', |
| 696 sourceFactory, |
| 697 options); |
| 691 scheduler.start(); | 698 scheduler.start(); |
| 692 } else { | 699 } else { |
| 693 if (packages != null) { | 700 if (packages != null) { |
| 694 var packageMap = <String, String>{}; | 701 var packageMap = <String, String>{}; |
| 695 packages.forEach((args) { | 702 packages.forEach((args) { |
| 696 String name = args[0]; | 703 String name = args[0]; |
| 697 String content = args[1]; | 704 String content = args[1]; |
| 698 packageMap['package:$name/$name.dart'] = content; | 705 packageMap['package:$name/$name.dart'] = content; |
| 699 }); | 706 }); |
| 700 analysisContext2 = AnalysisContextFactory.contextWithCoreAndPackages( | 707 analysisContext2 = AnalysisContextFactory.contextWithCoreAndPackages( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 728 * | 735 * |
| 729 * @param source the source of the compilation unit to be returned | 736 * @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 | 737 * @param library the library in which the compilation unit is to be resolved |
| 731 * @return the resolved compilation unit | 738 * @return the resolved compilation unit |
| 732 * @throws Exception if the compilation unit could not be resolved | 739 * @throws Exception if the compilation unit could not be resolved |
| 733 */ | 740 */ |
| 734 CompilationUnit resolveCompilationUnit( | 741 CompilationUnit resolveCompilationUnit( |
| 735 Source source, LibraryElement library) => | 742 Source source, LibraryElement library) => |
| 736 analysisContext2.resolveCompilationUnit(source, library); | 743 analysisContext2.resolveCompilationUnit(source, library); |
| 737 | 744 |
| 745 Future<CompilationUnit> resolveSource(String sourceText) => |
| 746 resolveSource2('/test.dart', sourceText); |
| 747 |
| 738 Future<CompilationUnit> resolveSource2( | 748 Future<CompilationUnit> resolveSource2( |
| 739 String fileName, String sourceText) async { | 749 String fileName, String sourceText) async { |
| 740 Source source = addNamedSource(fileName, sourceText); | 750 Source source = addNamedSource(fileName, sourceText); |
| 741 TestAnalysisResult analysisResult = await computeAnalysisResult(source); | 751 TestAnalysisResult analysisResult = await computeAnalysisResult(source); |
| 742 return analysisResult.unit; | 752 return analysisResult.unit; |
| 743 } | 753 } |
| 744 | 754 |
| 745 Future<CompilationUnit> resolveSource(String sourceText) => | |
| 746 resolveSource2('/test.dart', sourceText); | |
| 747 | |
| 748 Future<Source> resolveSources(List<String> sourceTexts) async { | 755 Future<Source> resolveSources(List<String> sourceTexts) async { |
| 749 for (int i = 0; i < sourceTexts.length; i++) { | 756 for (int i = 0; i < sourceTexts.length; i++) { |
| 750 Source source = addNamedSource('/lib${i + 1}.dart', sourceTexts[i]); | 757 Source source = addNamedSource('/lib${i + 1}.dart', sourceTexts[i]); |
| 751 await computeAnalysisResult(source); | 758 await computeAnalysisResult(source); |
| 752 // reference the source if this is the last source | 759 // reference the source if this is the last source |
| 753 if (i + 1 == sourceTexts.length) { | 760 if (i + 1 == sourceTexts.length) { |
| 754 return source; | 761 return source; |
| 755 } | 762 } |
| 756 } | 763 } |
| 757 return null; | 764 return null; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 } | 934 } |
| 928 } | 935 } |
| 929 } | 936 } |
| 930 | 937 |
| 931 class TestAnalysisResult { | 938 class TestAnalysisResult { |
| 932 final Source source; | 939 final Source source; |
| 933 final CompilationUnit unit; | 940 final CompilationUnit unit; |
| 934 final List<AnalysisError> errors; | 941 final List<AnalysisError> errors; |
| 935 TestAnalysisResult(this.source, this.unit, this.errors); | 942 TestAnalysisResult(this.source, this.unit, this.errors); |
| 936 } | 943 } |
| OLD | NEW |