Skip to content

Commit acf7d21

Browse files
authored
Naming improvements in Swiftgen models & interfaces (#1197)
* improve naming of AST models & interfaces * add a description of DeclaredType and GenericType
1 parent 58d6944 commit acf7d21

13 files changed

+46
-43
lines changed

pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/compund_declaration.dart renamed to pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/compound_declaration.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'confomingable.dart';
5+
import 'protocol_conformable.dart';
66
import 'declaration.dart';
7-
import 'genericable.dart';
7+
import 'type_parameterizable.dart';
88
import '../shared/referred_type.dart';
9-
import 'paramable.dart';
9+
import 'parameterizable.dart';
1010

1111
/// An interface for the declaration of all compound Swift entities. See `ClassDeclaration`,
1212
/// `StructDeclaration` and `ProtocolDeclaration` for concrete implementations.
1313
abstract interface class CompoundDeclaration
14-
implements Declaration, Genericable, Conformingable {
14+
implements Declaration, TypeParameterizable, ProtocolConformable {
1515
abstract List<CompoundPropertyDeclaration> properties;
1616
abstract List<CompoundMethodDeclaration> methods;
1717
}
@@ -26,6 +26,6 @@ abstract interface class CompoundPropertyDeclaration implements Declaration {
2626
/// An interface for a compound method. See `ClassMethodDeclaration`,
2727
/// `StructMethodDeclaration` and `ProtocolMethodDeclaration` for concrete implementations.
2828
abstract interface class CompoundMethodDeclaration
29-
implements Declaration, Genericable, Paramable {
29+
implements Declaration, TypeParameterizable, Parameterizable {
3030
abstract ReferredType returnType;
3131
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'confomingable.dart';
5+
import 'protocol_conformable.dart';
66
import 'declaration.dart';
7-
import 'genericable.dart';
7+
import 'type_parameterizable.dart';
88

99
/// An interface for describing the declaration of a Swift enum. See `NormalEnumDeclaration`,
1010
/// `AssociatedValueEnumDeclaration` and `RawValueEnumDeclaration` for concrete implementations.
1111
abstract interface class EnumDeclaration
12-
implements Declaration, Genericable, Conformingable {
12+
implements Declaration, TypeParameterizable, ProtocolConformable {
1313
abstract List<EnumCase> cases;
1414
}
1515

pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/paramable.dart renamed to pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/parameterizable.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
import '../shared/parameter.dart';
66

77
/// An interface to describe a Swift entity's ability to have parameters (e.g functions).
8-
abstract interface class Paramable {
8+
abstract interface class Parameterizable {
99
abstract List<Parameter> params;
1010
}

pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/confomingable.dart renamed to pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/protocol_conformable.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import '../../declarations/compounds/protocol_declaration.dart';
66
import '../shared/referred_type.dart';
77

88
/// An interface to describe a Swift entity's ability to confom to protocols.
9-
abstract interface class Conformingable {
9+
abstract interface class ProtocolConformable {
1010
abstract List<DeclaredType<ProtocolDeclaration>> conformedProtocols;
1111
}

pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/genericable.dart renamed to pkgs/swiftgen/swift2objc/lib/src/ast/_core/interfaces/type_parameterizable.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
import '../shared/referred_type.dart';
66

77
/// An interface to describe a Swift entity's ability to have generic parameters.
8-
abstract interface class Genericable {
9-
abstract List<GenericType> genericParams;
8+
abstract interface class TypeParameterizable {
9+
abstract List<GenericType> typeParams;
1010
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@
44

55
import '../interfaces/declaration.dart';
66

7-
/// Describes a type regerence in declaration of Swift entities (e.g a method return type).
7+
/// Describes a type reference in declaration of Swift entities (e.g a method return type).
88
/// See `DeclaredType` and `GenericType` for concrete implementation.
99
abstract class ReferredType {
1010
String id;
1111

1212
ReferredType({required this.id});
1313
}
1414

15+
/// Describes a reference of a user-defined type.
1516
class DeclaredType<T extends Declaration> extends ReferredType {
1617
T declaration;
17-
List<ReferredType> genericParams;
18+
List<ReferredType> typeParams;
1819

1920
DeclaredType({
2021
required super.id,
2122
required this.declaration,
22-
required this.genericParams,
23+
required this.typeParams,
2324
});
2425
}
2526

27+
/// Describes a reference of a generic type (e.g a method return type `T` within a generic class).
2628
class GenericType extends ReferredType {
2729
String name;
2830

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import '../../_core/interfaces/compund_declaration.dart';
5+
import '../../_core/interfaces/compound_declaration.dart';
66
import '../../_core/interfaces/objc_annotatable.dart';
77
import '../../_core/shared/parameter.dart';
88
import '../../_core/shared/referred_type.dart';
@@ -26,7 +26,7 @@ class ClassDeclaration implements CompoundDeclaration, ObjCAnnotatable {
2626
List<DeclaredType<ProtocolDeclaration>> conformedProtocols;
2727

2828
@override
29-
List<GenericType> genericParams;
29+
List<GenericType> typeParams;
3030

3131
@override
3232
bool hasObjCAnnotation;
@@ -39,7 +39,7 @@ class ClassDeclaration implements CompoundDeclaration, ObjCAnnotatable {
3939
required this.properties,
4040
required this.methods,
4141
required this.conformedProtocols,
42-
required this.genericParams,
42+
required this.typeParams,
4343
required this.hasObjCAnnotation,
4444
this.superClass,
4545
});
@@ -85,7 +85,7 @@ class ClassMethodDeclaration
8585
List<Parameter> params;
8686

8787
@override
88-
List<GenericType> genericParams;
88+
List<GenericType> typeParams;
8989

9090
@override
9191
ReferredType returnType;
@@ -97,7 +97,7 @@ class ClassMethodDeclaration
9797
required this.id,
9898
required this.name,
9999
required this.params,
100-
required this.genericParams,
100+
required this.typeParams,
101101
required this.returnType,
102102
required this.hasObjCAnnotation,
103103
});

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import '../../_core/interfaces/compund_declaration.dart';
5+
import '../../_core/interfaces/compound_declaration.dart';
66
import '../../_core/shared/parameter.dart';
77
import '../../_core/shared/referred_type.dart';
88

@@ -24,15 +24,15 @@ class ProtocolDeclaration implements CompoundDeclaration {
2424
List<DeclaredType<ProtocolDeclaration>> conformedProtocols;
2525

2626
@override
27-
List<GenericType> genericParams;
27+
List<GenericType> typeParams;
2828

2929
ProtocolDeclaration({
3030
required this.id,
3131
required this.name,
3232
required this.properties,
3333
required this.methods,
3434
required this.conformedProtocols,
35-
required this.genericParams,
35+
required this.typeParams,
3636
});
3737
}
3838

@@ -70,7 +70,7 @@ class ProtocolMethodDeclaration implements CompoundMethodDeclaration {
7070
List<Parameter> params;
7171

7272
@override
73-
List<GenericType> genericParams;
73+
List<GenericType> typeParams;
7474

7575
@override
7676
ReferredType returnType;
@@ -79,7 +79,7 @@ class ProtocolMethodDeclaration implements CompoundMethodDeclaration {
7979
required this.id,
8080
required this.name,
8181
required this.params,
82-
required this.genericParams,
82+
required this.typeParams,
8383
required this.returnType,
8484
});
8585
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import '../../_core/interfaces/compund_declaration.dart';
5+
import '../../_core/interfaces/compound_declaration.dart';
66
import '../../_core/shared/parameter.dart';
77
import '../../_core/shared/referred_type.dart';
88
import 'protocol_declaration.dart';
@@ -25,15 +25,15 @@ class StructDeclaration implements CompoundDeclaration {
2525
List<DeclaredType<ProtocolDeclaration>> conformedProtocols;
2626

2727
@override
28-
List<GenericType> genericParams;
28+
List<GenericType> typeParams;
2929

3030
StructDeclaration({
3131
required this.id,
3232
required this.name,
3333
required this.properties,
3434
required this.methods,
3535
required this.conformedProtocols,
36-
required this.genericParams,
36+
required this.typeParams,
3737
});
3838
}
3939

@@ -71,7 +71,7 @@ class StructMethodDeclaration implements CompoundMethodDeclaration {
7171
List<Parameter> params;
7272

7373
@override
74-
List<GenericType> genericParams;
74+
List<GenericType> typeParams;
7575

7676
@override
7777
ReferredType returnType;
@@ -80,7 +80,7 @@ class StructMethodDeclaration implements CompoundMethodDeclaration {
8080
required this.id,
8181
required this.name,
8282
required this.params,
83-
required this.genericParams,
83+
required this.typeParams,
8484
required this.returnType,
8585
});
8686
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import '../../_core/interfaces/enum_declaration.dart';
6-
import '../../_core/interfaces/paramable.dart';
6+
import '../../_core/interfaces/parameterizable.dart';
77
import '../../_core/shared/parameter.dart';
88
import '../../_core/shared/referred_type.dart';
99
import '../compounds/protocol_declaration.dart';
@@ -20,7 +20,7 @@ class AssociatedValueEnumDeclaration implements EnumDeclaration {
2020
covariant List<AssociatedValueEnumCase> cases;
2121

2222
@override
23-
List<GenericType> genericParams;
23+
List<GenericType> typeParams;
2424

2525
@override
2626
List<DeclaredType<ProtocolDeclaration>> conformedProtocols;
@@ -29,13 +29,13 @@ class AssociatedValueEnumDeclaration implements EnumDeclaration {
2929
required this.id,
3030
required this.name,
3131
required this.cases,
32-
required this.genericParams,
32+
required this.typeParams,
3333
required this.conformedProtocols,
3434
});
3535
}
3636

3737
/// Describes the declaration of a Swift enum case with associated values.
38-
class AssociatedValueEnumCase implements EnumCase, Paramable {
38+
class AssociatedValueEnumCase implements EnumCase, Parameterizable {
3939
@override
4040
String id;
4141

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class NormalEnumDeclaration implements EnumDeclaration {
1818
covariant List<NormalEnumCase> cases;
1919

2020
@override
21-
List<GenericType> genericParams;
21+
List<GenericType> typeParams;
2222

2323
@override
2424
List<DeclaredType<ProtocolDeclaration>> conformedProtocols;
@@ -27,7 +27,7 @@ class NormalEnumDeclaration implements EnumDeclaration {
2727
required this.id,
2828
required this.name,
2929
required this.cases,
30-
required this.genericParams,
30+
required this.typeParams,
3131
required this.conformedProtocols,
3232
});
3333
}

pkgs/swiftgen/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
@@ -19,7 +19,7 @@ class RawValueEnumDeclaration<T> implements EnumDeclaration, ObjCAnnotatable {
1919
covariant List<RawValueEnumCase<T>> cases;
2020

2121
@override
22-
List<GenericType> genericParams;
22+
List<GenericType> typeParams;
2323

2424
@override
2525
List<DeclaredType<ProtocolDeclaration>> conformedProtocols;
@@ -33,7 +33,7 @@ class RawValueEnumDeclaration<T> implements EnumDeclaration, ObjCAnnotatable {
3333
required this.id,
3434
required this.name,
3535
required this.cases,
36-
required this.genericParams,
36+
required this.typeParams,
3737
required this.conformedProtocols,
3838
required this.hasObjCAnnotation,
3939
required this.rawValueType,

pkgs/swiftgen/swift2objc/lib/src/ast/declarations/globals/globals.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import '../../_core/interfaces/declaration.dart';
6-
import '../../_core/interfaces/genericable.dart';
7-
import '../../_core/interfaces/paramable.dart';
6+
import '../../_core/interfaces/type_parameterizable.dart';
7+
import '../../_core/interfaces/parameterizable.dart';
88
import '../../_core/shared/parameter.dart';
99
import '../../_core/shared/referred_type.dart';
1010

@@ -20,7 +20,8 @@ class Globals {
2020
}
2121

2222
/// Describes a globally defined function.
23-
class GlobalFunction implements Declaration, Paramable, Genericable {
23+
class GlobalFunction
24+
implements Declaration, Parameterizable, TypeParameterizable {
2425
@override
2526
String id;
2627

@@ -31,15 +32,15 @@ class GlobalFunction implements Declaration, Paramable, Genericable {
3132
List<Parameter> params;
3233

3334
@override
34-
List<GenericType> genericParams;
35+
List<GenericType> typeParams;
3536

3637
ReferredType returnType;
3738

3839
GlobalFunction({
3940
required this.id,
4041
required this.name,
4142
required this.params,
42-
required this.genericParams,
43+
required this.typeParams,
4344
required this.returnType,
4445
});
4546
}

0 commit comments

Comments
 (0)