Skip to content

Migrate package_meta, io_utils, and utils. #2760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/src/dartdoc_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1388,12 +1388,12 @@ Future<List<DartdocOption>> createDartdocOptions(
negatable: true),
// This could be a ArgOnly, but trying to not provide too many ways
// to set the flutter root.
DartdocOptionSyntheticOnly<String>(
'flutterRoot',
(DartdocSyntheticOption<String> option, Folder dir) => resourceProvider
.pathContext
.resolveTildePath(Platform.environment['FLUTTER_ROOT']),
resourceProvider,
DartdocOptionSyntheticOnly<String?>('flutterRoot',
(DartdocSyntheticOption<String?> option, Folder dir) {
var envFlutterRoot = Platform.environment['FLUTTER_ROOT'];
if (envFlutterRoot == null) return null;
return resourceProvider.pathContext.resolveTildePath(envFlutterRoot);
}, resourceProvider,
optionIs: OptionKind.dir,
help: 'Root of the Flutter SDK, specified from environment.',
mustExist: true),
Expand Down
23 changes: 11 additions & 12 deletions lib/src/io_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

/// This is a helper library to make working with io easier.
library dartdoc.io_utils;

Expand Down Expand Up @@ -37,16 +35,16 @@ extension PathExtensions on path.Context {
/// Return a resolved path including the home directory in place of tilde
/// references.
String resolveTildePath(String originalPath) {
if (originalPath == null || !originalPath.startsWith('~/')) {
if (!originalPath.startsWith('~/')) {
return originalPath;
}

String homeDir;

if (io.Platform.isWindows) {
homeDir = absolute(io.Platform.environment['USERPROFILE']);
homeDir = absolute(io.Platform.environment['USERPROFILE'] ?? '\'');
} else {
homeDir = absolute(io.Platform.environment['HOME']);
homeDir = absolute(io.Platform.environment['HOME'] ?? '/');
}

return join(homeDir, originalPath.substring(2));
Expand All @@ -67,8 +65,7 @@ extension ResourceProviderExtensions on ResourceProvider {
if (this is PhysicalResourceProvider) {
return io.Platform.resolvedExecutable;
} else {
// TODO(srawlins): Return what is needed for tests.
return null;
throw UnimplementedError('resolvedExecutable not implemented');
}
}

Expand All @@ -77,8 +74,7 @@ extension ResourceProviderExtensions on ResourceProvider {
var mode = io.File(file.path).statSync().mode;
return (0x1 & ((mode >> 6) | (mode >> 3) | mode)) != 0;
} else {
// TODO(srawlins)
return false;
throw UnimplementedError('isExecutable not implemented');
}
}

Expand Down Expand Up @@ -124,8 +120,11 @@ final RegExp newLinePartOfRegexp = RegExp('\npart of ');

typedef TaskQueueClosure<T> = Future<T> Function();

void _defaultOnComplete() {}

class _TaskQueueItem<T> {
_TaskQueueItem(this._closure, this._completer, {this.onComplete});
_TaskQueueItem(this._closure, this._completer,
{this.onComplete = _defaultOnComplete});

final TaskQueueClosure<T> _closure;
final Completer<T> _completer;
Expand All @@ -137,7 +136,7 @@ class _TaskQueueItem<T> {
} catch (e) {
_completer.completeError(e);
} finally {
onComplete?.call();
onComplete.call();
}
}
}
Expand All @@ -150,7 +149,7 @@ class TaskQueue<T> {
/// Creates a task queue with a maximum number of simultaneous jobs.
/// The [maxJobs] parameter defaults to the number of CPU cores on the
/// system.
TaskQueue({int maxJobs})
TaskQueue({int? maxJobs})
: maxJobs = maxJobs ?? io.Platform.numberOfProcessors;

/// The maximum number of jobs that this queue will run simultaneously.
Expand Down
12 changes: 9 additions & 3 deletions lib/src/model/accessor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Accessor extends ModelElement implements EnclosedElement {

@override
String computeDocumentationComment() {
String docComment;
if (isSynthetic) {
// If we're a setter, only display something if we have something different than the getter.
// TODO(jcollins-g): modify analyzer to do this itself?
Expand All @@ -85,12 +86,17 @@ class Accessor extends ModelElement implements EnclosedElement {
definingCombo.hasGetter &&
definingCombo.getter.documentationComment !=
definingCombo.documentationComment)) {
return stripComments(definingCombo.documentationComment);
docComment = definingCombo.documentationComment;
} else {
return '';
docComment = '';
}
} else {
docComment = super.computeDocumentationComment();
}
if (docComment != null) {
return stripComments(docComment);
}
return stripComments(super.computeDocumentationComment());
return null;
}

@override
Expand Down
Loading