Live data from Hacker News

Comby - Structural code search and replace for every language

comby.dev

11–20 of 26 posts

Re: Comby - Structural code search and replace for every language

#11

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!

language-server methods like rename

Re: Comby - Structural code search and replace for every language

#12
post #10

A 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…

yeah i just discovered semgrep a week ago! i'll have to download this and compare.

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

#13

I believe Sourcegraph uses Comby under the hood to an extent for structural matching as well!

Yep! (Sourcegraph Community Manager here) We use Comby syntax for structural search: https://docs.sourcegraph.com/code_search/reference/structura...

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

#14
post #10

A 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.

Re: Comby - Structural code search and replace for every language

#15

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!

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.sourcegraph.com/batch_changes/explanations/intr... [3] https://docs.sourcegraph.com/cli

Re: Comby - Structural code search and replace for every language

#16

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!

language-server methods like rename

Yes. I regularly use this feature sky-high I was looking for something more advanced as vanesa- spoke in the sibling comment.

Re: Comby - Structural code search and replace for every language

#17

Earlier quoted context omitted.

language-server methods like rename

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

#18
post #15

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!

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.…

Thanks for letting me know. I'll try it right away.

Re: Comby - Structural code search and replace for every language

#19

Earlier 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? :)

You should be able to edit comments within 2? hours of posting. Maybe this link works for you? https://news.ycombinator.com/edit?id=31417626

Re: Comby - Structural code search and replace for every language

#20
post #14
post #10

A 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.

Semgrep has "experimental" support for C++. My understanding is that the major gap with both C & C++ support is macros, which are really hard.
Post reply on HN