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

Side by Side Diff: lib/dartdoc/frog/world.dart

Issue 10559030: Remove uses of string + from API document generator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove process_test.cc changes. Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « lib/dartdoc/frog/parser.dart ('k') | utils/apidoc/html_diff.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 /** The one true [World]. */ 5 /** The one true [World]. */
6 World world; 6 World world;
7 7
8 /** 8 /**
9 * Experimental phase to enable await, only set when using the 9 * Experimental phase to enable await, only set when using the
10 * await/awaitc.dart entrypoint. 10 * await/awaitc.dart entrypoint.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 _topNames[name] = named; 277 _topNames[name] = named;
278 return; 278 return;
279 } 279 }
280 if (existing === named) { 280 if (existing === named) {
281 // This happens for a simple non-hidden native class where the native name 281 // This happens for a simple non-hidden native class where the native name
282 // is the same as the default jsname, e.g. class A native 'A' {}. 282 // is the same as the default jsname, e.g. class A native 'A' {}.
283 return; 283 return;
284 } 284 }
285 285
286 info('mangling matching top level name "${named.jsname}" in ' 286 info('mangling matching top level name "${named.jsname}" in '
287 + 'both "${named.library.jsname}" and "${existing.library.jsname}"'); 287 'both "${named.library.jsname}" and "${existing.library.jsname}"');
288 288
289 // resolve conflicts based on priority 289 // resolve conflicts based on priority
290 int existingPri = existing.jsnamePriority; 290 int existingPri = existing.jsnamePriority;
291 int namedPri = named.jsnamePriority; 291 int namedPri = named.jsnamePriority;
292 if (existingPri > namedPri || namedPri == 0) { 292 if (existingPri > namedPri || namedPri == 0) {
293 // Either existing was higher priority, or they're both 0 so first one 293 // Either existing was higher priority, or they're both 0 so first one
294 // wins. 294 // wins.
295 _renameJavascriptTopName(named); 295 _renameJavascriptTopName(named);
296 } else if (namedPri > existingPri) { 296 } else if (namedPri > existingPri) {
297 // New one takes priority over existing 297 // New one takes priority over existing
298 _renameJavascriptTopName(existing); 298 _renameJavascriptTopName(existing);
299 } else { 299 } else {
300 if (named.isNative) { 300 if (named.isNative) {
301 final msg = 'conflicting JS name "$name" of same ' 301 final msg = 'conflicting JS name "$name" of same '
302 + 'priority $existingPri: (already defined in) ' 302 'priority $existingPri: (already defined in) '
303 + '${existing.span.locationText} with priority $namedPri)'; 303 '${existing.span.locationText} with priority $namedPri)';
304 // We trust that conflicting native names in builtin libraries 304 // We trust that conflicting native names in builtin libraries
305 // are harmless. Most cases there are no conflicts, currently 305 // are harmless. Most cases there are no conflicts, currently
306 // isolates in coreimpl and dart:dom_deprecated both define 306 // isolates in coreimpl and dart:dom_deprecated both define
307 // web workers to avoid adding a dependency from corelib to 307 // web workers to avoid adding a dependency from corelib to
308 // dart:dom_deprecated. 308 // dart:dom_deprecated.
309 world.info(msg, named.span, existing.span); 309 world.info(msg, named.span, existing.span);
310 } else { 310 } else {
311 // Conflicting js name in same library. This happens because 311 // Conflicting js name in same library. This happens because
312 // of two different type arguments with the same name but in 312 // of two different type arguments with the same name but in
313 // different libraries. 313 // different libraries.
314 _renameJavascriptTopName(existing); 314 _renameJavascriptTopName(existing);
315 } 315 }
316 } 316 }
317 } 317 }
318 318
319 /** Renames an [Element] that had a name conflict in the generated JS. */ 319 /** Renames an [Element] that had a name conflict in the generated JS. */
320 _renameJavascriptTopName(Element named) { 320 _renameJavascriptTopName(Element named) {
321 named._jsname = '${named.library.jsname}_${named.jsname}'; 321 named._jsname = '${named.library.jsname}_${named.jsname}';
322 final existing = _topNames[named.jsname]; 322 final existing = _topNames[named.jsname];
323 if (existing != null && existing != named) { 323 if (existing != null && existing != named) {
324 // If this happens it means the library name wasn't unique enough. 324 // If this happens it means the library name wasn't unique enough.
325 world.internalError('name mangling failed for "${named.jsname}" ' 325 world.internalError('name mangling failed for "${named.jsname}" '
326 + '("${named.jsname}" defined also in ${existing.span.locationText})', 326 '("${named.jsname}" defined also in ${existing.span.locationText})',
327 named.span); 327 named.span);
328 } 328 }
329 _topNames[named.jsname] = named; 329 _topNames[named.jsname] = named;
330 } 330 }
331 331
332 _addType(Type type) { 332 _addType(Type type) {
333 // Top types don't have a name - we will capture their members in 333 // Top types don't have a name - we will capture their members in
334 // [_addMember]. 334 // [_addMember].
335 if (!type.isTop) _addTopName(type); 335 if (!type.isTop) _addTopName(type);
336 } 336 }
(...skipping 10 matching lines...) Expand all
347 _jsKeywords = new Set.from([ 347 _jsKeywords = new Set.from([
348 'break', 'case', 'catch', 'continue', 'debugger', 'default', 348 'break', 'case', 'catch', 'continue', 'debugger', 'default',
349 'delete', 'do', 'else', 'finally', 'for', 'function', 'if', 349 'delete', 'do', 'else', 'finally', 'for', 'function', 'if',
350 'in', 'instanceof', 'new', 'return', 'switch', 'this', 'throw', 350 'in', 'instanceof', 'new', 'return', 'switch', 'this', 'throw',
351 'try', 'typeof', 'var', 'void', 'while', 'with', 351 'try', 'typeof', 'var', 'void', 'while', 'with',
352 'class', 'enum', 'export', 'extends', 'import', 'super', 352 'class', 'enum', 'export', 'extends', 'import', 'super',
353 'implements', 'interface', 'let', 'package', 'private', 353 'implements', 'interface', 'let', 'package', 'private',
354 'protected', 'public', 'static', 'yield', 'native']); 354 'protected', 'public', 'static', 'yield', 'native']);
355 } 355 }
356 if (_jsKeywords.contains(name)) { 356 if (_jsKeywords.contains(name)) {
357 return name + '_'; 357 return '${name}_';
358 } else { 358 } else {
359 // regexs for better perf? 359 // regexs for better perf?
360 return name.replaceAll(@'$', @'$$').replaceAll(':', @'$'); 360 return name.replaceAll(@'$', @'$$').replaceAll(':', @'$');
361 } 361 }
362 } 362 }
363 363
364 /** 364 /**
365 * Runs the compiler and updates the output file. The output will either be 365 * Runs the compiler and updates the output file. The output will either be
366 * the program, or a file that throws an error when run. 366 * the program, or a file that throws an error when run.
367 */ 367 */
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // TODO(jimhug): Multiple spans cleaner... 600 // TODO(jimhug): Multiple spans cleaner...
601 messageHandler(prefix, message, span); 601 messageHandler(prefix, message, span);
602 if (span1 != null) { 602 if (span1 != null) {
603 messageHandler(prefix, message, span1); 603 messageHandler(prefix, message, span1);
604 } 604 }
605 if (span2 != null) { 605 if (span2 != null) {
606 messageHandler(prefix, message, span2); 606 messageHandler(prefix, message, span2);
607 } 607 }
608 } else { 608 } else {
609 final messageWithPrefix = options.useColors 609 final messageWithPrefix = options.useColors
610 ? (color + prefix + _NO_COLOR + message) : (prefix + message); 610 ? ('$color$prefix${_NO_COLOR}$message') : ('$prefix$message');
611 611
612 var text = messageWithPrefix; 612 var text = messageWithPrefix;
613 if (span != null) { 613 if (span != null) {
614 text = span.toMessageString(messageWithPrefix); 614 text = span.toMessageString(messageWithPrefix);
615 } 615 }
616 print(text); 616 print(text);
617 if (span1 != null) { 617 if (span1 != null) {
618 print(span1.toMessageString(messageWithPrefix)); 618 print(span1.toMessageString(messageWithPrefix));
619 } 619 }
620 if (span2 != null) { 620 if (span2 != null) {
621 print(span2.toMessageString(messageWithPrefix)); 621 print(span2.toMessageString(messageWithPrefix));
622 } 622 }
623 } 623 }
624 624
625 if (throwing) { 625 if (throwing) {
626 throw new CompilerException(prefix + message, span); 626 throw new CompilerException('$prefix$message', span);
627 } 627 }
628 } 628 }
629 629
630 /** [message] is considered a static compile-time error by the Dart lang. */ 630 /** [message] is considered a static compile-time error by the Dart lang. */
631 void error(String message, 631 void error(String message,
632 [SourceSpan span, SourceSpan span1, SourceSpan span2]) { 632 [SourceSpan span, SourceSpan span1, SourceSpan span2]) {
633 errors++; 633 errors++;
634 _message(_RED_COLOR, 'error: ', message, 634 _message(_RED_COLOR, 'error: ', message,
635 span, span1, span2, options.throwOnErrors); 635 span, span1, span2, options.throwOnErrors);
636 } 636 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 706
707 withTiming(String name, f()) { 707 withTiming(String name, f()) {
708 final sw = new Stopwatch(); 708 final sw = new Stopwatch();
709 sw.start(); 709 sw.start();
710 var result = f(); 710 var result = f();
711 sw.stop(); 711 sw.stop();
712 info('$name in ${sw.elapsedInMs()}msec'); 712 info('$name in ${sw.elapsedInMs()}msec');
713 return result; 713 return result;
714 } 714 }
715 } 715 }
OLDNEW
« no previous file with comments | « lib/dartdoc/frog/parser.dart ('k') | utils/apidoc/html_diff.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698