| Index: lib/src/codegen.dart
|
| diff --git a/lib/src/codegen.dart b/lib/src/codegen.dart
|
| index baffd1b6fd5104d0c2a33d3de8084da493f9917e..0cd6163c1c42c30de3baf6f896ee283f1679ff01 100644
|
| --- a/lib/src/codegen.dart
|
| +++ b/lib/src/codegen.dart
|
| @@ -14,14 +14,15 @@ import 'utils.dart';
|
| * null then there is no file associated with the template (used by testing
|
| * so we'll display <MEMORY> for file name.
|
| */
|
| -String header(Path path, String libraryName) => """
|
| +String header(Path path, String libraryName) {
|
| + var library = libraryName != null ? '\nlibrary $libraryName;\n' : '';
|
| + return """
|
| // Auto-generated from ${path != null ? path.filename : "<MEMORY>"}.
|
| // DO NOT EDIT.
|
| -
|
| -library $libraryName;
|
| -
|
| +$library
|
| $imports
|
| """;
|
| +}
|
|
|
| // TODO(sigmund): include only those imports that are used by the code.
|
| String get imports => """
|
| @@ -128,7 +129,11 @@ String importList(Iterable<Path> imports) =>
|
| String directiveText(
|
| DartDirectiveInfo directive, LibraryInfo src, PathInfo pathInfo) {
|
| var buff = new StringBuffer();
|
| - var uri = pathInfo.transformUrl(src.inputPath, directive.uri);
|
| + var uri = directive.uri;
|
| + if (!directive.generated) {
|
| + // This file was not generated, so get the relative path to the input file.
|
| + uri = pathInfo.transformUrl(src.inputPath, uri);
|
| + }
|
| buff..add(directive.label)
|
| ..add(" '")
|
| ..add(uri.replaceAll("'", "\\'"))
|
|
|