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

Side by Side Diff: lib/src/codegen.dart

Issue 12096106: work in progress: observable implementation using detailed change records (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 unified diff | Download patch
« no previous file with comments | « lib/src/analyzer.dart ('k') | lib/src/compiler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'utils.dart'; 10 import 'utils.dart';
11 11
12 /** 12 /**
13 * Header with common imports, used in every generated .dart file. If path is 13 * Header with common imports, used in every generated .dart file. If path is
14 * null then there is no file associated with the template (used by testing 14 * null then there is no file associated with the template (used by testing
15 * so we'll display <MEMORY> for file name. 15 * so we'll display <MEMORY> for file name.
16 */ 16 */
17 String header(Path path, String libraryName) => """ 17 String header(Path path, String libraryName) {
18 var library = libraryName != null ? '\nlibrary $libraryName;\n' : '';
19 return """
18 // Auto-generated from ${path != null ? path.filename : "<MEMORY>"}. 20 // Auto-generated from ${path != null ? path.filename : "<MEMORY>"}.
19 // DO NOT EDIT. 21 // DO NOT EDIT.
20 22 $library
21 library $libraryName;
22
23 $imports 23 $imports
24 """; 24 """;
25 }
25 26
26 // TODO(sigmund): include only those imports that are used by the code. 27 // TODO(sigmund): include only those imports that are used by the code.
27 String get imports => """ 28 String get imports => """
28 import 'dart:html' as autogenerated; 29 import 'dart:html' as autogenerated;
29 import 'dart:svg' as autogenerated_svg; 30 import 'dart:svg' as autogenerated_svg;
30 import 'package:web_ui/web_ui.dart' as autogenerated; 31 import 'package:web_ui/web_ui.dart' as autogenerated;
31 """; 32 """;
32 33
33 /** The code in .dart files generated for a web component. */ 34 /** The code in .dart files generated for a web component. */
34 // TODO(sigmund): omit [_root] if the user already defined it. 35 // TODO(sigmund): omit [_root] if the user already defined it.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 String importList(Iterable<Path> imports) => 122 String importList(Iterable<Path> imports) =>
122 imports.mappedBy((url) => "import '$url';").join('\n'); 123 imports.mappedBy((url) => "import '$url';").join('\n');
123 124
124 /** 125 /**
125 * Text corresponding to a directive, fixed in case the code is in a different 126 * Text corresponding to a directive, fixed in case the code is in a different
126 * output location. 127 * output location.
127 */ 128 */
128 String directiveText( 129 String directiveText(
129 DartDirectiveInfo directive, LibraryInfo src, PathInfo pathInfo) { 130 DartDirectiveInfo directive, LibraryInfo src, PathInfo pathInfo) {
130 var buff = new StringBuffer(); 131 var buff = new StringBuffer();
131 var uri = pathInfo.transformUrl(src.inputPath, directive.uri); 132 var uri = directive.uri;
133 if (!directive.generated) {
134 // This file was not generated, so get the relative path to the input file.
135 uri = pathInfo.transformUrl(src.inputPath, uri);
136 }
132 buff..add(directive.label) 137 buff..add(directive.label)
133 ..add(" '") 138 ..add(" '")
134 ..add(uri.replaceAll("'", "\\'")) 139 ..add(uri.replaceAll("'", "\\'"))
135 ..add("'"); 140 ..add("'");
136 if (directive.prefix != null) { 141 if (directive.prefix != null) {
137 buff..add(' as ') 142 buff..add(' as ')
138 ..add(directive.prefix); 143 ..add(directive.prefix);
139 } 144 }
140 if (directive.show != null) { 145 if (directive.show != null) {
141 buff..add(' show ') 146 buff..add(' show ')
142 ..add(Strings.join(directive.show, ',')); 147 ..add(Strings.join(directive.show, ','));
143 } 148 }
144 if (directive.hide != null) { 149 if (directive.hide != null) {
145 buff..add(' hide ') 150 buff..add(' hide ')
146 ..add(Strings.join(directive.hide, ',')); 151 ..add(Strings.join(directive.hide, ','));
147 } 152 }
148 buff.add(';'); 153 buff.add(';');
149 return buff.toString(); 154 return buff.toString();
150 } 155 }
OLDNEW
« 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