Skip to content

update nnbd branch from master #2769

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 13 commits into from
Aug 30, 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
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk: [dev]
sdk: [dev, beta]
job: [nnbd, flutter, sdk-analyzer, packages, sdk-docs]
include:
- os: macos-latest
Expand All @@ -32,9 +32,9 @@ jobs:
# Do not try to run flutter against the "stable" sdk,
# it is unlikely to work and produces uninteresting
# results.
- sdk: stable
- sdk: beta
job: flutter
- sdk: stable
- sdk: beta
job: sdk-analyzer

steps:
Expand Down
2 changes: 1 addition & 1 deletion lib/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class Dartdoc {
return dartdocResults;
} finally {
// Clear out any cached tool snapshots and temporary directories.
SnapshotCache.instance?.dispose();
SnapshotCache.instanceFor(config.resourceProvider).dispose();
// ignore: unawaited_futures
ToolTempFileTracker.instance?.dispose();
}
Expand Down
35 changes: 18 additions & 17 deletions lib/src/comment_references/model_comment_reference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import 'package:analyzer/file_system/file_system.dart';
import 'package:dartdoc/src/comment_references/parser.dart';

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

void _initAllowCache() {
var referencePieces = parsed.whereType<IdentifierNode>().toList();
_allowDefaultConstructor = false;
_allowDefaultConstructorParameter = false;
_allowUnnamedConstructor = false;
_allowUnnamedConstructorParameter = false;
if (referencePieces.length >= 2) {
IdentifierNode nodeLast;
for (var f in referencePieces) {
if (f.text == nodeLast?.text) {
if (identical(referencePieces.last, f)) {
_allowDefaultConstructor = true;
_allowUnnamedConstructor = true;
} else {
_allowDefaultConstructorParameter = true;
_allowUnnamedConstructorParameter = true;
}
}
nodeLast = f;
}
if (referencePieces.last.text == 'new') {
_allowUnnamedConstructor = true;
}
}
}

