 Chromium Code Reviews
 Chromium Code Reviews Issue 1038063002:
  DDC fixes for path  (Closed) 
  Base URL: https://github.com/dart-lang/path.git@master
    
  
    Issue 1038063002:
  DDC fixes for path  (Closed) 
  Base URL: https://github.com/dart-lang/path.git@master| OLD | NEW | 
|---|---|
| 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 library path.context; | 5 library path.context; | 
| 6 | 6 | 
| 7 import 'internal_style.dart'; | 7 import 'internal_style.dart'; | 
| 8 import 'style.dart'; | 8 import 'style.dart'; | 
| 9 import 'parsed_path.dart'; | 9 import 'parsed_path.dart'; | 
| 10 import 'path_exception.dart'; | 10 import 'path_exception.dart'; | 
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 } | 33 } | 
| 34 } | 34 } | 
| 35 | 35 | 
| 36 if (style == null) { | 36 if (style == null) { | 
| 37 style = Style.platform; | 37 style = Style.platform; | 
| 38 } else if (style is! InternalStyle) { | 38 } else if (style is! InternalStyle) { | 
| 39 throw new ArgumentError("Only styles defined by the path package are " | 39 throw new ArgumentError("Only styles defined by the path package are " | 
| 40 "allowed."); | 40 "allowed."); | 
| 41 } | 41 } | 
| 42 | 42 | 
| 43 return new Context._(style, current); | 43 return new Context._(style, current); | 
| 
vsm
2015/03/26 19:33:31
Note, we get an implicit down cast warning on styl
 
Bob Nystrom
2015/03/27 20:23:13
Interesting. I'd be fine with explicit downcasting
 
vsm
2015/03/27 21:42:51
Done.
 | |
| 44 } | 44 } | 
| 45 | 45 | 
| 46 /// Create a [Context] to be used internally within path. | 46 /// Create a [Context] to be used internally within path. | 
| 47 Context._internal() | 47 Context._internal() | 
| 48 : style = Style.platform, | 48 : style = Style.platform, | 
| 
vsm
2015/03/26 19:33:31
Ditto as Style.platform is typed to return a Style
 
vsm
2015/03/27 21:42:51
Added explicit cast.
 | |
| 49 _current = null; | 49 _current = null; | 
| 50 | 50 | 
| 51 Context._(this.style, this._current); | 51 Context._(this.style, this._current); | 
| 52 | 52 | 
| 53 /// The style of path that this context works with. | 53 /// The style of path that this context works with. | 
| 54 final InternalStyle style; | 54 final InternalStyle style; | 
| 55 | 55 | 
| 56 /// The current directory given when Context was created. If null, current | 56 /// The current directory given when Context was created. If null, current | 
| 57 /// directory is evaluated from 'p.current'. | 57 /// directory is evaluated from 'p.current'. | 
| 58 final String _current; | 58 final String _current; | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 /// be added: | 190 /// be added: | 
| 191 /// | 191 /// | 
| 192 /// context.join('path/', 'to', 'foo'); // -> 'path/to/foo | 192 /// context.join('path/', 'to', 'foo'); // -> 'path/to/foo | 
| 193 /// | 193 /// | 
| 194 /// If a part is an absolute path, then anything before that will be ignored: | 194 /// If a part is an absolute path, then anything before that will be ignored: | 
| 195 /// | 195 /// | 
| 196 /// context.join('path', '/to', 'foo'); // -> '/to/foo' | 196 /// context.join('path', '/to', 'foo'); // -> '/to/foo' | 
| 197 /// | 197 /// | 
| 198 String join(String part1, [String part2, String part3, String part4, | 198 String join(String part1, [String part2, String part3, String part4, | 
| 199 String part5, String part6, String part7, String part8]) { | 199 String part5, String part6, String part7, String part8]) { | 
| 200 var parts = [part1, part2, part3, part4, part5, part6, part7, part8]; | 200 var parts = <String>[part1, part2, part3, part4, part5, part6, part7, part8] ; | 
| 
vsm
2015/03/26 19:33:31
Note: 
  List<String> parts = [ ... ]
would work a
 
Bob Nystrom
2015/03/27 20:24:04
I prefer how you did this.
 | |
| 201 _validateArgList("join", parts); | 201 _validateArgList("join", parts); | 
| 202 return joinAll(parts.where((part) => part != null)); | 202 return joinAll(parts.where((part) => part != null)); | 
| 203 } | 203 } | 
| 204 | 204 | 
| 205 /// Joins the given path parts into a single path. Example: | 205 /// Joins the given path parts into a single path. Example: | 
| 206 /// | 206 /// | 
| 207 /// context.joinAll(['path', 'to', 'foo']); // -> 'path/to/foo' | 207 /// context.joinAll(['path', 'to', 'foo']); // -> 'path/to/foo' | 
| 208 /// | 208 /// | 
| 209 /// If any part ends in a path separator, then a redundant separator will not | 209 /// If any part ends in a path separator, then a redundant separator will not | 
| 210 /// be added: | 210 /// be added: | 
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 var message = new StringBuffer(); | 556 var message = new StringBuffer(); | 
| 557 message.write("$method("); | 557 message.write("$method("); | 
| 558 message.write(args | 558 message.write(args | 
| 559 .take(numArgs) | 559 .take(numArgs) | 
| 560 .map((arg) => arg == null ? "null" : '"$arg"') | 560 .map((arg) => arg == null ? "null" : '"$arg"') | 
| 561 .join(", ")); | 561 .join(", ")); | 
| 562 message.write("): part ${i - 1} was null, but part $i was not."); | 562 message.write("): part ${i - 1} was null, but part $i was not."); | 
| 563 throw new ArgumentError(message.toString()); | 563 throw new ArgumentError(message.toString()); | 
| 564 } | 564 } | 
| 565 } | 565 } | 
| OLD | NEW |