You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by tkruse <gi...@git.apache.org> on 2015/08/21 20:38:03 UTC

[GitHub] incubator-groovy pull request: Refactor invoker

GitHub user tkruse opened a pull request:

    https://github.com/apache/incubator-groovy/pull/96

    Refactor invoker

    These are some refactorings and minor enhancements of the formatting methods in InvokerHelper.
    
    The formatting of maps, arrays, collections and ranges should be more consistent, allowing the same parameters (verbose, maxSize, safe) everywhere. The 'safe' parameter gets used in many more contexts (though default is still false).
    
    I hope that existing behavior and API was not changed (too much). I believe I did not change any existing *public* method signature, though I added a few with more options.
    
    The behavior should be the same, except for the case when an Object.toString() method throws a checked exception, then this will be rethrown wrapped in a GroovyRuntimeException, when a method is invoked with 'safe=true', which I believe is done by PowerAsserts.
    
    Some changes might need further discussions. One thing annoying me still is that after this PR, the methods
    ```toArrayString(Object[] collection, boolean verbose, int maxSize, boolean safe)``` and ```formatCollection(Collection collection, boolean verbose, int maxSize, boolean safe)``` are syntactically equal, not sure if there is a nice way not to replicate code, yet also not transforming arrays to collections or vice versa.
    
    The preAllocation of the StringBuffers might be too big, maybe a value like 3 or 4 might be nicer. It's always a heuristic value, maybe premature optimization.
    
    I hope next to change the default printing in PowerAsserts and Groovysh to use the "verbose" flag.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tkruse/incubator-groovy refactor-invoker

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-groovy/pull/96.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #96
    
----
commit 1cd54c77d65c964352f58e553612f49edf064815
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T14:02:32Z

    Refactor: Code style - if block

commit ac2cc23f2fecb26a14087691a8c2336f45950f65
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T14:06:46Z

    InvokerHelper: Refactor: Better StringBuffer pre-allocation

commit cd88e53c62838e1b3445911eb0de7dc79aa679c3
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T14:07:38Z

    InvokerHelper: Refactor: Rename private method

commit 89fa83e0b34878c18c2166bf3b044a7970bf4034
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T14:11:52Z

    InvokerHelper: Implement Array formatting like Collection formatting

commit b24a6dc76d12e06f64b1df9d284160fa8cd1ae93
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T14:23:10Z

    InvokerHelper: Provide safe formatting consistently (not just for lists)

commit 661569d49b7567a37b8a96027e2fadf297beb338
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T14:23:37Z

    InvokerHelper: Map formatting safe and self-detecting also for keys

commit 95cb3ec44f6a6dc6b13de4a270ba261d8f1c8c24
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T15:33:19Z

    InvokerHelper: Refactor: invoke specific methods. Remove obsolete

commit e76b7b1630cb6e573b02557929b51e29a747f768
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T16:16:16Z

    InvokerHelper: Refactor: Remove redundant if cases, format method has them

commit f1ea00198041b322eecb0742104726248da64293
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T16:17:39Z

    InvokerHelper: Refactor: Avoid unnecessary array transformation for Object[]

commit 560c036d3f3f02f2b40dc9c753ddb2060a7f3202
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T16:28:00Z

    InvokerHelper: Safe formatting of ranges, rethrow RuntimeException without wrap.

commit fcf8558d880067e57612a137cbe3a730a468bb20
Author: Thibault Kruse <th...@gmx.de>
Date:   2015-08-21T17:44:47Z

    InvokerHelper: Regression tests for formatting

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---