Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Unified Diff: lib/src/codegen.dart

Issue 12225039: Support for observable models, fixes #259 (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/analyzer.dart ('k') | lib/src/compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen.dart
diff --git a/lib/src/codegen.dart b/lib/src/codegen.dart
index f3c3730a11e3cfcecd481dcf667d3d23fd19c46a..26636f4e98c100592fca2b0c3604097419ba9727 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 => """
@@ -34,12 +35,14 @@ import 'package:web_ui/web_ui.dart' as autogenerated;
* The code that will be used to bootstrap the application, this is inlined in
* the main.html.html output file.
*/
-String bootstrapCode(Path userMainImport) => """
+String bootstrapCode(Path userMainImport, bool useObservers) => """
library bootstrap;
+import 'package:web_ui/watcher.dart' as watcher;
import '$userMainImport' as userMain;
main() {
+ watcher.useObservers = $useObservers;
userMain.main();
userMain.init_autogenerated();
}
@@ -47,32 +50,4 @@ main() {
/** Generate text for a list of imports. */
String importList(Iterable<Path> imports) =>
- imports.map((url) => "import '$url';").join('\n');
-
-/**
- * Text corresponding to a directive, fixed in case the code is in a different
- * output location.
- */
-String directiveText(
- DartDirectiveInfo directive, LibraryInfo src, PathInfo pathInfo) {
- var buff = new StringBuffer();
- var uri = pathInfo.transformUrl(src.inputPath, directive.uri);
- buff..add(directive.label)
- ..add(" '")
- ..add(uri.replaceAll("'", "\\'"))
- ..add("'");
- if (directive.prefix != null) {
- buff..add(' as ')
- ..add(directive.prefix);
- }
- if (directive.show != null) {
- buff..add(' show ')
- ..add(directive.show.join(','));
- }
- if (directive.hide != null) {
- buff..add(' hide ')
- ..add(directive.hide.join(','));
- }
- buff.add(';');
- return buff.toString();
-}
+ imports.map((url) => "import '$url';").join('\n');
« no previous file with comments | « lib/src/analyzer.dart ('k') | lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698