Chromium Code Reviews| Index: pkg/analyzer_experimental/lib/src/services/writer.dart |
| diff --git a/pkg/analyzer_experimental/lib/src/services/writer.dart b/pkg/analyzer_experimental/lib/src/services/writer.dart |
| index 5ec61559e67169a1540afa869aaca556b1376717..d73a1fa2c525fa295cd57e857d59fc44cb9db6a0 100644 |
| --- a/pkg/analyzer_experimental/lib/src/services/writer.dart |
| +++ b/pkg/analyzer_experimental/lib/src/services/writer.dart |
| @@ -19,30 +19,23 @@ class Line { |
| } |
| } |
| - addSpace() { |
| + void addSpace() { |
|
pquitslund
2013/08/08 21:20:23
Again, why be explicit here? Like I said, I prefe
|
| addSpaces(1); |
| } |
| - addSpaces(int n) { |
| + void addSpaces(int n) { |
|
pquitslund
2013/08/08 21:20:23
Ditto.
|
| if (n > 0) { |
| tokens.add(new SpaceToken(n)); |
| } |
| } |
| - addToken(LineToken token) { |
| + void addToken(LineToken token) { |
|
pquitslund
2013/08/08 21:20:23
Ditto.
|
| tokens.add(token); |
| } |
| - bool isWhitespace() { |
| - for (var tok in tokens) { |
| - if (!(tok is SpaceToken)) { |
| - return false; |
| - } |
| - } |
| - return true; |
| - } |
| + bool isWhitespace() => tokens.every((tok) => tok is SpaceToken); |
|
pquitslund
2013/08/08 21:20:23
Sweet!
|
| - _indent(int n) { |
| + void _indent(int n) { |
|
pquitslund
2013/08/08 21:20:23
Ditto. (And for the rest too.)
|
| tokens.add(useTabs ? new TabToken(n) : new SpaceToken(n * spacesPerIndent)); |
| } |
| @@ -96,19 +89,19 @@ class SourceWriter { |
| currentLine = new Line(indent: indentCount); |
| } |
| - indent() { |
| + void indent() { |
| ++indentCount; |
| } |
| - unindent() { |
| + void unindent() { |
| --indentCount; |
| } |
| - print(x) { |
| + void print(x) { |
| currentLine.addToken(new LineToken(x)); |
| } |
| - newline() { |
| + void newline() { |
| if (currentLine.isWhitespace()) { |
| currentLine.tokens.clear(); |
| } |
| @@ -117,21 +110,21 @@ class SourceWriter { |
| currentLine = new Line(indent: indentCount); |
| } |
| - newlines(int num) { |
| + void newlines(int num) { |
| while (num-- > 0) { |
| newline(); |
| } |
| } |
| - space() { |
| + void space() { |
| spaces(1); |
| } |
| - spaces(n) { |
| + void spaces(n) { |
| currentLine.addSpaces(n); |
| } |
| - println(String s) { |
| + void println(String s) { |
| print(s); |
| newline(); |
| } |
| @@ -148,7 +141,7 @@ class SourceWriter { |
| const SPACE = ' '; |
| -final SPACES = [ |
| +const SPACES = const [ |
| '', |
| ' ', |
| ' ', |
| @@ -167,7 +160,7 @@ final SPACES = [ |
| ' ', |
| ' ', |
| ]; |
| -final TABS = [ |
| +const TABS = const [ |
| '', |
| '\t', |
| '\t\t', |