-
Notifications
You must be signed in to change notification settings - Fork 4
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
add parameterized types #5
add parameterized types #5
Conversation
Extended the parser and type model to handle parameterized types such as `sequence`, `record`, `FrozenArray`, and `Promise`. Updated validation logic to recognize these types and parse their parameters correctly. Adjusted the `IdlType` class to store parameterized type information.
Renamed parameters and improved variable naming to enhance readability. Adjusted error messaging to align with updated parameter names for better context.
Previously, all imports were processed without regard for parameterized types, potentially causing issues. This update adds a filter to exclude unsupported parameterized types, improving stability and error handling. A TODO comment is included for future support of these types.
Previously, the tested interface contained 2 attributes, but this has been updated to 7. The change aligns the test with the updated interface definition.
6cd5199
to
5def144
Compare
Corrected inconsistent indentation in the lambda to improve code readability. This change does not alter functionality but ensures the code adheres to proper formatting standards.
Removed unnecessary conditional block checking for parameterized types within angled brackets. Simplifies code by consolidating checks and reducing duplication, improving maintainability.
} | ||
|
||
val typeParams = typeName.substring(typeName.indexOf("<") + 1, typeName.lastIndexOf(">")) | ||
typeName = typeName.substring(0, typeName.indexOf("<")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I prefer using the substringBefore
/ substringAfter
functions for these kind of things. E.g. something like this:
val typeParams = typeName.substringAfter('<').substringBeforeLast('>')
typeName = typeName.substringBefore('<')
But that's only a personal preference so feel free to keep it this way 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, that part lack also of Unit Test on the result, working on it.
Refactor type parameter extraction to use more concise Kotlin functions `substringAfter` and `substringBeforeLast`.
Updated `IdlType.parameterType` from a single string to a list to handle multiple type parameters. Adjusted parsing logic in `WebIdlStream` and updated tests to validate the new structure. Ensures compatibility with complex type definitions like `record` and `FrozenArray`.
Renamed the `parameterType` field to `parameterTypes` in the `IdlType` class for consistency and clarity. Updated relevant test assertions to reflect this change.
No description provided.