Okay wow. I didn't tools like this existed! There's been more than once where I've found myself in a situation like "find all code like this, change if this, delete if this". Regex can only get you so far. Does someone know if this or something similar is available as a VSCode extension? It'd be fun to make one if not!
Comby - Structural code search and replace for every language
11–20 of 26 posts
Re: Comby - Structural code search and replace for every language
#12A more interesting comparison than with Coccinelle is with semgrep ( https://semgrep.dev/ ) since it also supports semantic/structural pattern matching over a number of languages, but also adds in a bunch of Boolean logic into the mix, as well as some more advanced semantic features like constant propagation. Curious whether the teams behind these tools are aware of each other? I suppose it's unlikely that they're no…
i found the CLI features lacking in semgrep (vs using a yaml config), so maybe this will have more support there.
Re: Comby - Structural code search and replace for every language
#13I believe Sourcegraph uses Comby under the hood to an extent for structural matching as well!
We also have a few tutorials to make large-scale code changes across many repositories and code hosts (batch changes) with Comby:
- Refactor Go code using Comby: https://docs.sourcegraph.com/batch_changes/tutorials/refacto...
- Updating Go import statements using Comby: https://docs.sourcegraph.com/batch_changes/tutorials/updatin...
The author of Comby is a researcher at Sourcegraph building our search platform.
Re: Comby - Structural code search and replace for every language
#14A more interesting comparison than with Coccinelle is with semgrep ( https://semgrep.dev/ ) since it also supports semantic/structural pattern matching over a number of languages, but also adds in a bunch of Boolean logic into the mix, as well as some more advanced semantic features like constant propagation. Curious whether the teams behind these tools are aware of each other? I suppose it's unlikely that they're no…
Re: Comby - Structural code search and replace for every language
#15Okay wow. I didn't tools like this existed! There's been more than once where I've found myself in a situation like "find all code like this, change if this, delete if this". Regex can only get you so far. Does someone know if this or something similar is available as a VSCode extension? It'd be fun to make one if not!
You can't do batch changes[2] inside of VSCode yet, only via the Sourcegraph CLI[3]. We're working on expanding this.
[1] https://marketplace.visualstudio.com/items?itemName=sourcegr... [2] https://docs.sourcegraph.com/batch_changes/explanations/intr... [3] https://docs.sourcegraph.com/cli
Re: Comby - Structural code search and replace for every language
#16Okay wow. I didn't tools like this existed! There's been more than once where I've found myself in a situation like "find all code like this, change if this, delete if this". Regex can only get you so far. Does someone know if this or something similar is available as a VSCode extension? It'd be fun to make one if not!
language-server methods like rename
Re: Comby - Structural code search and replace for every language
#17Re: Comby - Structural code search and replace for every language
#18Okay wow. I didn't tools like this existed! There's been more than once where I've found myself in a situation like "find all code like this, change if this, delete if this". Regex can only get you so far. Does someone know if this or something similar is available as a VSCode extension? It'd be fun to make one if not!
Sourcegraph Community Manager here. You can use the Sourcegraph extension for VSCode [1] that would allow you to have the structural search powered by Comby (or literal or regular expression search) inside of VSCode. You can't do batch changes[2] inside of VSCode yet, only via the Sourcegraph CLI[3]. We're working on expanding this. [1] https://marketplace.visualstudio.com/items?itemName=sourcegr... [2] https://docs.…
Re: Comby - Structural code search and replace for every language
#19Earlier quoted context omitted.
Yes. I regularly use this feature sky-high I was looking for something more advanced as vanesa- spoke in the sibling comment.
- sky-high + but Swiping fiasco. When do we get the edit comment feature in HN? :)
Re: Comby - Structural code search and replace for every language
#20A more interesting comparison than with Coccinelle is with semgrep ( https://semgrep.dev/ ) since it also supports semantic/structural pattern matching over a number of languages, but also adds in a bunch of Boolean logic into the mix, as well as some more advanced semantic features like constant propagation. Curious whether the teams behind these tools are aware of each other? I suppose it's unlikely that they're no…
Comby works with C++, which to me is a great advantage.