| 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 'src/error.dart'; | 9 import 'src/error.dart'; |
| 10 import 'src/generated/ast.dart'; | 10 import 'src/generated/ast.dart'; |
| 11 import 'src/generated/error.dart'; | 11 import 'src/generated/error.dart'; |
| 12 import 'src/generated/java_io.dart'; | 12 import 'src/generated/java_io.dart'; |
| 13 import 'src/generated/parser.dart'; | 13 import 'src/generated/parser.dart'; |
| 14 import 'src/generated/scanner.dart'; | 14 import 'src/generated/scanner.dart'; |
| 15 import 'src/generated/source_io.dart'; | 15 import 'src/generated/source_io.dart'; |
| 16 import 'src/utils.dart'; | 16 import 'src/utils.dart'; |
| 17 | 17 |
| 18 export 'src/error.dart'; | 18 export 'src/error.dart'; |
| 19 export 'src/generated/ast.dart'; | 19 export 'src/generated/ast.dart'; |
| 20 export 'src/generated/error.dart'; | 20 export 'src/generated/error.dart'; |
| 21 export 'src/generated/utilities_dart.dart'; |
| 21 | 22 |
| 22 /// Parses a Dart file into an AST. | 23 /// Parses a Dart file into an AST. |
| 23 CompilationUnit parseDartFile(String path) { | 24 CompilationUnit parseDartFile(String path) { |
| 24 var contents = new File(path).readAsStringSync(); | 25 var contents = new File(path).readAsStringSync(); |
| 25 var errorCollector = new _ErrorCollector(); | 26 var errorCollector = new _ErrorCollector(); |
| 26 var sourceFactory = new SourceFactory.con2([new FileUriResolver()]); | 27 var sourceFactory = new SourceFactory.con2([new FileUriResolver()]); |
| 27 var source = sourceFactory.forUri(pathToFileUri(path).toString()); | 28 var source = sourceFactory.forUri(pathToFileUri(path).toString()); |
| 28 var scanner = new StringScanner(source, contents, errorCollector); | 29 var scanner = new StringScanner(source, contents, errorCollector); |
| 29 var token = scanner.tokenize(); | 30 var token = scanner.tokenize(); |
| 30 var parser = new Parser(source, errorCollector); | 31 var parser = new Parser(source, errorCollector); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 55 bool get hasErrors => !_errors.isEmpty; | 56 bool get hasErrors => !_errors.isEmpty; |
| 56 | 57 |
| 57 /// The group of errors collected. | 58 /// The group of errors collected. |
| 58 AnalyzerErrorGroup get group => | 59 AnalyzerErrorGroup get group => |
| 59 new AnalyzerErrorGroup.fromAnalysisErrors(_errors); | 60 new AnalyzerErrorGroup.fromAnalysisErrors(_errors); |
| 60 | 61 |
| 61 _ErrorCollector(); | 62 _ErrorCollector(); |
| 62 | 63 |
| 63 void onError(AnalysisError error) => _errors.add(error); | 64 void onError(AnalysisError error) => _errors.add(error); |
| 64 } | 65 } |
| OLD | NEW |