Skip to content

Commit dbbc79e

Browse files
authored
Convert options/logging libraries to null safety (#2748)
* Update analyzer version to 2.0.0 * grind build for analyzer 2 * First steps toward migrating * Start migrating some things around the edges and see what happens * Basic migration infrastruture for new NNBD branch * use separate workflow file for nnbd branch, for clarity * thinko * Switch to using CompilationUnitElement.classes (#2743) * Ignore null safe import warnings for presubmits * Prepare dartdoc_options for migration (#2745) * more specific imports in options * do not allow autoinitialization * dartfmt * parameterize the valueWithContext type * Use alternative constructors instead of externalizing, didn't realize the autodetect was so widely used * more subclasses * Empty commit to straighten out GitHub Actions * dartfmt
1 parent 50f38ec commit dbbc79e

File tree

4 files changed

+14
-26
lines changed

4 files changed

+14
-26
lines changed

analysis_options_presubmit.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ analyzer:
1010
### Extra ignores for presubmit
1111
deprecated_member_use: ignore
1212
deprecated_member_use_from_same_package: ignore
13+
### Temporary presubmit ignore for NNBD migration
14+
import_of_legacy_library_into_null_safe: ignore
1315
exclude:
1416
- 'doc/**'
1517
- 'lib/src/third_party/pkg/**'

lib/options.dart

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @dart=2.9
2-
31
import 'dart:io' show stderr, exitCode;
42

53
import 'package:analyzer/file_system/file_system.dart';
@@ -12,34 +10,24 @@ import 'package:dartdoc/src/package_meta.dart';
1210

1311
/// Helper class that consolidates option contexts for instantiating generators.
1412
class DartdocGeneratorOptionContext extends DartdocOptionContext {
15-
DartdocGeneratorOptionContext(
16-
DartdocOptionSet optionSet, Folder dir, ResourceProvider resourceProvider)
13+
DartdocGeneratorOptionContext(DartdocOptionSet optionSet, Folder? dir,
14+
ResourceProvider resourceProvider)
1715
: super(optionSet, dir, resourceProvider);
18-
1916
DartdocGeneratorOptionContext.fromDefaultContextLocation(
2017
DartdocOptionSet optionSet, ResourceProvider resourceProvider)
2118
: super.fromDefaultContextLocation(optionSet, resourceProvider);
2219

23-
// TODO(migration): Make late final with initializer when Null Safe.
24-
String _header;
25-
2620
/// Returns the joined contents of any 'header' files specified in options.
27-
String get header =>
28-
_header ??= _joinCustomTextFiles(optionSet['header'].valueAt(context));
29-
30-
// TODO(migration): Make late final with initializer when Null Safe.
31-
String _footer;
21+
late final String header =
22+
_joinCustomTextFiles(optionSet['header'].valueAt(context));
3223

3324
/// Returns the joined contents of any 'footer' files specified in options.
34-
String get footer =>
35-
_footer ??= _joinCustomTextFiles(optionSet['footer'].valueAt(context));
36-
37-
// TODO(migration): Make late final with initializer when Null Safe.
38-
String _footerText;
25+
late final String footer =
26+
_joinCustomTextFiles(optionSet['footer'].valueAt(context));
3927

4028
/// Returns the joined contents of any 'footer-text' files specified in
4129
/// options.
42-
String get footerText => _footerText ??=
30+
late final String footerText =
4331
_joinCustomTextFiles(optionSet['footerText'].valueAt(context));
4432

4533
String _joinCustomTextFiles(Iterable<String> paths) => paths
@@ -63,8 +51,8 @@ class DartdocGeneratorOptionContext extends DartdocOptionContext {
6351

6452
class DartdocProgramOptionContext extends DartdocGeneratorOptionContext
6553
with LoggingContext {
66-
DartdocProgramOptionContext(
67-
DartdocOptionSet optionSet, Folder dir, ResourceProvider resourceProvider)
54+
DartdocProgramOptionContext(DartdocOptionSet optionSet, Folder? dir,
55+
ResourceProvider resourceProvider)
6856
: super(optionSet, dir, resourceProvider);
6957
DartdocProgramOptionContext.fromDefaultContextLocation(
7058
DartdocOptionSet optionSet, ResourceProvider resourceProvider)
@@ -91,10 +79,10 @@ Future<List<DartdocOption<bool>>> createDartdocProgramOptions(
9179
];
9280
}
9381

94-
Future<DartdocProgramOptionContext> parseOptions(
82+
Future<DartdocProgramOptionContext?> parseOptions(
9583
PackageMetaProvider packageMetaProvider,
9684
List<String> arguments, {
97-
OptionGenerator additionalOptions,
85+
OptionGenerator? additionalOptions,
9886
}) async {
9987
var optionSet = await DartdocOptionSet.fromOptionGenerators(
10088
'dartdoc',

lib/src/logging.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
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
import 'dart:convert';
86
import 'dart:io' show stderr, stdout;
97

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
analyzer: ^2.0.0
1111
args: ^2.0.0
1212
charcode: ^1.2.0
13-
collection: ^1.15.0-nullsafety.4
13+
collection: ^1.15.0
1414
cli_util: ^0.3.0
1515
crypto: ^3.0.0
1616
glob: ^2.0.0

0 commit comments

Comments
 (0)