forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
TyDecl
Enum and Separate Structs for Improved Code Organiz…
…ation (FuelLabs#4457) ## Description This PR refactors the `TyDecl` enum by separating its variants into individual structs and simplifying the enum itself, leading to better code organization and maintainability. This refactoring enhances modularity making it easier to implement a Parse trait on these types in the language server when matching on the variants during AST traversal, which is required to unblock FuelLabs#3799. I had attempted to do this in FuelLabs#4247 but it was reverted by @emilyaherbert. Hopefully, this new approach is acceptable. The main change is ```rust #[derive(Clone, Debug)] pub enum TyDecl { ConstantDecl { name: Ident, decl_id: DeclId<TyConstantDecl>, decl_span: Span, }, FunctionDecl { name: Ident, decl_id: DeclId<TyFunctionDecl>, subst_list: Template<SubstList>, decl_span: Span, }, .... } ``` Has been changed to ```rust #[derive(Clone, Debug)] pub enum TyDecl { ConstantDecl(ConstantDecl), FunctionDecl(FunctionDecl), .... } #[derive(Clone, Debug)] pub struct ConstantDecl { pub name: Ident, pub decl_id: DeclId<TyConstantDecl>, pub decl_span: Span, } #[derive(Clone, Debug)] pub struct FunctionDecl { pub name: Ident, pub decl_id: DeclId<TyFunctionDecl>, pub subst_list: Template<SubstList>, pub decl_span: Span, } ``` ## Checklist - [x] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
- Loading branch information
1 parent
5e7ad6e
commit 7011edd
Showing
37 changed files
with
594 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.