Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: pkg/analyzer/lib/analyzer.dart

Issue 725143004: Format and sort analyzer and analysis_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/example/scanner_driver.dart ('k') | pkg/analyzer/lib/file_system/file_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/analyzer.dart
diff --git a/pkg/analyzer/lib/analyzer.dart b/pkg/analyzer/lib/analyzer.dart
index dc0b647a361304f9dc88e7f1b026e90b50471e05..2f52d8a34e9140e076b22f1f9f9f3e5dff8501d7 100644
--- a/pkg/analyzer/lib/analyzer.dart
+++ b/pkg/analyzer/lib/analyzer.dart
@@ -21,6 +21,30 @@ export 'src/generated/ast.dart';
export 'src/generated/error.dart';
export 'src/generated/utilities_dart.dart';
+/// Parses a string of Dart code into an AST.
+///
+/// If [name] is passed, it's used in error messages as the name of the code
+/// being parsed.
+///
+/// Throws an [AnalyzerErrorGroup] if any errors occurred, unless
+/// [suppressErrors] is `true`, in which case any errors are discarded.
+CompilationUnit parseCompilationUnit(String contents, {String name,
+ bool suppressErrors: false}) {
+ if (name == null) name = '<unknown source>';
+ var source = new StringSource(contents, name);
+ var errorCollector = new _ErrorCollector();
+ var reader = new CharSequenceReader(contents);
+ var scanner = new Scanner(source, reader, errorCollector);
+ var token = scanner.tokenize();
+ var parser = new Parser(source, errorCollector);
+ var unit = parser.parseCompilationUnit(token);
+ unit.lineInfo = new LineInfo(scanner.lineStarts);
+
+ if (errorCollector.hasErrors && !suppressErrors) throw errorCollector.group;
+
+ return unit;
+}
+
/// Parses a Dart file into an AST.
CompilationUnit parseDartFile(String path) {
String contents = new File(path).readAsStringSync();
@@ -48,30 +72,6 @@ CompilationUnit parseDartFile(String path) {
return unit;
}
-/// Parses a string of Dart code into an AST.
-///
-/// If [name] is passed, it's used in error messages as the name of the code
-/// being parsed.
-///
-/// Throws an [AnalyzerErrorGroup] if any errors occurred, unless
-/// [suppressErrors] is `true`, in which case any errors are discarded.
-CompilationUnit parseCompilationUnit(String contents,
- {String name, bool suppressErrors: false}) {
- if (name == null) name = '<unknown source>';
- var source = new StringSource(contents, name);
- var errorCollector = new _ErrorCollector();
- var reader = new CharSequenceReader(contents);
- var scanner = new Scanner(source, reader, errorCollector);
- var token = scanner.tokenize();
- var parser = new Parser(source, errorCollector);
- var unit = parser.parseCompilationUnit(token);
- unit.lineInfo = new LineInfo(scanner.lineStarts);
-
- if (errorCollector.hasErrors && !suppressErrors) throw errorCollector.group;
-
- return unit;
-}
-
/// Parses the script tag and directives in a string of Dart code into an AST.
///
/// Stops parsing when the first non-directive is encountered. The rest of the
@@ -82,8 +82,8 @@ CompilationUnit parseCompilationUnit(String contents,
///
/// Throws an [AnalyzerErrorGroup] if any errors occurred, unless
/// [suppressErrors] is `true`, in which case any errors are discarded.
-CompilationUnit parseDirectives(String contents,
- {String name, bool suppressErrors: false}) {
+CompilationUnit parseDirectives(String contents, {String name,
+ bool suppressErrors: false}) {
if (name == null) name = '<unknown source>';
var source = new StringSource(contents, name);
var errorCollector = new _ErrorCollector();
@@ -108,14 +108,14 @@ String stringLiteralToString(StringLiteral literal) {
class _ErrorCollector extends AnalysisErrorListener {
final _errors = <AnalysisError>[];
- /// Whether any errors where collected.
- bool get hasErrors => !_errors.isEmpty;
+ _ErrorCollector();
/// The group of errors collected.
AnalyzerErrorGroup get group =>
- new AnalyzerErrorGroup.fromAnalysisErrors(_errors);
+ new AnalyzerErrorGroup.fromAnalysisErrors(_errors);
- _ErrorCollector();
+ /// Whether any errors where collected.
+ bool get hasErrors => !_errors.isEmpty;
void onError(AnalysisError error) => _errors.add(error);
}
« no previous file with comments | « pkg/analyzer/example/scanner_driver.dart ('k') | pkg/analyzer/lib/file_system/file_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698