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:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
(...skipping 17 matching lines...) Expand all Loading... |
28 /// If [name] is passed, it's used in error messages as the name of the code | 28 /// If [name] is passed, it's used in error messages as the name of the code |
29 /// being parsed. | 29 /// being parsed. |
30 /// | 30 /// |
31 /// Throws an [AnalyzerErrorGroup] if any errors occurred, unless | 31 /// Throws an [AnalyzerErrorGroup] if any errors occurred, unless |
32 /// [suppressErrors] is `true`, in which case any errors are discarded. | 32 /// [suppressErrors] is `true`, in which case any errors are discarded. |
33 /// | 33 /// |
34 /// If [parseFunctionBodies] is [false] then only function signatures will be | 34 /// If [parseFunctionBodies] is [false] then only function signatures will be |
35 /// parsed. | 35 /// parsed. |
36 CompilationUnit parseCompilationUnit(String contents, | 36 CompilationUnit parseCompilationUnit(String contents, |
37 {String name, bool suppressErrors: false, bool parseFunctionBodies: true}) { | 37 {String name, bool suppressErrors: false, bool parseFunctionBodies: true}) { |
38 if (name == null) name = '<unknown source>'; | 38 Source source = new StringSource(contents, name); |
39 var source = new StringSource(contents, name); | |
40 return _parseSource(contents, source, | 39 return _parseSource(contents, source, |
41 suppressErrors: suppressErrors, parseFunctionBodies: parseFunctionBodies); | 40 suppressErrors: suppressErrors, parseFunctionBodies: parseFunctionBodies); |
42 } | 41 } |
43 | 42 |
44 /// Parses a Dart file into an AST. | 43 /// Parses a Dart file into an AST. |
45 /// | 44 /// |
46 /// Throws an [AnalyzerErrorGroup] if any errors occurred, unless | 45 /// Throws an [AnalyzerErrorGroup] if any errors occurred, unless |
47 /// [suppressErrors] is `true`, in which case any errors are discarded. | 46 /// [suppressErrors] is `true`, in which case any errors are discarded. |
48 /// | 47 /// |
49 /// If [parseFunctionBodies] is [false] then only function signatures will be | 48 /// If [parseFunctionBodies] is [false] then only function signatures will be |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 121 |
123 /// The group of errors collected. | 122 /// The group of errors collected. |
124 AnalyzerErrorGroup get group => | 123 AnalyzerErrorGroup get group => |
125 new AnalyzerErrorGroup.fromAnalysisErrors(_errors); | 124 new AnalyzerErrorGroup.fromAnalysisErrors(_errors); |
126 | 125 |
127 /// Whether any errors where collected. | 126 /// Whether any errors where collected. |
128 bool get hasErrors => !_errors.isEmpty; | 127 bool get hasErrors => !_errors.isEmpty; |
129 | 128 |
130 void onError(AnalysisError error) => _errors.add(error); | 129 void onError(AnalysisError error) => _errors.add(error); |
131 } | 130 } |
OLD | NEW |