Skip to content
Permalink
Branch: master
Commits on Mar 6, 2019
  1. don't panic on funcs with nil blocks

    mvdan committed Mar 6, 2019
    This can happen with stub function declarations, which are common in
    larage codebases.
    
    Fixes #36.
  2. allow more stmtList substitution scenarios

    mvdan committed Mar 6, 2019
    Hit this when trying to replace:
    
    	err = F()
    	if err != nil {
    		...
    	}
    
    With:
    
    	if err := F(); err != nil {
    		...
    	}
    
    The command below failed. Add a small test case and fix it.
  3. CI: test on Go 1.12

    mvdan committed Mar 6, 2019
  4. update x/tools dependency

    mvdan committed Mar 6, 2019
Commits on Dec 18, 2018
  1. stop on package load errors too

    mvdan committed Dec 18, 2018
    I had forgotten to check those. Otherwise, we might be ignoring parse or
    typecheck errors.
    
    We can't fix the TODO in load_test.go yet, because it looks like there's
    another bug in go/packages. See golang/go#29280.
Commits on Dec 15, 2018
  1. don't load test packages by default

    mvdan committed Dec 15, 2018
    In go/packages, this currently means multiplying the loading and
    typechecking work most of the time. Not only because of the _test.go
    files and their extra dependencies, but also because we need to load and
    typecheck internal test packages.
    
    However, most queries are geared towards non-test code, so it's best not
    to assume that the user wants to include test code. This way, the tool
    is simpler and faster by default. It's also worth noting that most
    static analysis tools already skip tests by default.
    
    Reduces 'go test' time from ~2.4s to ~0.4s on my laptop.
    
    We might want to reconsider the performance cost if
    golang/go#29258 is implemented, or if gogrep
    starts being used with a language server.
  2. simplify node loader

    mvdan committed Dec 15, 2018
    Now that all loading should happen via go/packages.Load, it makes little
    sense to split the typed and untyped loaders into separate functions. If
    we do split the untyped loader at some point, that will probably be via
    some if conditions via the single load function.
  3. don't load recursive test dependencies with -r

    mvdan committed Dec 15, 2018
    Only direct test dependencies are loaded. This can drastically reduce
    the amount of packages to search on.
    
    Reduces 'go test' time from ~2.9s to ~2.6s on my laptop.
  4. all: port to go/packages

    mvdan committed Dec 15, 2018
    To get module support, mainly. We also get rid of the deprecated
    go/loader dependency.
    
    For the sake of simplicity, the untyped loader has been removed for now.
    We might re-add them in the future via LoadFiles.
    
    This isn't perfect, so we'll probably clean up the code in the following
    days. But at least 'go test' now passes on Go 1.11, and modules seem to
    work.
    
    Fixes #39.
Commits on Sep 1, 2018
  1. all: convert into a Go module

    mvdan committed Sep 1, 2018
Commits on Jul 14, 2018
  1. remove duplicate test cases

    mvdan committed Jul 14, 2018
    They were probably added by mistake while working on covering more
    scenarios with test cases.
  2. remove the need for wantSrc in the tests

    mvdan committed Jul 14, 2018
    Now that -w works well, we can simply use that for the substitution test
    cases.
  3. support substituting the root node

    mvdan committed Jul 14, 2018
    Since it has no parent, we can't change it in the syntax tree. We simply
    have to swap the syntax tree entirely.
    
    Fixes #34.
Commits on Jun 24, 2018
  1. remove unused parameter in matcher.wildcard

    mvdan committed Jun 24, 2018
    Found by unparam.
Commits on May 14, 2018
  1. don't crash on types that cannot be found

    mvdan committed May 14, 2018
    For now, simply ignore them. Erroring is not an option, as other
    sub-matches might have found a type.
    
    One option was to find the type globally across the entire program. But
    that would be a slightly less precise approach, as this one finds the
    type from the scope of the submatch. That will work better when the type
    in question is defined in a local scope such as a func body.
    
    I might revisit this mechanism in the future.
    
    Fixes #30.
Commits on May 10, 2018
  1. rework dollar expressions and some commands

    mvdan committed May 10, 2018
    Get rid of the $() notation. Instead, split these "wildcard operators"
    into their own commands, which simplifies the syntax and the code.
    
    With this change, the following query:
    
    	-x '$(x /elems/ type([]string))'
    
    Becomes:
    
    	-x '$x' -a 'rx(elems)' -a 'type([]string)'
    
    This will also allow these commands to be more composable and powerful.
    For example, now one can check for type equality on all expressions, not
    just dollar expressions.
    
    While at it, also add a -p command to navigate up a number of parent
    nodes, which is required now that queries tend to navigate to
    sub-expressions more often.
    
    Fixes #28.
Commits on Mar 11, 2018
  1. start fixing positions when substituting nodes

    mvdan committed Mar 11, 2018
    We don't want to mix positions from different filesets. First, remove
    the positions, and later adapt them as best we can.
  2. support substituting a stmt with an expression

    mvdan committed Mar 11, 2018
    Another edge case.
  3. support substituting many exprs with one

    mvdan committed Mar 11, 2018
    Similar to the recent fix for statements.
  4. support replacing entire node lists

    mvdan committed Mar 11, 2018
    This wasn't working very well since we were lacking the glue code to
    make single nodes just work. And the parents map wasn't being updated
    appropriately.
  5. support substituting expr lists with a single expr

    mvdan committed Mar 11, 2018
    This needs a bit of extra glue code, as we were trying to replace an
    ast.Ident with an exprList.
  6. support replacing single identifiers

    mvdan committed Mar 11, 2018
    That is, when they are an *ast.Ident in their parent node as opposed to
    an ast.Expr, which we already support.
    
    While at it, make bufferJoinLines deduplicate newlines and avoid a
    trailing "; ".
Commits on Mar 10, 2018
  1. load source files with comments for -w

    mvdan committed Mar 10, 2018
    Otherwise comments are lost.
  2. add docs for -s and -w

    mvdan committed Mar 10, 2018
    Also remove the redundant usage lines from the flag package, as we have
    our own usage func.
  3. add -w flag to write modified output back

    mvdan committed Mar 10, 2018
    To write changes to files on disk, for example. The missing piece for
    -s. Similar to sed's -i.
  4. support substituting within node lists

    mvdan committed Mar 10, 2018
    For example, substituting any number of expressions or statements with
    any other number of nodes of the same class.
    
    This was the last missing piece to make -s generally useful.
Commits on Mar 9, 2018
  1. start supporting wildcards in -s

    mvdan committed Mar 9, 2018
  2. narrow extra $*x list walks

    mvdan committed Mar 9, 2018
    Don't do it for any expression; just those that are wildcards with the *
    "any" modifier.
  3. first working version of -s to substitute nodes

    mvdan committed Mar 9, 2018
    Borrowing the node replacing code from goreduce.
Commits on Mar 2, 2018
  1. fix stdImportFixes generation command

    mvdan committed Mar 2, 2018
    I likely forgot to include this grep argument that it depends on.
  2. remove "~ var n T" aggressive matching code

    mvdan committed Mar 2, 2018
    This can now be accomplished with "~ n T" without the extra code. One of
    the advantages of accepting specs as -x arguments.
Commits on Mar 1, 2018
  1. CI: drop Go 1.8, add 1.10

    mvdan committed Mar 1, 2018
Commits on Feb 27, 2018
  1. allow value specs as given expressions

    mvdan committed Feb 27, 2018
    Not very useful just yet, but will be for some cases.
Older
You can’t perform that action at this time.