-
Notifications
You must be signed in to change notification settings - Fork 46
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 support for region comments in Solidity #452
Comments
This is interesting. We are interested in whether other users would find this useful, so leave a comment or a In terms of implementation, it involves a change to the language configuration, basically pulling this from the js/ts language config: https://github.com/microsoft/vscode/blob/a1eb9e2b48736c3f79697fb6618528d094318a93/extensions/javascript/javascript-language-configuration.json#L112 |
Yes, region comments can be a helpful tool for organizing, structuring, and reading Solidity code, but, unfortunately, they are not widely supported in major dev environments right now like IntelliJ, VS Code, Remix, etc, while other languages have good support for it. Developers who have used this functionality in other languages and are familiar with its benefits would likely want to embrace it in Solidity (example). Once Solidity IDEs add support for region comments, developers can adopt this practice and benefit from its advantages. |
I was looking into this myself. By performing a quick search on GitHub, we could see all Solidity code out there that integrate region comments. Also note that this feature is already supported in juanfranblanco's VSCode extension. I personally think region comments are a must have for any code formatting maxi, so I took the initiative by opening #526 to address this. |
Region comments are now supported in the extension. |
Region comments are useful for organizing code and making it more readable by allowing developers to collapse and expand sections of code. This is especially useful for large files with many functions or blocks of code that are related but not necessarily sequential.
There are several use cases where region comments could be useful:
Contract sections: Solidity contracts can have multiple sections, such as state variables, constructors, functions, and modifiers. Using region comments to group these sections together would make it easier to navigate and understand the structure of a contract.
Code blocks: Solidity code can be complex, and it's often helpful to break it down into smaller, more manageable sections. Region comments could be used to group related code blocks together, such as loops, conditionals, or function calls.
Regional comments are supported in multiple languages in VS Code, and I believe it would be beneficial to have support for region comments in Solidity as well. Solidity code can often be complex, with multiple sections and code blocks, and region comments would make it easier for developers to navigate and understand the code. The ability to collapse and expand sections of code would improve code readability and reduce the cognitive load on developers. Additionally, many developers are already familiar with using region comments in other languages, so having support for them in Solidity would make the development experience more consistent and intuitive.
The text was updated successfully, but these errors were encountered: