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

Side by Side Diff: pkg/polymer/lib/src/loader.dart

Issue 68103005: Use logger for polymer loader warning (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of polymer; 5 part of polymer;
6 6
7 /** Annotation used to automatically register polymer elements. */ 7 /** Annotation used to automatically register polymer elements. */
8 class CustomTag { 8 class CustomTag {
9 final String tagName; 9 final String tagName;
10 const CustomTag(this.tagName); 10 const CustomTag(this.tagName);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 /** All libraries in the current isolate. */ 134 /** All libraries in the current isolate. */
135 final _libs = currentMirrorSystem().libraries; 135 final _libs = currentMirrorSystem().libraries;
136 136
137 // TODO(sigmund): explore other (cheaper) ways to resolve URIs relative to the 137 // TODO(sigmund): explore other (cheaper) ways to resolve URIs relative to the
138 // root library (see dartbug.com/12612) 138 // root library (see dartbug.com/12612)
139 final _rootUri = currentMirrorSystem().isolate.rootLibrary.uri; 139 final _rootUri = currentMirrorSystem().isolate.rootLibrary.uri;
140 140
141 final String _packageRoot = 141 final String _packageRoot =
142 '${path.dirname(Uri.parse(window.location.href).path)}/packages/'; 142 '${path.dirname(Uri.parse(window.location.href).path)}/packages/';
143 143
144 final Logger _loaderLog = new Logger('polymer.loader');
145
144 /** 146 /**
145 * Reads the library at [uriString] (which can be an absolute URI or a relative 147 * Reads the library at [uriString] (which can be an absolute URI or a relative
146 * URI from the root library), and: 148 * URI from the root library), and:
147 * 149 *
148 * * If present, invokes any top-level and static functions marked 150 * * If present, invokes any top-level and static functions marked
149 * with the [initMethod] annotation (in the order they appear). 151 * with the [initMethod] annotation (in the order they appear).
150 * 152 *
151 * * Registers any [PolymerElement] that is marked with the [CustomTag] 153 * * Registers any [PolymerElement] that is marked with the [CustomTag]
152 * annotation. 154 * annotation.
153 */ 155 */
154 void _loadLibrary(String uriString) { 156 void _loadLibrary(String uriString) {
155 var uri = _rootUri.resolve(uriString); 157 var uri = _rootUri.resolve(uriString);
156 var lib = _libs[uri]; 158 var lib = _libs[uri];
157 if (uri.path.startsWith(_packageRoot) && uri.path.endsWith('.dart')) { 159 if (uri.path.startsWith(_packageRoot) && uri.path.endsWith('.dart')) {
158 var packageUri = 160 var packageUri =
159 Uri.parse('package:${uri.path.substring(_packageRoot.length)}'); 161 Uri.parse('package:${uri.path.substring(_packageRoot.length)}');
160 var canonicalLib = _libs[packageUri]; 162 var canonicalLib = _libs[packageUri];
161 if (canonicalLib != null) { 163 if (canonicalLib != null) {
162 lib = canonicalLib; 164 lib = canonicalLib;
163 } 165 }
164 } 166 }
165 167
166 if (lib == null) { 168 if (lib == null) {
167 print('warning: $uri library not found'); 169 _loaderLog.info('$uri library not found');
168 return; 170 return;
169 } 171 }
170 172
171 // Search top-level functions marked with @initMethod 173 // Search top-level functions marked with @initMethod
172 for (var f in lib.functions.values) { 174 for (var f in lib.functions.values) {
173 _maybeInvoke(lib, f); 175 _maybeInvoke(lib, f);
174 } 176 }
175 177
176 for (var c in lib.classes.values) { 178 for (var c in lib.classes.values) {
177 // Search for @CustomTag on classes 179 // Search for @CustomTag on classes
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 print("warning: methods marked with @initMethod should take no " 211 print("warning: methods marked with @initMethod should take no "
210 "arguments, ${method.simpleName} expects some."); 212 "arguments, ${method.simpleName} expects some.");
211 return; 213 return;
212 } 214 }
213 obj.invoke(method.simpleName, const []); 215 obj.invoke(method.simpleName, const []);
214 } 216 }
215 217
216 class _InitMethodAnnotation { 218 class _InitMethodAnnotation {
217 const _InitMethodAnnotation(); 219 const _InitMethodAnnotation();
218 } 220 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698