Skip to content

Migrate various util and small libraries #2805

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
Sep 22, 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
2 changes: 0 additions & 2 deletions lib/src/generator/resource_loader.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

/// Make it possible to load resources from the dartdoc code repository.
library dartdoc.resource_loader;

Expand Down
20 changes: 9 additions & 11 deletions lib/src/generator/template_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// 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

import 'package:collection/collection.dart';
import 'package:dartdoc/src/model/model.dart';

typedef ContainerSidebar = String Function(
Expand Down Expand Up @@ -31,7 +30,7 @@ abstract class TemplateData<T extends Documentable> {

List<Documentable> get navLinks;
List<Container> get navLinksWithGenerics => [];
Documentable get parent {
Documentable? get parent {
if (navLinksWithGenerics.isEmpty) {
return navLinks.isNotEmpty ? navLinks.last : null;
}
Expand All @@ -42,7 +41,7 @@ abstract class TemplateData<T extends Documentable> {

bool get hasHomepage => false;

String get homepage => null;
String? get homepage => null;

String get htmlBase;
T get self;
Expand Down Expand Up @@ -212,10 +211,10 @@ class ClassTemplateData extends InheritingContainerTemplateData<Class> {
abstract class InheritingContainerTemplateData<T extends InheritingContainer>
extends TemplateData<T>
implements TemplateDataWithLibrary<T>, TemplateDataWithContainer<T> {
final InheritingContainer clazz;
final T clazz;
@override
final Library library;
Class _objectType;
Class? _objectType;
final LibrarySidebar _sidebarForLibrary;
final ContainerSidebar _sidebarForContainer;

Expand All @@ -236,8 +235,7 @@ abstract class InheritingContainerTemplateData<T extends InheritingContainer>

@override
T get self => clazz;
String get linkedObjectType =>
objectType == null ? 'Object' : objectType.linkedName;
String get linkedObjectType => objectType?.linkedName ?? 'Object';
@override
String get title =>
'${clazz.name} ${clazz.kind} - ${library.name} library - Dart API';
Expand All @@ -254,13 +252,13 @@ abstract class InheritingContainerTemplateData<T extends InheritingContainer>
@override
String get htmlBase => '../';

Class get objectType {
Class? get objectType {
if (_objectType != null) {
return _objectType;
return _objectType!;
}

var dc = _packageGraph.libraries
.firstWhere((it) => it.name == 'dart:core', orElse: () => null);
.firstWhereOrNull((it) => it.name == 'dart:core');

return _objectType = dc?.getClassByName('Object');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa, there is a way faster way to do this now (using Specials), but outside the scope of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha oh?

Copy link
Contributor

@jcollins-g jcollins-g Sep 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. _packageGraph.specialClasses[SpecialClass.object] should get you the right Object.

}
Expand Down
11 changes: 5 additions & 6 deletions lib/src/package_config_provider.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

import 'dart:io' as io;

import 'package:analyzer/file_system/file_system.dart';
Expand All @@ -14,12 +12,12 @@ import 'package:package_config/package_config.dart' as package_config;
/// This provides an abstraction around package_config, which can only work
/// with the physical file system.
abstract class PackageConfigProvider {
Future<package_config.PackageConfig> findPackageConfig(Folder dir);
Future<package_config.PackageConfig?> findPackageConfig(Folder dir);
}

class PhysicalPackageConfigProvider implements PackageConfigProvider {
@override
Future<package_config.PackageConfig> findPackageConfig(Folder dir) =>
Future<package_config.PackageConfig?> findPackageConfig(Folder dir) =>
package_config.findPackageConfig(io.Directory(dir.path));
}

Expand All @@ -35,8 +33,9 @@ class FakePackageConfigProvider implements PackageConfigProvider {

@override
Future<package_config.PackageConfig> findPackageConfig(Folder dir) async {
assert(_packageConfigData[dir.path] != null,
var packageConfig = _packageConfigData[dir.path];
assert(packageConfig != null,
'Package config data at ${dir.path} should not be null');
return package_config.PackageConfig(_packageConfigData[dir.path]);
return package_config.PackageConfig(packageConfig!);
}
}
2 changes: 0 additions & 2 deletions lib/src/quiver.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

/// Methods in-lined from package:quiver.

// From lib/iterables.dart:
Expand Down
2 changes: 0 additions & 2 deletions lib/src/tuple.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copied from source at github.com/kseo/tuple/blob/470ed3aeb/lib/src/tuple.dart

// @dart=2.9

// Original copyright:
// Copyright (c) 2014, the tuple project authors. Please see the AUTHORS
// file for details. All rights reserved. Use of this source code is governed
Expand Down