Skip to content

Commit 7788b63

Browse files
authored
split NestableDeclaration (#2466)
1 parent 16ae2d8 commit 7788b63

File tree

14 files changed

+34
-25
lines changed

14 files changed

+34
-25
lines changed

pkgs/swift2objc/lib/src/ast/_core/interfaces/compound_declaration.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ abstract interface class CompoundDeclaration
1818
Declaration,
1919
TypeParameterizable,
2020
ProtocolConformable,
21-
NestableDeclaration {
21+
OuterNestableDeclaration,
22+
InnerNestableDeclaration {
2223
abstract List<PropertyDeclaration> properties;
2324
abstract List<MethodDeclaration> methods;
2425
abstract List<InitializerDeclaration> initializers;

pkgs/swift2objc/lib/src/ast/_core/interfaces/enum_declaration.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ abstract interface class EnumDeclaration
1515
Declaration,
1616
TypeParameterizable,
1717
ProtocolConformable,
18-
NestableDeclaration {
18+
OuterNestableDeclaration,
19+
InnerNestableDeclaration {
1920
abstract List<EnumCase> cases;
2021
}
2122

pkgs/swift2objc/lib/src/ast/_core/interfaces/nestable_declaration.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@
55
import '../../ast_node.dart';
66
import 'declaration.dart';
77

8+
/// A Swift entity that can contain other declarations.
9+
abstract interface class OuterNestableDeclaration
10+
implements Declaration, AstNode {
11+
abstract final List<InnerNestableDeclaration> nestedDeclarations;
12+
}
13+
814
/// A Swift entity that can be nested inside other declarations.
9-
abstract interface class NestableDeclaration implements Declaration, AstNode {
10-
abstract NestableDeclaration? nestingParent;
11-
abstract final List<NestableDeclaration> nestedDeclarations;
15+
abstract interface class InnerNestableDeclaration
16+
implements Declaration, AstNode {
17+
abstract OuterNestableDeclaration? nestingParent;
1218
}
1319

14-
extension FillNestingParents on List<NestableDeclaration> {
15-
void fillNestingParents(NestableDeclaration parent) {
20+
extension FillNestingParents on List<InnerNestableDeclaration> {
21+
void fillNestingParents(OuterNestableDeclaration parent) {
1622
for (final nested in this) {
1723
assert(nested.nestingParent == null);
1824
nested.nestingParent = parent;

pkgs/swift2objc/lib/src/ast/_core/shared/referred_type.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DeclaredType<T extends Declaration> extends AstNode
3030

3131
String get name {
3232
final decl = declaration;
33-
final parent = decl is NestableDeclaration ? decl.nestingParent : null;
33+
final parent = decl is InnerNestableDeclaration ? decl.nestingParent : null;
3434
final nesting = parent != null ? '${parent.name}.' : '';
3535
return '$nesting${declaration.name}';
3636
}

pkgs/swift2objc/lib/src/ast/declarations/compounds/class_declaration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ class ClassDeclaration extends AstNode
5555
List<InitializerDeclaration> initializers;
5656

5757
@override
58-
NestableDeclaration? nestingParent;
58+
OuterNestableDeclaration? nestingParent;
5959

6060
@override
61-
List<NestableDeclaration> nestedDeclarations;
61+
List<InnerNestableDeclaration> nestedDeclarations;
6262

6363
ClassDeclaration({
6464
required this.id,

pkgs/swift2objc/lib/src/ast/declarations/compounds/protocol_declaration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class ProtocolDeclaration extends AstNode implements CompoundDeclaration {
3434
List<InitializerDeclaration> initializers;
3535

3636
@override
37-
NestableDeclaration? nestingParent;
37+
OuterNestableDeclaration? nestingParent;
3838

3939
@override
40-
List<NestableDeclaration> nestedDeclarations;
40+
List<InnerNestableDeclaration> nestedDeclarations;
4141

4242
ProtocolDeclaration({
4343
required this.id,

pkgs/swift2objc/lib/src/ast/declarations/compounds/struct_declaration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class StructDeclaration extends AstNode implements CompoundDeclaration {
3535
List<InitializerDeclaration> initializers;
3636

3737
@override
38-
NestableDeclaration? nestingParent;
38+
OuterNestableDeclaration? nestingParent;
3939

4040
@override
41-
List<NestableDeclaration> nestedDeclarations;
41+
List<InnerNestableDeclaration> nestedDeclarations;
4242

4343
StructDeclaration({
4444
required this.id,

pkgs/swift2objc/lib/src/ast/declarations/enums/associated_value_enum_declaration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class AssociatedValueEnumDeclaration extends AstNode
2929
List<DeclaredType<ProtocolDeclaration>> conformedProtocols;
3030

3131
@override
32-
NestableDeclaration? nestingParent;
32+
OuterNestableDeclaration? nestingParent;
3333

3434
@override
35-
List<NestableDeclaration> nestedDeclarations;
35+
List<InnerNestableDeclaration> nestedDeclarations;
3636

3737
AssociatedValueEnumDeclaration({
3838
required this.id,

pkgs/swift2objc/lib/src/ast/declarations/enums/normal_enum_declaration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class NormalEnumDeclaration extends AstNode implements EnumDeclaration {
2727
List<DeclaredType<ProtocolDeclaration>> conformedProtocols;
2828

2929
@override
30-
NestableDeclaration? nestingParent;
30+
OuterNestableDeclaration? nestingParent;
3131

3232
@override
33-
List<NestableDeclaration> nestedDeclarations;
33+
List<InnerNestableDeclaration> nestedDeclarations;
3434

3535
NormalEnumDeclaration({
3636
required this.id,

pkgs/swift2objc/lib/src/ast/declarations/enums/raw_value_enum_declaration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class RawValueEnumDeclaration<T> extends AstNode
3131
bool hasObjCAnnotation;
3232

3333
@override
34-
NestableDeclaration? nestingParent;
34+
OuterNestableDeclaration? nestingParent;
3535

3636
@override
37-
List<NestableDeclaration> nestedDeclarations;
37+
List<InnerNestableDeclaration> nestedDeclarations;
3838

3939
ReferredType rawValueType;
4040

0 commit comments

Comments
 (0)