Skip to content

Commit

Permalink
#13, MemberedTypeToClass.importFromMemberedType()
Browse files Browse the repository at this point in the history
  • Loading branch information
ajvincent committed Jan 25, 2024
1 parent e7834fa commit 1716199
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
19 changes: 18 additions & 1 deletion stage_1_integration/toolbox/MemberedTypeToClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {
ClassMembersMap,
ConstructorDeclarationImpl,
IndexSignatureResolver,
type InterfaceDeclarationImpl,
MemberedStatementsKeyClass,
type MemberedTypeToClass_StatementGetter,
type MemberedObjectTypeStructureImpl,
NamedTypeMemberImpl,
ParameterDeclarationImpl,
type TypeMemberImpl,
Expand Down Expand Up @@ -103,7 +105,7 @@ export default class MemberedTypeToClass {
* @param isStatic - true if the class members are static.
* @param membersMap - the type members map for conversion to class members.
*/
importFromTypeMembers(
importFromTypeMembersMap(
isStatic: boolean,
membersMap: TypeMembersMap,
): void
Expand All @@ -115,6 +117,21 @@ export default class MemberedTypeToClass {
this.#adoptTypeMembers(isStatic, temporaryTypeMembers);
}

/**
* Define class members for a membered object type or interface.
* @param isStatic - true if the class members are static.
* @param membered - the interface or membered object type.
*/
importFromMemberedType(
isStatic: boolean,
membered: InterfaceDeclarationImpl | MemberedObjectTypeStructureImpl
): void
{
return this.importFromTypeMembersMap(
isStatic, TypeMembersMap.fromMemberedObject(membered)
);
}

#importFromTypeMembers(
isStatic: boolean,
membersMap: TypeMembersMap,
Expand Down
22 changes: 21 additions & 1 deletion stage_2_fullset/snapshot/source/toolbox/MemberedTypeToClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import {
ClassMembersMap,
ConstructorDeclarationImpl,
IndexSignatureResolver,
type InterfaceDeclarationImpl,
MemberedStatementsKeyClass,
type MemberedTypeToClass_StatementGetter,
type MemberedObjectTypeStructureImpl,
NamedTypeMemberImpl,
ParameterDeclarationImpl,
type TypeMemberImpl,
Expand Down Expand Up @@ -101,14 +103,32 @@ export default class MemberedTypeToClass {
* @param isStatic - true if the class members are static.
* @param membersMap - the type members map for conversion to class members.
*/
importFromTypeMembers(isStatic: boolean, membersMap: TypeMembersMap): void {
importFromTypeMembersMap(
isStatic: boolean,
membersMap: TypeMembersMap,
): void {
this.#requireNotStarted();
const temporaryTypeMembers = new TypeMembersMap();
this.#importFromTypeMembers(isStatic, membersMap, temporaryTypeMembers);

this.#adoptTypeMembers(isStatic, temporaryTypeMembers);
}

/**
* Define class members for a membered object type or interface.
* @param isStatic - true if the class members are static.
* @param membered - the interface or membered object type.
*/
importFromMemberedType(
isStatic: boolean,
membered: InterfaceDeclarationImpl | MemberedObjectTypeStructureImpl,
): void {
return this.importFromTypeMembersMap(
isStatic,
TypeMembersMap.fromMemberedObject(membered),
);
}

#importFromTypeMembers(
isStatic: boolean,
membersMap: TypeMembersMap,
Expand Down

0 comments on commit 1716199

Please sign in to comment.