Skip to content

Commit ae72b68

Browse files
authored
Merge pull request #2769 from jcollins-g/nnbd-mastermerge-0830
update nnbd branch from master
2 parents 056995d + acfcba2 commit ae72b68

32 files changed

+545
-1267
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
os: [ubuntu-latest]
22-
sdk: [dev]
22+
sdk: [dev, beta]
2323
job: [nnbd, flutter, sdk-analyzer, packages, sdk-docs]
2424
include:
2525
- os: macos-latest
@@ -32,9 +32,9 @@ jobs:
3232
# Do not try to run flutter against the "stable" sdk,
3333
# it is unlikely to work and produces uninteresting
3434
# results.
35-
- sdk: stable
35+
- sdk: beta
3636
job: flutter
37-
- sdk: stable
37+
- sdk: beta
3838
job: sdk-analyzer
3939

4040
steps:

lib/dartdoc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class Dartdoc {
264264
return dartdocResults;
265265
} finally {
266266
// Clear out any cached tool snapshots and temporary directories.
267-
SnapshotCache.instance?.dispose();
267+
SnapshotCache.instanceFor(config.resourceProvider).dispose();
268268
// ignore: unawaited_futures
269269
ToolTempFileTracker.instance?.dispose();
270270
}

lib/src/comment_references/model_comment_reference.dart

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ import 'package:analyzer/file_system/file_system.dart';
1111
import 'package:dartdoc/src/comment_references/parser.dart';
1212

