GumTreeDiff / gumtree

An awesome code differencing tool
https://github.com/GumTreeDiff/gumtree/wiki
GNU Lesser General Public License v3.0
932 stars 173 forks source link

add support for AST-diffing Solidity #266

Open monperrus opened 2 years ago

monperrus commented 2 years ago

it would be great to add support for diffing Solidity.

For this we can use the existing support from solidity compiler solc

solc --ast-compact-json contract.sol

Flag --ast-compact-json gives the "AST of all source files in a compact JSON format."

jrfaller commented 2 years ago

Nice idea!

Apparently there is also a tree sitter grammar : https://github.com/JoranHonig/tree-sitter-solidity

jrfaller commented 2 years ago

I looked a little bit into the output of solc and it wouldn't be straightforward, the AST is quite far from the CST and lacking a lot of textual position information 😢

I'll try to see if I get more luck with the tree-sitter one ^^

monperrus commented 2 years ago

cool, thanks for the update

jrfaller commented 2 years ago

ok the tree-sitter version seems a little unstable I got a ValueError: Incompatible Language version 12. Must be between 13 and 13, so I'll have to retry that at some point in the future when it's more stable

Coppelian commented 2 years ago

Hello there. I found a parser: https://github.com/solidity-parser/parser I wonder if it could be used in this case.

jrfaller commented 2 years ago

Hi, apparently there is a ANTLR grammar related to the code you point out here : https://github.com/solidityj/solidity-antlr4

And we have support for antlr grammars, so that might worth a try.

monperrus commented 2 months ago

For the record, we have a first prototype at https://github.com/mojtaba-eshghie/solidity-code-diff