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

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

Issue 1038063002: DDC fixes for path (Closed) Base URL: https://github.com/dart-lang/path.git@master
Patch Set: Respond to comments Created 5 years, 9 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 | « CHANGELOG.md ('k') | lib/src/parsed_path.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) 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
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 as InternalStyle, current);
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 as InternalStyle,
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
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] ;
Bob Nystrom 2015/03/27 22:05:41 This is *just* a bit too long now, so you'll have
vsm 2015/03/27 22:30:01 Done.
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
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 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/parsed_path.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698