Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Yawar Quadir Amin
    @yamin-oanda
    this is from the project root
    Yawar Quadir Amin
    @yamin-oanda
    i also tried using just -diff but the output diff can't be applied with git...
    it seems because the diff headers have the absolute path of the files, instead of the relative paths
    Yawar Quadir Amin
    @yamin-oanda
    working around that for now by going into the exact directory
    Rijnard van Tonder
    @rvantonder
    @yamin-oanda the patches are applied using patch -p0, so there's some issue with that failing. Could you tell me what you see after you do this:
    comby 'Some(:[x])' ':[x].?' src/test/scala/com/oanda/sfb/rates/CandleExchangeRatesSpec.scala -diff > p.patch 
    patch -p0 --verbose < p.patch
    Yawar Quadir Amin
    @yamin-oanda
    thanks! i'll try that
    btw comby is really cool. thanks for making it :-)
    Yawar Quadir Amin
    @yamin-oanda
    yes–patch -p0 works! thanks
    4 replies
    Raphaël Duchaîne
    @duchainer
    Hi, seems to be a great tool to add to my emacs toolbelt, but is comby.dev down for anybody else? I can use comby.live no problem but can't seem to access anything on the comby.dev domain.
    2 replies
    Jens
    @jensim
    I was making a long set of pipes in bash today, and found myself wanting to use comby in the pipe to mutate and output, would have been a nice fit this time. But I do t see an stdout option to accompany the stdin one
    14 replies
    Maybe I just missed something.. Did not read the comby -help | grep stdout, just the comby.dev search
    Rijnard van Tonder
    @rvantonder
    Sounds like -stdout should work for you!
    Oskar Hermansson
    @oskar
    Hi! There is language support for C# in comby but it doesn't look like it's available on the playground / comby.live. Any particular reason for that?
    Oskar Hermansson
    @oskar
    Would it be enough to just extend this list? :) https://github.com/comby-tools/comby-ui/blob/master/LanguageExtension.elm
    1 reply
    Rijnard van Tonder
    @rvantonder
    Hey @oskar ! Of course, looks like I missed it.
    Daniel Hines
    @d4hines

    Hello. Quick question: suppose I have a Javascript object with a (Typescript) type like {a: number, b: number, c?: number} (note c is optional). I'd like to extract the props a, b, and c, from the object into an ordered, delimited list. So, some example rewrites might be:

    {a: 1, b: 2, c: 3 } -> 1,2,3
    {c: 4, b: 5, a: 6} -> 6,5,4      // out of order
    {a: 7, b: 8} -> 7,8,,                // some items missing

    Is it possible to achieve this kind of matching and rewriting with Comby? I see there was a merge for optional holes. Perhaps one could use pattern matching + optional holes, but I'm not clever enough to figure it out.

    Oskar Hermansson
    @oskar
    Thanks @rvantonder! Works like a charm :)
    Raphaël Duchaîne
    @duchainer
    Is there a way to rewrite a hole to change from snake_case to camelCase ?
    5 replies
    Josh Marcus
    @joshmarcus
    Is there a pattern for adding an import to a file (e.g. java, scala, python)?
    1 reply
    Ameya Ketkar
    @ameyaKetkar

    Hello, I am trying to use comby to substitute a template variable with a string fragment.
    However, I found that this does not work:
    comby '' ':[1~\w] :[2]' -substitute-only '[{"variable":"1", "value":"hello" }]'

    While this works:
    comby '' ':[1~\w] :[2]' -substitute-only '[{"variable":"1~\w", "value":"hello" }]'

    Is there a any work-around for this? Or will I always have to append the associated regex to the template variable

    2 replies
    Ameya Ketkar
    @ameyaKetkar
    Hello, Can i use the config files only for matching (not rewriting), if so, what should be the value at the rewrite field? Also, can I use config file to find which template matches an input string (not a file)?
    12 replies
    Wouter Smeenk
    @woutersmeenk
    @rvantonder I just watched the talk at "Parser Parser Combinators for Program Transformation" and I found it very interesting! During the questions you talk about the type information that is needed sometimes. Has there been anything done on this since this talk? Any research or implementation?
    4 replies
    Dan Lien
    @danclien
    Anyone get different results on the live demo vs running locally? This match works for me online, but I can't get it work locally. When running locally, it doesn't search past the newline. - https://comby.live/index.html#{%22source%22:%22var%20a%20=%20true%20\n||%20false;%22,%22match%22:%22var%20:[name]%20=%20:[statement];%22,%22rule%22:%22where%20true%22,%22rewrite%22:%22:[statement]%22,%22language%22:%22.cs%22,%22substitution_kind%22:%22in_place%22,%22id%22:0}
    3 replies
    Wouter Smeenk
    @woutersmeenk
    Just had a wild idea... What if you could generate a Comby query with GTP-3 like: https://www.youtube.com/watch?v=j0UnS3jHhAA
    1 reply
    Wouter Smeenk
    @woutersmeenk
    Getting started with Comby and trying replace something in one file: "docker run --rm comby/comby 'ProxyListValue' 'IProxyListValue' ExternalBOLinkService.java" but it seems to be running forever. Am I doing something wrong?
    5 replies
    Mark Derricutt
    @talios

    Hey all - LOVE comby. I’m wanting to drop a line of code, but retain indentation, I have in my TOML config:

    match='''
    :[prefix]@NotNull:[~\s]
    '''
    rewrite=":[prefix]"

    but that gives me a warning about matching everything - but works. Is there a better syntax I should be using?

    4 replies
    mmm, or it did work before.
    Mark Derricutt
    @talios
    Weird - that all works fine now, if I have a single rule in my config file - if I have multiple rules nothing fires if I do -in-place or -review
    Mark Derricutt
    @talios
    Hrm, matching "@NotNull :[var]” on the command line will hit multiple matches/replacements in a single line, but from a config file - only the first matches - is that expected?
    Rijnard van Tonder
    @rvantonder
    :grimacing: looks like a recent bug! The config file issue should be fixed upstream, but it's not in a release yet. I think the bug persists with -review though
    let me hack on this a little and push out a release, maybe in the next day or two
    Mark Derricutt
    @talios
    Awesome! comby continues to be awesome and a game changer :) Long weekend starting here now and about to fly off to a wedding, so will look forward that that new release when it lands.
    uzshrestha
    @uzshrestha
    Hi @rvantonder I’m still facing issue here looks like your recommended work around is stillcomby-tools/comby#276
    3 replies
    jtrakk
    @jtrakk

    Is it possible to turn

    class MyObject:
        def __init__(self, a: Foo, b: Bar, c: Baz):
            self.a = a
            self.b = b
            self.c = c

    into

    class MyObject:
        a: Foo
        b: Bar
        c: Baz

    but for any number of arguments?

    or do I need to do a one-argument version and a two-argument version, etc
    3 replies
    Ameya Ketkar
    @ameyaKetkar
    @rvantonder I was trying comby on my ubuntu machine. However, it seems that the latest version is not available. It downloads and installs version 1.0.0. Will I have to build it from source for Ubuntu?
    10 replies
    Jens
    @jensim
    @rvantonder Is there some way to make comby do lower-case conversion of a captured hole? I searched for 'lower' in comby.dev, the github repo and here, but found nothing. Is there some way of stitching in this text mutation?
    6 replies
    vvvvv
    @vvvvv
    hey comby folks
    new to comby and I want to do something rather simple but can't get it to work
    why does my matcher match var x string
    vvvvv
    @vvvvv
    got it working myself
    Mark Derricutt
    @talios

    Hey all - trying to use comby to rewrite a 170mb CSV file, worked fine on a small sampe - but the large file just bails due to timeouts. Altho, even updating the -timeout doesn’t help - any other options I could enable to try speed this up ( or even get it to not crash).

    Seems I’m gonna need to run this process for the next week or so massaging some data, comby worked well initially but…. 8 matchers - Maybe if I tell it not to run in parrallel or something?

    3 replies
    Mark Derricutt
    @talios

    Is -config suppose to accept a directory of TOML files? CSV of directories containing templates, or TOML configuration files is a bit ambiguous over the directory containg “templates or TOML files”, or “directories of templates, OR toml files”.

    Directory of TOMLs would be handy but doesn’t seem to work.

    2 replies
    Cory Forsyth
    @bantic
    Is there a way to have a hole that could match nothing? I'm trying to use comby to find a matching line inside of a method call, and it could have 0 or more lines before or after it. Here's an example, where I want to make :[before] and :[after] match 0-or-more lines. Is that possible?
    bit.ly/3vJkFfw
    3 replies
    subham sarkar
    @shmsr
    Anyone had success setting up comby-server on Mac? I followed the instructions — "Building from the Source", but it just generates the "comby" executable. How to install "comby-server"?
    16 replies
    Thomas Ahle
    @thomasahle_twitter
    Hi all, I'm trying to match for loops like for (int i = 0; ...) { :[s] += :[ar][i]; }, but it doesn't seem to match anything. Do I have to add something to allow for whitespace inside the block?
    4 replies
    Nicolò Martini
    @nicmart

    Hello everyone!
    I am trying to use comby to do some refactor in a large scala codebase.
    I have a rule like this:

    LegacySelection(TableName(:[table]), :[field]) --> NewSelection(:[table], :[field])

    The rule works, but the annoying thing is about whitespaces.
    Sometimes in the codebase TableName is preceeded by a new line and spaces:

    LegacySelection(
       TableName("foo"),
      "bar"
    )

    sometimes it is inline

    LegacySelection(TableName("foo"), "bar")

    Now, the rules does not match the first one, because in the pattern there is no whitespace. If I put the whitespace it will match the second, but not the first...
    How can I avoid to have to replicate the rules with the two versions?
    (In reality the rule is much more complex than this, and covering all the cases it is not feasible)

    4 replies
    Ameya Ketkar
    @ameyaKetkar
    Hi @rvantonder I was playing with this simple snippet
    :[m](:[a], :[a]) applied to the code foo(ab, ab)
    I observed that comby generates an auxiliary variable to represent the second template variable a. I was wondering two things :
    (i) is there a way i can get back the original variable name? Is a 37 character prefix always added in such scenarios followed by _equal in suffix?
    (ii) I was curious why did you choose to report this auxiliary variable instead of reporting the two occurrences as a list of range for variable a.
    5 replies