| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Generate a doc comment based on the HTML in [docs]. | 95 * Generate a doc comment based on the HTML in [docs]. |
| 96 * | 96 * |
| 97 * When generating java code, the output is compatible with Javadoc, which | 97 * When generating java code, the output is compatible with Javadoc, which |
| 98 * understands certain HTML constructs. | 98 * understands certain HTML constructs. |
| 99 */ | 99 */ |
| 100 void docComment(List<dom.Node> docs, {bool removeTrailingNewLine: false}) { | 100 void docComment(List<dom.Node> docs, {bool removeTrailingNewLine: false}) { |
| 101 if (containsOnlyWhitespace(docs)) return; | 101 if (containsOnlyWhitespace(docs)) return; |
| 102 if (codeGeneratorSettings.docCommentStartMarker != null) writeln(codeGenerat
orSettings.docCommentStartMarker); | 102 if (codeGeneratorSettings.docCommentStartMarker != null) |
| 103 writeln(codeGeneratorSettings.docCommentStartMarker); |
| 103 int width = codeGeneratorSettings.commentLineLength; | 104 int width = codeGeneratorSettings.commentLineLength; |
| 104 bool javadocStyle = codeGeneratorSettings.languageName == 'java'; | 105 bool javadocStyle = codeGeneratorSettings.languageName == 'java'; |
| 105 indentBy(codeGeneratorSettings.docCommentLineLeader, () { | 106 indentBy(codeGeneratorSettings.docCommentLineLeader, () { |
| 106 write(nodesToText(docs, width - _state.indent.length, javadocStyle, | 107 write(nodesToText(docs, width - _state.indent.length, javadocStyle, |
| 107 removeTrailingNewLine: removeTrailingNewLine)); | 108 removeTrailingNewLine: removeTrailingNewLine)); |
| 108 }); | 109 }); |
| 109 if (codeGeneratorSettings.docCommentEndMarker != null) writeln(codeGenerator
Settings.docCommentEndMarker); | 110 if (codeGeneratorSettings.docCommentEndMarker != null) |
| 111 writeln(codeGeneratorSettings.docCommentEndMarker); |
| 110 } | 112 } |
| 111 | 113 |
| 112 /** | 114 /** |
| 113 * Execute [callback], indenting any code it outputs. | 115 * Execute [callback], indenting any code it outputs. |
| 114 */ | 116 */ |
| 115 void indent(void callback()) { | 117 void indent(void callback()) { |
| 116 indentSpecial( | 118 indentSpecial( |
| 117 codeGeneratorSettings.indent, codeGeneratorSettings.indent, callback); | 119 codeGeneratorSettings.indent, codeGeneratorSettings.indent, callback); |
| 118 } | 120 } |
| 119 | 121 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (lines.last.isEmpty) { | 599 if (lines.last.isEmpty) { |
| 598 lines.removeLast(); | 600 lines.removeLast(); |
| 599 buffer.add(new dom.Text(lines.join('\n$indent') + '\n')); | 601 buffer.add(new dom.Text(lines.join('\n$indent') + '\n')); |
| 600 indentNeeded = true; | 602 indentNeeded = true; |
| 601 } else { | 603 } else { |
| 602 buffer.add(new dom.Text(lines.join('\n$indent'))); | 604 buffer.add(new dom.Text(lines.join('\n$indent'))); |
| 603 indentNeeded = false; | 605 indentNeeded = false; |
| 604 } | 606 } |
| 605 } | 607 } |
| 606 } | 608 } |
| OLD | NEW |