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

Organize the arguments of Model.render. #272

Merged
merged 10 commits into from
Nov 12, 2024

Conversation

sidepelican
Copy link
Collaborator

Model.render has a lot of arguments, making it very complex.
There are also places where meaningless values are being passed.

In this PR, I will organize the arguments by separating them into RenderContext and GenerationArguments, allowing us to distinguish between global settings and the state during the render process.

}
return nil
}
.sorted { (left: (String, Int64), right: (String, Int64)) -> Bool in
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sorting is done in generateUniqueModels, so sorting here is unnecessary.

Tests/TestMacros/MacroTests.swift Show resolved Hide resolved
@@ -32,28 +31,37 @@ final class ClosureModel: Model {
return .closure
}

init(genericTypeParams: [ParamModel], paramNames: [String], paramTypes: [SwiftType], isAsync: Bool, throwing: ThrowingKind, returnType: SwiftType, encloser: String) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encloser is unnecessary here because type depends on RenderContext.

@@ -27,6 +27,18 @@ public enum ModelType {
case closure
}

enum NominalTypeDeclKind: String {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the most places, DeclType has incorrect cases so prepares new enum.

Copy link
Collaborator

@fummicc1 fummicc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few minor review comments. Thank you very much!

Sources/MockoloFramework/Models/TypeAliasModel.swift Outdated Show resolved Hide resolved
Tests/TestMacros/MacroTests.swift Show resolved Hide resolved
Copy link
Collaborator

@fummicc1 fummicc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

@sidepelican sidepelican merged commit 2e87c0c into uber:master Nov 12, 2024
3 checks passed
@sidepelican sidepelican deleted the rendercontext branch November 12, 2024 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants