|
| 1 | +// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file |
| 2 | +// for details. All rights reserved. Use of this source code is governed by a |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +import 'package:built_collection/built_collection.dart'; |
| 6 | +import 'package:built_value/built_value.dart'; |
| 7 | +import 'package:meta/meta.dart'; |
| 8 | + |
| 9 | +import '../base.dart'; |
| 10 | +import '../mixins/annotations.dart'; |
| 11 | +import '../mixins/dartdoc.dart'; |
| 12 | +import '../visitors.dart'; |
| 13 | +import 'expression.dart'; |
| 14 | + |
| 15 | +part 'typedef.g.dart'; |
| 16 | + |
| 17 | +@immutable |
| 18 | +abstract class TypeDef extends Object |
| 19 | + with HasAnnotations, HasDartDocs |
| 20 | + implements Built<TypeDef, TypeDefBuilder>, Spec { |
| 21 | + factory TypeDef([void Function(TypeDefBuilder)? updates]) = _$TypeDef; |
| 22 | + |
| 23 | + TypeDef._(); |
| 24 | + |
| 25 | + /// Name of the typedef. |
| 26 | + String get name; |
| 27 | + |
| 28 | + /// The right hand side of the typedef. |
| 29 | + /// |
| 30 | + /// Typically a reference to a type, or a Function type. |
| 31 | + Expression get definition; |
| 32 | + |
| 33 | + @override |
| 34 | + R accept<R>( |
| 35 | + SpecVisitor<R> visitor, [ |
| 36 | + R? context, |
| 37 | + ]) => |
| 38 | + visitor.visitTypeDef(this, context); |
| 39 | +} |
| 40 | + |
| 41 | +abstract class TypeDefBuilder extends Object |
| 42 | + with HasAnnotationsBuilder, HasDartDocsBuilder |
| 43 | + implements Builder<TypeDef, TypeDefBuilder> { |
| 44 | + factory TypeDefBuilder() = _$TypeDefBuilder; |
| 45 | + |
| 46 | + TypeDefBuilder._(); |
| 47 | + |
| 48 | + @override |
| 49 | + ListBuilder<Expression> annotations = ListBuilder<Expression>(); |
| 50 | + |
| 51 | + @override |
| 52 | + ListBuilder<String> docs = ListBuilder<String>(); |
| 53 | + |
| 54 | + String? name; |
| 55 | + |
| 56 | + Expression? definition; |
| 57 | +} |
0 commit comments