Skip to content
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

Drop support for final, interface, and sealed mixins #3369

Merged
merged 2 commits into from
Mar 21, 2023
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
3,346 changes: 1,669 additions & 1,677 deletions lib/resources/docs.dart.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions lib/resources/docs.dart.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/src/element_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class UndefinedElementType extends ElementType {

@override
String get name {
if (type.isVoid) return 'void';
if (type is VoidType) return 'void';
if (type.isDynamic) return 'dynamic';
assert(const {'Never'}.contains(typeElement!.name),
'Unrecognized type for UndefinedElementType: ${type.toString()}');
Expand Down Expand Up @@ -436,7 +436,7 @@ class GenericTypeAliasElementType extends TypeParameterElementType {
extension on DartType {
/// The dartdoc nullability suffix for this type in [library].
String nullabilitySuffixWithin(Library library) {
if (!isVoid && !isBottom) {
if (this is! VoidType && !isBottom) {
/// If a legacy type appears inside the public interface of a Null
/// safety library, we pretend it is nullable for the purpose of
/// documentation (since star-types are not supposed to be public).
Expand Down
4 changes: 4 additions & 0 deletions lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15982,6 +15982,7 @@ const _invisibleGetters = {
'nonSynthetic',
'runtimeType',
'session',
'sinceSdkVersion',
'source'
},
'ElementAnnotation': {
Expand Down Expand Up @@ -16074,6 +16075,7 @@ const _invisibleGetters = {
'returnType',
'runtimeType',
'session',
'sinceSdkVersion',
'substitution',
'type',
'typeParameters'
Expand Down Expand Up @@ -16314,6 +16316,7 @@ const _invisibleGetters = {
'nonSynthetic',
'runtimeType',
'session',
'sinceSdkVersion',
'substitution'
},
'MethodElement': {'augmentation', 'declaration', 'hashCode', 'runtimeType'},
Expand Down Expand Up @@ -16483,6 +16486,7 @@ const _invisibleGetters = {
'parameters',
'runtimeType',
'session',
'sinceSdkVersion',
'source',
'substitution',
'type',
Expand Down
5 changes: 3 additions & 2 deletions lib/src/model/extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:dartdoc/src/element_type.dart';
import 'package:dartdoc/src/model/comment_referable.dart';
import 'package:dartdoc/src/model/extension_target.dart';
Expand All @@ -23,7 +24,7 @@ class Extension extends Container implements EnclosedElement {
/// Detect if this extension applies to every object.
bool get alwaysApplies =>
extendedType.instantiatedType.isDynamic ||
extendedType.instantiatedType.isVoid ||
extendedType.instantiatedType is VoidType ||
extendedType.instantiatedType.isDartCoreObject;

bool couldApplyTo<T extends ExtensionTarget>(T c) =>
Expand All @@ -32,7 +33,7 @@ class Extension extends Container implements EnclosedElement {
/// Whether this extension could apply to [type].
bool _couldApplyTo(DefinedElementType type) {
if (extendedType.instantiatedType.isDynamic ||
extendedType.instantiatedType.isVoid) {
extendedType.instantiatedType is VoidType) {
return true;
}
var typeInstantiated = type.instantiatedType;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/model/mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ class Mixin extends InheritingContainer with TypeImplementing {
bool get isBase => element.isBase;

@override
bool get isFinal => element.isFinal;
bool get isFinal => false;

@override
bool get isInterface => element.isInterface;
bool get isInterface => false;

@override

/// Mixins are not mixin classes by definition.
bool get isMixinClass => false;

@override
bool get isSealed => element.isSealed;
bool get isSealed => false;

@override
String get kind => 'mixin';
Expand Down
9 changes: 0 additions & 9 deletions test/class_modifiers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ abstract mixin class L {}
abstract base mixin class M {}
mixin N {}
base mixin O {}
interface mixin P {}
final mixin Q {}
sealed mixin R {}
''');
// This almost seems worth a map and loop, but leaving expanded for now for
// test clarity.
Expand All @@ -66,9 +63,6 @@ sealed mixin R {}
var Mclass = library.classes.named('M');
var Nmixin = library.mixins.named('N');
var Omixin = library.mixins.named('O');
var Pmixin = library.mixins.named('P');
var Qmixin = library.mixins.named('Q');
var Rmixin = library.mixins.named('R');
expect(Aclass.fullkind, equals('class'));
expect(Bclass.fullkind, equals('base class'));
expect(Cclass.fullkind, equals('interface class'));
Expand All @@ -84,8 +78,5 @@ sealed mixin R {}
expect(Mclass.fullkind, equals('abstract base mixin class'));
expect(Nmixin.fullkind, equals('mixin'));
expect(Omixin.fullkind, equals('base mixin'));
expect(Pmixin.fullkind, equals('interface mixin'));
expect(Qmixin.fullkind, equals('final mixin'));
expect(Rmixin.fullkind, equals('sealed mixin'));
}
}