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

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

Issue 1064273002: pkg/path: Add type annotations to top-level and static fields. (Closed) Base URL: https://github.com/dart-lang/path.git@master
Patch Set: version nits Created 5 years, 8 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/path.dart ('k') | pubspec.yaml » ('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.style; 5 library path.style;
6 6
7 import 'context.dart'; 7 import 'context.dart';
8 import 'style/posix.dart'; 8 import 'style/posix.dart';
9 import 'style/url.dart'; 9 import 'style/url.dart';
10 import 'style/windows.dart'; 10 import 'style/windows.dart';
11 11
12 /// An enum type describing a "flavor" of path. 12 /// An enum type describing a "flavor" of path.
13 abstract class Style { 13 abstract class Style {
14 /// POSIX-style paths use "/" (forward slash) as separators. Absolute paths 14 /// POSIX-style paths use "/" (forward slash) as separators. Absolute paths
15 /// start with "/". Used by UNIX, Linux, Mac OS X, and others. 15 /// start with "/". Used by UNIX, Linux, Mac OS X, and others.
16 static final posix = new PosixStyle(); 16 static final Style posix = new PosixStyle();
17 17
18 /// Windows paths use "\" (backslash) as separators. Absolute paths start with 18 /// Windows paths use "\" (backslash) as separators. Absolute paths start with
19 /// a drive letter followed by a colon (example, "C:") or two backslashes 19 /// a drive letter followed by a colon (example, "C:") or two backslashes
20 /// ("\\") for UNC paths. 20 /// ("\\") for UNC paths.
21 // TODO(rnystrom): The UNC root prefix should include the drive name too, not 21 // TODO(rnystrom): The UNC root prefix should include the drive name too, not
22 // just the "\\". 22 // just the "\\".
23 static final windows = new WindowsStyle(); 23 static final Style windows = new WindowsStyle();
24 24
25 /// URLs aren't filesystem paths, but they're supported to make it easier to 25 /// URLs aren't filesystem paths, but they're supported to make it easier to
26 /// manipulate URL paths in the browser. 26 /// manipulate URL paths in the browser.
27 /// 27 ///
28 /// URLs use "/" (forward slash) as separators. Absolute paths either start 28 /// URLs use "/" (forward slash) as separators. Absolute paths either start
29 /// with a protocol and optional hostname (e.g. `http://dartlang.org`, 29 /// with a protocol and optional hostname (e.g. `http://dartlang.org`,
30 /// `file://`) or with "/". 30 /// `file://`) or with "/".
31 static final url = new UrlStyle(); 31 static final Style url = new UrlStyle();
32 32
33 /// The style of the host platform. 33 /// The style of the host platform.
34 /// 34 ///
35 /// When running on the command line, this will be [windows] or [posix] based 35 /// When running on the command line, this will be [windows] or [posix] based
36 /// on the host operating system. On a browser, this will be [url]. 36 /// on the host operating system. On a browser, this will be [url].
37 static final platform = _getPlatformStyle(); 37 static final Style platform = _getPlatformStyle();
38 38
39 /// Gets the type of the host platform. 39 /// Gets the type of the host platform.
40 static Style _getPlatformStyle() { 40 static Style _getPlatformStyle() {
41 // If we're running a Dart file in the browser from a `file:` URI, 41 // If we're running a Dart file in the browser from a `file:` URI,
42 // [Uri.base] will point to a file. If we're running on the standalone, 42 // [Uri.base] will point to a file. If we're running on the standalone,
43 // it will point to a directory. We can use that fact to determine which 43 // it will point to a directory. We can use that fact to determine which
44 // style to use. 44 // style to use.
45 if (Uri.base.scheme != 'file') return Style.url; 45 if (Uri.base.scheme != 'file') return Style.url;
46 if (!Uri.base.path.endsWith('/')) return Style.url; 46 if (!Uri.base.path.endsWith('/')) return Style.url;
47 if (new Uri(path: 'a/b').toFilePath() == 'a\\b') return Style.windows; 47 if (new Uri(path: 'a/b').toFilePath() == 'a\\b') return Style.windows;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 String pathFromUri(Uri uri); 79 String pathFromUri(Uri uri);
80 80
81 @Deprecated("Most style members will be removed in path 2.0.") 81 @Deprecated("Most style members will be removed in path 2.0.")
82 Uri relativePathToUri(String path); 82 Uri relativePathToUri(String path);
83 83
84 @Deprecated("Most style members will be removed in path 2.0.") 84 @Deprecated("Most style members will be removed in path 2.0.")
85 Uri absolutePathToUri(String path); 85 Uri absolutePathToUri(String path);
86 86
87 String toString() => name; 87 String toString() => name;
88 } 88 }
OLDNEW
« no previous file with comments | « lib/path.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698