| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /** | 5 /** |
| 6 * Tools for generating code in analyzer and analysis server. | 6 * Tools for generating code in analyzer and analysis server. |
| 7 */ | 7 */ |
| 8 library analyzer.src.codegen.tools; | 8 library analyzer.src.codegen.tools; |
| 9 | 9 |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 return _state.buffer; | 504 return _state.buffer; |
| 505 } finally { | 505 } finally { |
| 506 _state = oldState; | 506 _state = oldState; |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 /** | 510 /** |
| 511 * Execute [callback], wrapping its output in an element with the given | 511 * Execute [callback], wrapping its output in an element with the given |
| 512 * [name] and [attributes]. | 512 * [name] and [attributes]. |
| 513 */ | 513 */ |
| 514 void element(String name, Map<String, String> attributes, [void callback()]) { | 514 void element(String name, Map<dynamic, String> attributes, |
| 515 [void callback()]) { |
| 515 add(makeElement(name, attributes, collectHtml(callback))); | 516 add(makeElement(name, attributes, collectHtml(callback))); |
| 516 } | 517 } |
| 517 | 518 |
| 518 /** | 519 /** |
| 519 * Execute [callback], indenting any code it outputs by two spaces. | 520 * Execute [callback], indenting any code it outputs by two spaces. |
| 520 */ | 521 */ |
| 521 void indent(void callback()) { | 522 void indent(void callback()) { |
| 522 String oldIndent = _state.indent; | 523 String oldIndent = _state.indent; |
| 523 try { | 524 try { |
| 524 _state.indent += ' '; | 525 _state.indent += ' '; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 if (lines.last.isEmpty) { | 600 if (lines.last.isEmpty) { |
| 600 lines.removeLast(); | 601 lines.removeLast(); |
| 601 buffer.add(new dom.Text(lines.join('\n$indent') + '\n')); | 602 buffer.add(new dom.Text(lines.join('\n$indent') + '\n')); |
| 602 indentNeeded = true; | 603 indentNeeded = true; |
| 603 } else { | 604 } else { |
| 604 buffer.add(new dom.Text(lines.join('\n$indent'))); | 605 buffer.add(new dom.Text(lines.join('\n$indent'))); |
| 605 indentNeeded = false; | 606 indentNeeded = false; |
| 606 } | 607 } |
| 607 } | 608 } |
| 608 } | 609 } |
| OLD | NEW |