| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 mirrors_util; | 5 library mirrors_util; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 // TODO(rnystrom): Use "package:" URL (#4968). | 9 // TODO(rnystrom): Use "package:" URL (#4968). |
| 10 import 'mirrors.dart'; | 10 import 'mirrors.dart'; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return match[1]; | 131 return match[1]; |
| 132 } | 132 } |
| 133 match = _multiLineCommentStartEnd.firstMatch(comment); | 133 match = _multiLineCommentStartEnd.firstMatch(comment); |
| 134 if (match != null) { | 134 if (match != null) { |
| 135 comment = match[1]; | 135 comment = match[1]; |
| 136 var sb = new StringBuffer(); | 136 var sb = new StringBuffer(); |
| 137 List<String> lines = comment.split('\n'); | 137 List<String> lines = comment.split('\n'); |
| 138 for (int index = 0 ; index < lines.length ; index++) { | 138 for (int index = 0 ; index < lines.length ; index++) { |
| 139 String line = lines[index]; | 139 String line = lines[index]; |
| 140 if (index == 0) { | 140 if (index == 0) { |
| 141 sb.add(line); // Add the first line unprocessed. | 141 sb.write(line); // Add the first line unprocessed. |
| 142 continue; | 142 continue; |
| 143 } | 143 } |
| 144 sb.add('\n'); | 144 sb.write('\n'); |
| 145 match = _multiLineCommentLineStart.firstMatch(line); | 145 match = _multiLineCommentLineStart.firstMatch(line); |
| 146 if (match != null) { | 146 if (match != null) { |
| 147 sb.add(match[1]); | 147 sb.write(match[1]); |
| 148 } else if (index < lines.length-1 || !line.trim().isEmpty) { | 148 } else if (index < lines.length-1 || !line.trim().isEmpty) { |
| 149 // Do not add the last line if it only contains white space. | 149 // Do not add the last line if it only contains white space. |
| 150 // This interprets cases like | 150 // This interprets cases like |
| 151 // /* | 151 // /* |
| 152 // * Foo | 152 // * Foo |
| 153 // */ | 153 // */ |
| 154 // as "\nFoo\n" and not as "\nFoo\n ". | 154 // as "\nFoo\n" and not as "\nFoo\n ". |
| 155 sb.add(line); | 155 sb.write(line); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 return sb.toString(); | 158 return sb.toString(); |
| 159 } | 159 } |
| 160 throw new ArgumentError('Invalid comment $comment'); | 160 throw new ArgumentError('Invalid comment $comment'); |
| 161 } | 161 } |
| OLD | NEW |