1313
abstract class ModelCommentReference {
14-
/// Does the structure of the reference itself imply a possible default
14+
/// Does the structure of the reference itself imply a possible unnamed
1515
/// constructor?
16-
// TODO(jcollins-g): rewrite/discard this once default constructor tear-off
17-
// design process is complete.
18-
bool get allowDefaultConstructor;
19-
bool get allowDefaultConstructorParameter;
16+
bool get allowUnnamedConstructor;
17+
bool get allowUnnamedConstructorParameter;
2018
String get codeRef;
2119
bool get hasConstructorHint;
2220
bool get hasCallableHint;
@@ -37,42 +35,45 @@ abstract class ModelCommentReference {
3735
/// information needed for Dartdoc. Drops link to the [CommentReference]
3836
/// and [ResourceProvider] after construction.
3937
class _ModelCommentReferenceImpl implements ModelCommentReference {
40-
bool _allowDefaultConstructor;
38+
bool _allowUnnamedConstructor;
4139

4240
void _initAllowCache() {
4341
var referencePieces = parsed.whereType<IdentifierNode>().toList();
44-
_allowDefaultConstructor = false;
45-
_allowDefaultConstructorParameter = false;
42+
_allowUnnamedConstructor = false;
43+
_allowUnnamedConstructorParameter = false;
4644
if (referencePieces.length >= 2) {
4745
IdentifierNode nodeLast;
4846
for (var f in referencePieces) {
4947
if (f.text == nodeLast?.text) {
5048
if (identical(referencePieces.last, f)) {
51-
_allowDefaultConstructor = true;
49+
_allowUnnamedConstructor = true;
5250
} else {
53-
_allowDefaultConstructorParameter = true;
51+
_allowUnnamedConstructorParameter = true;
5452
}
5553
}
5654
nodeLast = f;
5755
}
56+
if (referencePieces.last.text == 'new') {
57+
_allowUnnamedConstructor = true;
58+
}
5859
}
5960
}
6061

6162
@override
62-
bool get allowDefaultConstructor {
63-
if (_allowDefaultConstructor == null) {
63+
bool get allowUnnamedConstructor {
64+
if (_allowUnnamedConstructor == null) {
6465
_initAllowCache();
6566
}
66-
return _allowDefaultConstructor;
67+
return _allowUnnamedConstructor;
6768
}
6869

69-
bool _allowDefaultConstructorParameter;
70+
bool _allowUnnamedConstructorParameter;
7071
@override
71-
bool get allowDefaultConstructorParameter {
72-
if (_allowDefaultConstructorParameter == null) {
72+
bool get allowUnnamedConstructorParameter {
73+
if (_allowUnnamedConstructorParameter == null) {
7374
_initAllowCache();
7475
}
75-
return _allowDefaultConstructorParameter;
76+
return _allowUnnamedConstructorParameter;
7677
}
7778

7879
@override

lib/src/dartdoc_options.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,9 +1240,6 @@ class DartdocOptionContext extends DartdocOptionContextBase
12401240
List<String> get excludePackages =>
12411241
optionSet['excludePackages'].valueAt(context);
12421242

1243-
bool get enhancedReferenceLookup =>
1244-
optionSet['enhancedReferenceLookup'].valueAt(context);
1245-
12461243
String get flutterRoot => optionSet['flutterRoot'].valueAt(context);
12471244

12481245
bool get hideSdkText => optionSet['hideSdkText'].valueAt(context);
@@ -1377,17 +1374,6 @@ Future<List<DartdocOption>> createDartdocOptions(
13771374
help: 'Library names to ignore.', splitCommas: true),
13781375
DartdocOptionArgOnly<List<String>>('excludePackages', [], resourceProvider,
13791376
help: 'Package names to ignore.', splitCommas: true),
1380-
DartdocOptionArgFile<bool>(
1381-
'enhancedReferenceLookup', true, resourceProvider,
1382-
hide: true,
1383-
help:
1384-
'Use the new comment reference lookup system instead of the legacy '
1385-
'version. Please file a bug referencing this flag if you have to '
1386-
'change it to false -- this flag and associated behavior will '
1387-
'disappear in a future version.',
1388-
negatable: true),
1389-
// This could be a ArgOnly, but trying to not provide too many ways
1390-
// to set the flutter root.
13911377
DartdocOptionSyntheticOnly<String?>('flutterRoot',
13921378
(DartdocSyntheticOption<String?> option, Folder dir) {
13931379
var envFlutterRoot = Platform.environment['FLUTTER_ROOT'];

lib/src/element_type.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class ElementType extends Privacy with CommentReferable, Nameable {
3333
f.element.kind == ElementKind.DYNAMIC ||
3434
f.element.kind == ElementKind.NEVER) {
3535
if (f is FunctionType) {
36-
if (f.aliasElement != null) {
36+
if (f.alias?.element != null) {
3737
return AliasedFunctionTypeElementType(
3838
f, library, packageGraph, returnedFrom);
3939
}
@@ -46,14 +46,14 @@ abstract class ElementType extends Privacy with CommentReferable, Nameable {
4646
// In that case it is an actual type alias of some kind (generic
4747
// or otherwise. Here however aliasElement signals that this is a
4848
// type referring to an alias.
49-
if (f is! TypeAliasElement && f.aliasElement != null) {
49+
if (f is! TypeAliasElement && f.alias?.element != null) {
5050
return AliasedElementType(
5151
f, library, packageGraph, element, returnedFrom);
5252
}
5353
assert(f is ParameterizedType || f is TypeParameterType);
5454
// TODO(jcollins-g): strip out all the cruft that's accumulated
5555
// here for non-generic type aliases.
56-
var isGenericTypeAlias = f.aliasElement != null && f is! InterfaceType;
56+
var isGenericTypeAlias = f.alias?.element != null && f is! InterfaceType;
5757
if (f is FunctionType) {
5858
assert(f is ParameterizedType);
5959
// This is an indication we have an extremely out of date analyzer....
@@ -190,8 +190,8 @@ class AliasedFunctionTypeElementType extends FunctionTypeElementType
190190
AliasedFunctionTypeElementType(FunctionType f, Library library,
191191
PackageGraph packageGraph, ElementType returnedFrom)
192192
: super(f, library, packageGraph, returnedFrom) {
193-
assert(type.aliasElement != null);
194-
assert(type.aliasArguments != null);
193+
assert(type.alias?.element != null);
194+
assert(type.alias?.typeArguments != null);
195195
}
196196

197197
@override
@@ -222,18 +222,18 @@ class ParameterizedElementType extends DefinedElementType with Rendered {
222222
/// A [ElementType] whose underlying type was referrred to by a type alias.
223223
mixin Aliased implements ElementType {
224224
@override
225-
String get name => type.aliasElement.name;
225+
String get name => type.alias.element.name;
226226

227227
@override
228228
bool get isTypedef => true;
229229

230230
ModelElement _aliasElement;
231231
ModelElement get aliasElement => _aliasElement ??=
232-
ModelElement.fromElement(type.aliasElement, packageGraph);
232+
ModelElement.fromElement(type.alias.element, packageGraph);
233233

234234
Iterable<ElementType> _aliasArguments;
235235
Iterable<ElementType> get aliasArguments =>
236-
_aliasArguments ??= type.aliasArguments
236+
_aliasArguments ??= type.alias.typeArguments
237237
.map((f) => ElementType.from(f, library, packageGraph))
238238
.toList(growable: false);
239239
}
@@ -242,7 +242,7 @@ class AliasedElementType extends ParameterizedElementType with Aliased {
242242
AliasedElementType(ParameterizedType type, Library library,
243243
PackageGraph packageGraph, ModelElement element, ElementType returnedFrom)
244244
: super(type, library, packageGraph, element, returnedFrom) {
245-
assert(type.aliasElement != null);
245+
assert(type.alias?.element != null);
246246
}
247247

248248
@override
@@ -431,7 +431,7 @@ class CallableElementType extends DefinedElementType with Rendered, Callable {
431431
Iterable<ElementType> _typeArguments;
432432
@override
433433
Iterable<ElementType> get typeArguments =>
434-
_typeArguments ??= (type.aliasArguments ?? [])
434+
_typeArguments ??= (type.alias?.typeArguments ?? [])
435435
.map((f) => ElementType.from(f, library, packageGraph))
436436
.toList(growable: false);
437437
}

lib/src/generator/templates.runtime_renderers.dart

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3358,20 +3358,6 @@ class _Renderer_Container extends RendererBase<Container> {
33583358
parent: r));
33593359
},
33603360
),
3361-
'allModelElementsByNamePart': Property(
3362-
getValue: (CT_ c) => c.allModelElementsByNamePart,
3363-
renderVariable: (CT_ c, Property<CT_> self,
3364-
List<String> remainingNames) =>
3365-
self.renderSimpleVariable(
3366-
c, remainingNames, 'Map<String, List<ModelElement>>'),
3367-
isNullValue: (CT_ c) => c.allModelElementsByNamePart == null,
3368-
renderValue: (CT_ c, RendererBase<CT_> r,
3369-
List<MustachioNode> ast, StringSink sink) {
3370-
renderSimple(
3371-
c.allModelElementsByNamePart, ast, r.template, sink,
3372-
parent: r, getters: _invisibleGetters['Map']);
3373-
},
3374-
),
33753361
'constantFields': Property(
33763362
getValue: (CT_ c) => c.constantFields,
33773363
renderVariable: (CT_ c, Property<CT_> self,
@@ -7461,19 +7447,6 @@ class _Renderer_Library extends RendererBase<Library> {
74617447
parent: r, getters: _invisibleGetters['HashMap']);
74627448
},
74637449
),
7464-
'modelElementsNameMap': Property(
7465-
getValue: (CT_ c) => c.modelElementsNameMap,
7466-
renderVariable: (CT_ c, Property<CT_> self,
7467-
List<String> remainingNames) =>
7468-
self.renderSimpleVariable(c, remainingNames,
7469-
'HashMap<String, Set<ModelElement>>'),
7470-
isNullValue: (CT_ c) => c.modelElementsNameMap == null,
7471-
renderValue: (CT_ c, RendererBase<CT_> r,
7472-
List<MustachioNode> ast, StringSink sink) {
7473-
renderSimple(c.modelElementsNameMap, ast, r.template, sink,
7474-
parent: r, getters: _invisibleGetters['HashMap']);
7475-
},
7476-
),
74777450
'name': Property(
74787451
getValue: (CT_ c) => c.name,
74797452
renderVariable:
@@ -14804,6 +14777,7 @@ const _invisibleGetters = {
1480414777
'DartType': {
1480514778
'hashCode',
1480614779
'runtimeType',
14780+
'alias',
1480714781
'aliasArguments',
1480814782
'aliasElement',
1480914783
'displayName',
@@ -14843,7 +14817,6 @@ const _invisibleGetters = {
1484314817
'dropTextFrom',
1484414818
'examplePathPrefix',
1484514819
'excludePackages',
14846-
'enhancedReferenceLookup',
1484714820
'flutterRoot',
1484814821
'hideSdkText',
1484914822
'include',
@@ -15113,6 +15086,7 @@ const _invisibleGetters = {
1511315086
'LibraryElement': {
1511415087
'hashCode',
1511515088
'runtimeType',
15089+
'accessibleExtensions',
1511615090
'definingCompilationUnit',
1511715091
'entryPoint',
1511815092
'exportedLibraries',
@@ -15240,7 +15214,6 @@ const _invisibleGetters = {
1524015214
'implementors',
1524115215
'documentedExtensions',
1524215216
'extensions',
15243-
'findRefElementCache',
1524415217
'defaultPackageName',
1524515218
'defaultPackage',
1524615219
'hasFooterVersion',

0 commit comments

Comments
 (0)