22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- // @dart=2.9
6-
75/// This is a helper library to make working with io easier.
86library dartdoc.io_utils;
97
@@ -37,16 +35,16 @@ extension PathExtensions on path.Context {
3735 /// Return a resolved path including the home directory in place of tilde
3836 /// references.
3937 String resolveTildePath (String originalPath) {
40- if (originalPath == null || ! originalPath.startsWith ('~/' )) {
38+ if (! originalPath.startsWith ('~/' )) {
4139 return originalPath;
4240 }
4341
4442 String homeDir;
4543
4644 if (io.Platform .isWindows) {
47- homeDir = absolute (io.Platform .environment['USERPROFILE' ]);
45+ homeDir = absolute (io.Platform .environment['USERPROFILE' ] ?? ' \' ' );
4846 } else {
49- homeDir = absolute (io.Platform .environment['HOME' ]);
47+ homeDir = absolute (io.Platform .environment['HOME' ] ?? '/' );
5048 }
5149
5250 return join (homeDir, originalPath.substring (2 ));
@@ -67,8 +65,7 @@ extension ResourceProviderExtensions on ResourceProvider {
6765 if (this is PhysicalResourceProvider ) {
6866 return io.Platform .resolvedExecutable;
6967 } else {
70- // TODO(srawlins): Return what is needed for tests.
71- return null ;
68+ throw UnimplementedError ('resolvedExecutable not implemented' );
7269 }
7370 }
7471
@@ -77,8 +74,7 @@ extension ResourceProviderExtensions on ResourceProvider {
7774 var mode = io.File (file.path).statSync ().mode;
7875 return (0x1 & ((mode >> 6 ) | (mode >> 3 ) | mode)) != 0 ;
7976 } else {
80- // TODO(srawlins)
81- return false ;
77+ throw UnimplementedError ('isExecutable not implemented' );
8278 }
8379 }
8480
@@ -124,8 +120,11 @@ final RegExp newLinePartOfRegexp = RegExp('\npart of ');
124120
125121typedef TaskQueueClosure <T > = Future <T > Function ();
126122
123+ void _defaultOnComplete () {}
124+
127125class _TaskQueueItem <T > {
128- _TaskQueueItem (this ._closure, this ._completer, {this .onComplete});
126+ _TaskQueueItem (this ._closure, this ._completer,
127+ {this .onComplete = _defaultOnComplete});
129128
130129 final TaskQueueClosure <T > _closure;
131130 final Completer <T > _completer;
@@ -137,7 +136,7 @@ class _TaskQueueItem<T> {
137136 } catch (e) {
138137 _completer.completeError (e);
139138 } finally {
140- onComplete? .call ();
139+ onComplete.call ();
141140 }
142141 }
143142}
@@ -150,7 +149,7 @@ class TaskQueue<T> {
150149 /// Creates a task queue with a maximum number of simultaneous jobs.
151150 /// The [maxJobs] parameter defaults to the number of CPU cores on the
152151 /// system.
153- TaskQueue ({int maxJobs})
152+ TaskQueue ({int ? maxJobs})
154153 : maxJobs = maxJobs ?? io.Platform .numberOfProcessors;
155154
156155 /// The maximum number of jobs that this queue will run simultaneously.
0 commit comments