| 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 /** Collects common snippets of generated code. */ | 5 /** Collects common snippets of generated code. */ |
| 6 library codegen; | 6 library codegen; |
| 7 | 7 |
| 8 import 'file_system/path.dart'; | 8 import 'file_system/path.dart'; |
| 9 import 'info.dart'; | 9 import 'info.dart'; |
| 10 | 10 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 ${exportList(exports)} | 127 ${exportList(exports)} |
| 128 """; | 128 """; |
| 129 | 129 |
| 130 /** Generate text for a list of imports. */ | 130 /** Generate text for a list of imports. */ |
| 131 String importList(List<Path> imports) => | 131 String importList(List<Path> imports) => |
| 132 Strings.join(imports.map((url) => "import '$url';"), '\n'); | 132 Strings.join(imports.map((url) => "import '$url';"), '\n'); |
| 133 | 133 |
| 134 /** Generate text for a list of export. */ | 134 /** Generate text for a list of export. */ |
| 135 String exportList(List<Path> exports) => | 135 String exportList(List<Path> exports) => |
| 136 Strings.join(exports.map((url) => "export '$url';"), '\n'); | 136 Strings.join(exports.map((url) => "export '$url';"), '\n'); |
| 137 |
| 138 /** |
| 139 * Text corresponding to a directive, fixed in case the code is in a different |
| 140 * output location. |
| 141 */ |
| 142 String directiveText( |
| 143 DartDirectiveInfo directive, LibraryInfo src, PathInfo pathInfo) { |
| 144 var buff = new StringBuffer(); |
| 145 var uri = pathInfo.transferDirectiveUrl(src, directive.uri); |
| 146 buff.add(directive.label) |
| 147 .add(" '") |
| 148 .add(uri.replaceAll("'", "\\'")) |
| 149 .add("'"); |
| 150 if (directive.prefix != null) { |
| 151 buff.add(' as ') |
| 152 .add(directive.prefix); |
| 153 } |
| 154 if (directive.show != null) { |
| 155 buff.add(' show ') |
| 156 .add(Strings.join(directive.show, ',')); |
| 157 } |
| 158 if (directive.hide != null) { |
| 159 buff.add(' hide ') |
| 160 .add(Strings.join(directive.hide, ',')); |
| 161 } |
| 162 buff.add(';'); |
| 163 return buff.toString(); |
| 164 } |
| OLD | NEW |