Chromium Code Reviews| 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 formatter_impl; | 5 library formatter_impl; |
| 6 | 6 |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/parser.dart'; | 10 import 'package:analyzer/src/generated/parser.dart'; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 var errorCode = errors[0].errorCode; | 52 var errorCode = errors[0].errorCode; |
| 53 var phase = errorCode is ParserErrorCode ? 'parsing' : 'scanning'; | 53 var phase = errorCode is ParserErrorCode ? 'parsing' : 'scanning'; |
| 54 return 'An error occured while $phase (${errorCode.name}).'; | 54 return 'An error occured while $phase (${errorCode.name}).'; |
| 55 } | 55 } |
| 56 | 56 |
| 57 String toString() => '$message'; | 57 String toString() => '$message'; |
| 58 } | 58 } |
| 59 | 59 |
| 60 /// Specifies the kind of code snippet to format. | 60 /// Specifies the kind of code snippet to format. |
| 61 class CodeKind { | 61 class CodeKind { |
| 62 const CodeKind._(); | 62 final int ordinal; |
|
Brian Wilkerson
2014/11/14 19:16:15
Alternatively, we could give them a name, which wo
| |
| 63 | |
| 64 const CodeKind._(this.ordinal); | |
| 63 | 65 |
| 64 /// A compilation unit snippet. | 66 /// A compilation unit snippet. |
| 65 static const COMPILATION_UNIT = const CodeKind._(); | 67 static const COMPILATION_UNIT = const CodeKind._(0); |
| 66 | 68 |
| 67 /// A statement snippet. | 69 /// A statement snippet. |
| 68 static const STATEMENT = const CodeKind._(); | 70 static const STATEMENT = const CodeKind._(1); |
| 69 | 71 |
| 70 } | 72 } |
| 71 | 73 |
| 72 /// Dart source code formatter. | 74 /// Dart source code formatter. |
| 73 abstract class CodeFormatter { | 75 abstract class CodeFormatter { |
| 74 | 76 |
| 75 factory CodeFormatter([FormatterOptions options = const FormatterOptions()]) | 77 factory CodeFormatter([FormatterOptions options = const FormatterOptions()]) |
| 76 => new CodeFormatterImpl(options); | 78 => new CodeFormatterImpl(options); |
| 77 | 79 |
| 78 /// Format the specified portion (from [offset] with [length]) of the given | 80 /// Format the specified portion (from [offset] with [length]) of the given |
| (...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1841 @override | 1843 @override |
| 1842 visitEnumConstantDeclaration(EnumConstantDeclaration node) { | 1844 visitEnumConstantDeclaration(EnumConstantDeclaration node) { |
| 1843 // TODO: implement visitEnumConstantDeclaration | 1845 // TODO: implement visitEnumConstantDeclaration |
| 1844 } | 1846 } |
| 1845 | 1847 |
| 1846 @override | 1848 @override |
| 1847 visitEnumDeclaration(EnumDeclaration node) { | 1849 visitEnumDeclaration(EnumDeclaration node) { |
| 1848 // TODO: implement visitEnumDeclaration | 1850 // TODO: implement visitEnumDeclaration |
| 1849 } | 1851 } |
| 1850 } | 1852 } |
| OLD | NEW |