@override
bool get allowDefaultConstructor {
if (_allowDefaultConstructor == null) {
bool get allowUnnamedConstructor {
if (_allowUnnamedConstructor == null) {
_initAllowCache();
}
return _allowDefaultConstructor;
return _allowUnnamedConstructor;
}

bool _allowDefaultConstructorParameter;
bool _allowUnnamedConstructorParameter;
@override
bool get allowDefaultConstructorParameter {
if (_allowDefaultConstructorParameter == null) {
bool get allowUnnamedConstructorParameter {
if (_allowUnnamedConstructorParameter == null) {
_initAllowCache();
}
return _allowDefaultConstructorParameter;
return _allowUnnamedConstructorParameter;
}

@override
Expand Down
14 changes: 0 additions & 14 deletions lib/src/dartdoc_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1240,9 +1240,6 @@ class DartdocOptionContext extends DartdocOptionContextBase
List<String> get excludePackages =>
optionSet['excludePackages'].valueAt(context);

bool get enhancedReferenceLookup =>
optionSet['enhancedReferenceLookup'].valueAt(context);

String get flutterRoot => optionSet['flutterRoot'].valueAt(context);

bool get hideSdkText => optionSet['hideSdkText'].valueAt(context);
Expand Down Expand Up @@ -1377,17 +1374,6 @@ Future<List<DartdocOption>> createDartdocOptions(
help: 'Library names to ignore.', splitCommas: true),
DartdocOptionArgOnly<List<String>>('excludePackages', [], resourceProvider,
help: 'Package names to ignore.', splitCommas: true),
DartdocOptionArgFile<bool>(
'enhancedReferenceLookup', true, resourceProvider,
hide: true,
help:
'Use the new comment reference lookup system instead of the legacy '
'version. Please file a bug referencing this flag if you have to '
'change it to false -- this flag and associated behavior will '
'disappear in a future version.',
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) {
var envFlutterRoot = Platform.environment['FLUTTER_ROOT'];
Expand Down
20 changes: 10 additions & 10 deletions lib/src/element_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class ElementType extends Privacy with CommentReferable, Nameable {
f.element.kind == ElementKind.DYNAMIC ||
f.element.kind == ElementKind.NEVER) {
if (f is FunctionType) {
if (f.aliasElement != null) {
if (f.alias?.element != null) {
return AliasedFunctionTypeElementType(
f, library, packageGraph, returnedFrom);
}
Expand All @@ -46,14 +46,14 @@ abstract class ElementType extends Privacy with CommentReferable, Nameable {
// In that case it is an actual type alias of some kind (generic
// or otherwise. Here however aliasElement signals that this is a
// type referring to an alias.
if (f is! TypeAliasElement && f.aliasElement != null) {
if (f is! TypeAliasElement && f.alias?.element != null) {
return AliasedElementType(
f, library, packageGraph, element, returnedFrom);
}
assert(f is ParameterizedType || f is TypeParameterType);
// TODO(jcollins-g): strip out all the cruft that's accumulated
// here for non-generic type aliases.
var isGenericTypeAlias = f.aliasElement != null && f is! InterfaceType;
var isGenericTypeAlias = f.alias?.element != null && f is! InterfaceType;
if (f is FunctionType) {
assert(f is ParameterizedType);
// This is an indication we have an extremely out of date analyzer....
Expand Down Expand Up @@ -190,8 +190,8 @@ class AliasedFunctionTypeElementType extends FunctionTypeElementType
AliasedFunctionTypeElementType(FunctionType f, Library library,
PackageGraph packageGraph, ElementType returnedFrom)
: super(f, library, packageGraph, returnedFrom) {
assert(type.aliasElement != null);
assert(type.aliasArguments != null);
assert(type.alias?.element != null);
assert(type.alias?.typeArguments != null);
}

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

@override
bool get isTypedef => true;

ModelElement _aliasElement;
ModelElement get aliasElement => _aliasElement ??=
ModelElement.fromElement(type.aliasElement, packageGraph);
ModelElement.fromElement(type.alias.element, packageGraph);

Iterable<ElementType> _aliasArguments;
Iterable<ElementType> get aliasArguments =>
_aliasArguments ??= type.aliasArguments
_aliasArguments ??= type.alias.typeArguments
.map((f) => ElementType.from(f, library, packageGraph))
.toList(growable: false);
}
Expand All @@ -242,7 +242,7 @@ class AliasedElementType extends ParameterizedElementType with Aliased {
AliasedElementType(ParameterizedType type, Library library,
PackageGraph packageGraph, ModelElement element, ElementType returnedFrom)
: super(type, library, packageGraph, element, returnedFrom) {
assert(type.aliasElement != null);
assert(type.alias?.element != null);
}

@override
Expand Down Expand Up @@ -431,7 +431,7 @@ class CallableElementType extends DefinedElementType with Rendered, Callable {
Iterable<ElementType> _typeArguments;
@override
Iterable<ElementType> get typeArguments =>
_typeArguments ??= (type.aliasArguments ?? [])
_typeArguments ??= (type.alias?.typeArguments ?? [])
.map((f) => ElementType.from(f, library, packageGraph))
.toList(growable: false);
}
Expand Down
31 changes: 2 additions & 29 deletions lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3358,20 +3358,6 @@ class _Renderer_Container extends RendererBase<Container> {
parent: r));
},
),
'allModelElementsByNamePart': Property(
getValue: (CT_ c) => c.allModelElementsByNamePart,
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(
c, remainingNames, 'Map<String, List<ModelElement>>'),
isNullValue: (CT_ c) => c.allModelElementsByNamePart == null,
renderValue: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
renderSimple(
c.allModelElementsByNamePart, ast, r.template, sink,
parent: r, getters: _invisibleGetters['Map']);
},
),
'constantFields': Property(
getValue: (CT_ c) => c.constantFields,
renderVariable: (CT_ c, Property<CT_> self,
Expand Down Expand Up @@ -7461,19 +7447,6 @@ class _Renderer_Library extends RendererBase<Library> {
parent: r, getters: _invisibleGetters['HashMap']);
},
),
'modelElementsNameMap': Property(
getValue: (CT_ c) => c.modelElementsNameMap,
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(c, remainingNames,
'HashMap<String, Set<ModelElement>>'),
isNullValue: (CT_ c) => c.modelElementsNameMap == null,
renderValue: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
renderSimple(c.modelElementsNameMap, ast, r.template, sink,
parent: r, getters: _invisibleGetters['HashMap']);
},
),
'name': Property(
getValue: (CT_ c) => c.name,
renderVariable:
Expand Down Expand Up @@ -14804,6 +14777,7 @@ const _invisibleGetters = {
'DartType': {
'hashCode',
'runtimeType',
'alias',
'aliasArguments',
'aliasElement',
'displayName',
Expand Down Expand Up @@ -14843,7 +14817,6 @@ const _invisibleGetters = {
'dropTextFrom',
'examplePathPrefix',
'excludePackages',
'enhancedReferenceLookup',
'flutterRoot',
'hideSdkText',
'include',
Expand Down Expand Up @@ -15113,6 +15086,7 @@ const _invisibleGetters = {
'LibraryElement': {
'hashCode',
'runtimeType',
'accessibleExtensions',
'definingCompilationUnit',
'entryPoint',
'exportedLibraries',
Expand Down Expand Up @@ -15240,7 +15214,6 @@ const _invisibleGetters = {
'implementors',
'documentedExtensions',
'extensions',
'findRefElementCache',
'defaultPackageName',
'defaultPackage',
'hasFooterVersion',
Expand Down
Loading