| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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; | 5 library analyzer; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as pathos; | 9 import 'package:path/path.dart' as pathos; |
| 10 | 10 |
| 11 import 'src/error.dart'; | 11 import 'src/error.dart'; |
| 12 import 'src/generated/ast.dart'; | 12 import 'src/generated/ast.dart'; |
| 13 import 'src/generated/error.dart'; | 13 import 'src/generated/error.dart'; |
| 14 import 'src/generated/parser.dart'; | 14 import 'src/generated/parser.dart'; |
| 15 import 'src/generated/scanner.dart'; | 15 import 'src/generated/scanner.dart'; |
| 16 import 'src/generated/source_io.dart'; | 16 import 'src/generated/source_io.dart'; |
| 17 import 'src/string_source.dart'; | 17 import 'src/string_source.dart'; |
| 18 | 18 |
| 19 export 'src/error.dart'; | 19 export 'src/error.dart'; |
| 20 export 'src/generated/ast.dart'; | 20 export 'src/generated/ast.dart'; |
| 21 export 'src/generated/error.dart'; | 21 export 'src/generated/error.dart'; |
| 22 export 'src/generated/utilities_dart.dart'; | 22 export 'src/generated/utilities_dart.dart'; |
| 23 | 23 |
| 24 /// Parses a Dart file into an AST. | 24 /// Parses a Dart file into an AST. |
| 25 CompilationUnit parseDartFile(String path) { | 25 CompilationUnit parseDartFile(String path) { |
| 26 String contents = new File(path).readAsStringSync(); | 26 String contents = new File(path).readAsStringSync(); |
| 27 var errorCollector = new _ErrorCollector(); | 27 var errorCollector = new _ErrorCollector(); |
| 28 var sourceFactory = new SourceFactory.con2([new FileUriResolver()]); | 28 var sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 29 | 29 |
| 30 var absolutePath = pathos.absolute(path); | 30 var absolutePath = pathos.absolute(path); |
| 31 var source = sourceFactory.forUri(pathos.toUri(absolutePath).toString()); | 31 var source = sourceFactory.forUri(pathos.toUri(absolutePath).toString()); |
| 32 if (source == null) { | 32 if (source == null) { |
| 33 throw new ArgumentError("Can't get source for path $path"); | 33 throw new ArgumentError("Can't get source for path $path"); |
| 34 } | 34 } |
| 35 if (!source.exists()) { | 35 if (!source.exists()) { |
| 36 throw new ArgumentError("Source $source doesn't exist"); | 36 throw new ArgumentError("Source $source doesn't exist"); |
| 37 } | 37 } |
| 38 | 38 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 bool get hasErrors => !_errors.isEmpty; | 81 bool get hasErrors => !_errors.isEmpty; |
| 82 | 82 |
| 83 /// The group of errors collected. | 83 /// The group of errors collected. |
| 84 AnalyzerErrorGroup get group => | 84 AnalyzerErrorGroup get group => |
| 85 new AnalyzerErrorGroup.fromAnalysisErrors(_errors); | 85 new AnalyzerErrorGroup.fromAnalysisErrors(_errors); |
| 86 | 86 |
| 87 _ErrorCollector(); | 87 _ErrorCollector(); |
| 88 | 88 |
| 89 void onError(AnalysisError error) => _errors.add(error); | 89 void onError(AnalysisError error) => _errors.add(error); |
| 90 } | 90 } |
| OLD | NEW |