| 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 library kernel.analyzer.loader; | 4 library kernel.analyzer.loader; |
| 5 | 5 |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:convert'; |
| 7 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 8 | 9 |
| 9 import 'package:analyzer/analyzer.dart'; | 10 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 11 import 'package:analyzer/file_system/file_system.dart'; |
| 11 import 'package:analyzer/file_system/physical_file_system.dart'; | 12 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 12 import 'package:analyzer/source/package_map_resolver.dart'; | 13 import 'package:analyzer/source/package_map_resolver.dart'; |
| 13 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 14 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 14 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 15 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart'; | 16 import 'package:analyzer/src/generated/engine.dart'; |
| 16 import 'package:analyzer/src/generated/parser.dart'; | 17 import 'package:analyzer/src/generated/parser.dart'; |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 loadEverything(target: target, compileSdk: compileSdk); | 821 loadEverything(target: target, compileSdk: compileSdk); |
| 821 if (mainMethod == null) { | 822 if (mainMethod == null) { |
| 822 mainMethod = _makeMissingMainMethod(library); | 823 mainMethod = _makeMissingMainMethod(library); |
| 823 } | 824 } |
| 824 program.mainMethod = mainMethod; | 825 program.mainMethod = mainMethod; |
| 825 for (LibraryElement libraryElement in libraryElements) { | 826 for (LibraryElement libraryElement in libraryElements) { |
| 826 for (CompilationUnitElement compilationUnitElement | 827 for (CompilationUnitElement compilationUnitElement |
| 827 in libraryElement.units) { | 828 in libraryElement.units) { |
| 828 var source = compilationUnitElement.source; | 829 var source = compilationUnitElement.source; |
| 829 LineInfo lineInfo = context.computeLineInfo(source); | 830 LineInfo lineInfo = context.computeLineInfo(source); |
| 830 String sourceCode; | 831 List<int> sourceCode; |
| 831 try { | 832 try { |
| 832 sourceCode = context.getContents(source).data; | 833 sourceCode = |
| 834 const Utf8Encoder().convert(context.getContents(source).data); |
| 833 } catch (e) { | 835 } catch (e) { |
| 834 // The source's contents could not be accessed. | 836 // The source's contents could not be accessed. |
| 835 sourceCode = ''; | 837 sourceCode = const <int>[]; |
| 836 } | 838 } |
| 837 program.uriToSource['${source.uri}'] = | 839 program.uriToSource['${source.uri}'] = |
| 838 new ast.Source(lineInfo.lineStarts, sourceCode); | 840 new ast.Source(lineInfo.lineStarts, sourceCode); |
| 839 } | 841 } |
| 840 } | 842 } |
| 841 } | 843 } |
| 842 | 844 |
| 843 ast.Library loadLibrary(Uri uri) { | 845 ast.Library loadLibrary(Uri uri) { |
| 844 ast.Library library = getLibraryReferenceFromUri(uri); | 846 ast.Library library = getLibraryReferenceFromUri(uri); |
| 845 ensureLibraryIsLoaded(library); | 847 ensureLibraryIsLoaded(library); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext() | 995 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext() |
| 994 ..sourceFactory = new SourceFactory(resolvers) | 996 ..sourceFactory = new SourceFactory(resolvers) |
| 995 ..analysisOptions = createAnalysisOptions(options.strongMode); | 997 ..analysisOptions = createAnalysisOptions(options.strongMode); |
| 996 | 998 |
| 997 options.declaredVariables.forEach((String name, String value) { | 999 options.declaredVariables.forEach((String name, String value) { |
| 998 context.declaredVariables.define(name, value); | 1000 context.declaredVariables.define(name, value); |
| 999 }); | 1001 }); |
| 1000 | 1002 |
| 1001 return context; | 1003 return context; |
| 1002 } | 1004 } |
| OLD | NEW |