| 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 | 62 const CodeKind._(); |
| 63 final int _index; | |
| 64 | |
| 65 const CodeKind._(this._index); | |
| 66 | 63 |
| 67 /// A compilation unit snippet. | 64 /// A compilation unit snippet. |
| 68 static const COMPILATION_UNIT = const CodeKind._(0); | 65 static const COMPILATION_UNIT = const CodeKind._(); |
| 69 | 66 |
| 70 /// A statement snippet. | 67 /// A statement snippet. |
| 71 static const STATEMENT = const CodeKind._(1); | 68 static const STATEMENT = const CodeKind._(); |
| 72 | 69 |
| 73 } | 70 } |
| 74 | 71 |
| 75 /// Dart source code formatter. | 72 /// Dart source code formatter. |
| 76 abstract class CodeFormatter { | 73 abstract class CodeFormatter { |
| 77 | 74 |
| 78 factory CodeFormatter([FormatterOptions options = const FormatterOptions()]) | 75 factory CodeFormatter([FormatterOptions options = const FormatterOptions()]) |
| 79 => new CodeFormatterImpl(options); | 76 => new CodeFormatterImpl(options); |
| 80 | 77 |
| 81 /// Format the specified portion (from [offset] with [length]) of the given | 78 /// Format the specified portion (from [offset] with [length]) of the given |
| (...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1844 @override | 1841 @override |
| 1845 visitEnumConstantDeclaration(EnumConstantDeclaration node) { | 1842 visitEnumConstantDeclaration(EnumConstantDeclaration node) { |
| 1846 // TODO: implement visitEnumConstantDeclaration | 1843 // TODO: implement visitEnumConstantDeclaration |
| 1847 } | 1844 } |
| 1848 | 1845 |
| 1849 @override | 1846 @override |
| 1850 visitEnumDeclaration(EnumDeclaration node) { | 1847 visitEnumDeclaration(EnumDeclaration node) { |
| 1851 // TODO: implement visitEnumDeclaration | 1848 // TODO: implement visitEnumDeclaration |
| 1852 } | 1849 } |
| 1853 } | 1850 } |
| OLD | NEW |