2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- // @dart=2.9
6
-
7
5
/// This is a helper library to make working with io easier.
8
6
library dartdoc.io_utils;
9
7
@@ -37,16 +35,16 @@ extension PathExtensions on path.Context {
37
35
/// Return a resolved path including the home directory in place of tilde
38
36
/// references.
39
37
String resolveTildePath (String originalPath) {
40
- if (originalPath == null || ! originalPath.startsWith ('~/' )) {
38
+ if (! originalPath.startsWith ('~/' )) {
41
39
return originalPath;
42
40
}
43
41
44
42
String homeDir;
45
43
46
44
if (io.Platform .isWindows) {
47
- homeDir = absolute (io.Platform .environment['USERPROFILE' ]);
45
+ homeDir = absolute (io.Platform .environment['USERPROFILE' ] ?? ' \' ' );
48
46
} else {
49
- homeDir = absolute (io.Platform .environment['HOME' ]);
47
+ homeDir = absolute (io.Platform .environment['HOME' ] ?? '/' );
50
48
}
51
49
52
50
return join (homeDir, originalPath.substring (2 ));
@@ -67,8 +65,7 @@ extension ResourceProviderExtensions on ResourceProvider {
67
65
if (this is PhysicalResourceProvider ) {
68
66
return io.Platform .resolvedExecutable;
69
67
} else {
70
- // TODO(srawlins): Return what is needed for tests.
71
- return null ;
68
+ throw UnimplementedError ('resolvedExecutable not implemented' );
72
69
}
73
70
}
74
71
@@ -77,8 +74,7 @@ extension ResourceProviderExtensions on ResourceProvider {
77
74
var mode = io.File (file.path).statSync ().mode;
78
75
return (0x1 & ((mode >> 6 ) | (mode >> 3 ) | mode)) != 0 ;
79
76
} else {
80
- // TODO(srawlins)
81
- return false ;
77
+ throw UnimplementedError ('isExecutable not implemented' );
82
78
}
83
79
}
84
80
@@ -124,8 +120,11 @@ final RegExp newLinePartOfRegexp = RegExp('\npart of ');
124
120
125
121
typedef TaskQueueClosure <T > = Future <T > Function ();
126
122
123
+ void _defaultOnComplete () {}
124
+
127
125
class _TaskQueueItem <T > {
128
- _TaskQueueItem (this ._closure, this ._completer, {this .onComplete});
126
+ _TaskQueueItem (this ._closure, this ._completer,
127
+ {this .onComplete = _defaultOnComplete});
129
128
130
129
final TaskQueueClosure <T > _closure;
131
130
final Completer <T > _completer;
@@ -137,7 +136,7 @@ class _TaskQueueItem<T> {
137
136
} catch (e) {
138
137
_completer.completeError (e);
139
138
} finally {
140
- onComplete? .call ();
139
+ onComplete.call ();
141
140
}
142
141
}
143
142
}
@@ -150,7 +149,7 @@ class TaskQueue<T> {
150
149
/// Creates a task queue with a maximum number of simultaneous jobs.
151
150
/// The [maxJobs] parameter defaults to the number of CPU cores on the
152
151
/// system.
153
- TaskQueue ({int maxJobs})
152
+ TaskQueue ({int ? maxJobs})
154
153
: maxJobs = maxJobs ?? io.Platform .numberOfProcessors;
155
154
156
155
/// The maximum number of jobs that this queue will run simultaneously.
0 commit comments