[jira] [Commented] (GROOVY-7499) DelegatingScript should support resolve strategies

2015-11-26 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15028610#comment-15028610
 ] 

Jochen Kemnade commented on GROOVY-7499:


For example, the following test will fail:
{code}
public void testUsePropertiesFromDelegate() throws Exception {
  def cc = new CompilerConfiguration()
  cc.scriptBaseClass = DelegatingScript.class.name
  OutputStream os = new ByteArrayOutputStream()
  def binding = new Binding()
  binding.setProperty("out", new PrintStream(os))
  def sh = new GroovyShell(binding, cc)
  def script = sh.parse('''print("Hello World!")''')
  script.setDelegate([:])
  script.run()

  assert os.toString() == """Hello World!"""
}
}
{code}
The {{out}} property from the binding will not be used, because the delegate 
map will return {{null}} for {{getProperty("out")}}.
So, should the script's bindings have precedence over the delegate? What if the 
delegate also has an {{out}} property?
And what should happen for {{setProperty("foo", "bar")}}? Should {{foo}} be set 
inside the map or in the script binding?
Should there be 
{{setResolveStrategyForGetProperty(BINDINGS_ONLY|BINDINGS_FIRST|DELEGATE_ONLY|DELEGATE_FIRST)
 and setResolveStrategyForSetProperty(...)}}? What about {{invokeMethod}}? For 
instance, {{println}} should probably not be called on a builder.

> DelegatingScript should support resolve strategies
> --
>
> Key: GROOVY-7499
> URL: https://issues.apache.org/jira/browse/GROOVY-7499
> Project: Groovy
>  Issue Type: Improvement
>Affects Versions: 2.4.3, 2.4.4
>Reporter: Jochen Kemnade
>
> It should be possible to configure a {{DelegatingScript}} wrt. its resolution 
> strategies. In some cases, it might be desirable to try to resolve properties 
> in the script binding before trying the delegate.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Created] (GROOVY-7689) DelegatingScript should support different delegates for different operations

2015-11-26 Thread Jochen Kemnade (JIRA)
Jochen Kemnade created GROOVY-7689:
--

 Summary: DelegatingScript should support different delegates for 
different operations
 Key: GROOVY-7689
 URL: https://issues.apache.org/jira/browse/GROOVY-7689
 Project: Groovy
  Issue Type: Improvement
Affects Versions: 2.4.5
Reporter: Jochen Kemnade


I'd like to use different "inputs" and "outputs" for a script.
For example if my input is {{[ x : 2 ]}} and my output is {{[ : ]}}, 
{code}
result = 2 * x
{code}
should lead to {{output == [ result : 4 ]}}. That means, getProperty should use 
the input and setProperty should use the output.
Currently, you can only set a single delegate for DelegatingScript, so that is 
not possible.
I suggest introducing the additional methods {{setDelegateForInvokeMethod, 
setDelegateForGetProperty, and setDelegateForSetProperty}} that set the 
delegates only for the respective methods. The existing {{setDelegate}} method 
would set all the delegates to the same object.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-11-26 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15028475#comment-15028475
 ] 

Jochen Kemnade commented on GROOVY-7074:


On second thought, that is not within the scope of this issue and I don't have 
a valid use case for {{get/setProperty}} yet.

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Comment Edited] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-11-26 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15028419#comment-15028419
 ] 

Jochen Kemnade edited comment on GROOVY-7074 at 11/26/15 10:09 AM:
---

That behavior should probably be used for {{get/setProperty}} too, I'll create 
a new patch.


was (Author: jkemnade):
That behavior should probable be used for {{get/setProperty}} too, I'll create 
a new patch.

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-11-26 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15028419#comment-15028419
 ] 

Jochen Kemnade commented on GROOVY-7074:


That behavior should probable be used for {{get/setProperty}} too, I'll create 
a new patch.

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-11-26 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15028371#comment-15028371
 ] 

Jochen Kemnade commented on GROOVY-7074:


New patch based on [~shils]'s suggestions. [~blackdrag], what do you think?

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-11-26 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7074:
---
Attachment: 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-11-26 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7074:
---
Attachment: (was: 
0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch)

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Created] (GROOVY-7669) Add a method to parse a locale-specific string into a number

2015-11-10 Thread Jochen Kemnade (JIRA)
Jochen Kemnade created GROOVY-7669:
--

 Summary: Add a method to parse a locale-specific string into a 
number
 Key: GROOVY-7669
 URL: https://issues.apache.org/jira/browse/GROOVY-7669
 Project: Groovy
  Issue Type: Improvement
Affects Versions: 2.4.5
Reporter: Jochen Kemnade


Proposed implementation from my custom category:
{code}
public static BigDecimal toBigDecimal(final CharSequence self, final Locale 
locale) {
String s = self.toString().trim();
DecimalFormat numberFormat = (DecimalFormat) 
NumberFormat.getInstance(locale);
char groupingSeparator = 
numberFormat.getDecimalFormatSymbols().getGroupingSeparator();
char decimalSeparator = 
numberFormat.getDecimalFormatSymbols().getDecimalSeparator();
StringBuilder sb = new StringBuilder(s);
for (int i = sb.length() - 1; i >= 0; i--) {
  char c = sb.charAt(i);
  if (c == groupingSeparator) {
sb.replace(i, i + 1, "");
  } else if (c == decimalSeparator) {
sb.replace(i, i + 1, ".");
  }
}
s = new String(sb);

return new BigDecimal(s);
  }
{code}
tests:
{code}
  def "Parse numbers in different Locales"(){
expect:
toBigDecimal("123", Locale.US).toPlainString() == "123"
toBigDecimal("123.45", Locale.US).toPlainString() == "123.45"
toBigDecimal("1,123.45", Locale.US).toPlainString() == "1123.45"
toBigDecimal("1,123", Locale.GERMANY).toPlainString() == "1.123"
toBigDecimal("1.123,45", Locale.GERMANY).toPlainString() == "1123.45"
  }
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Created] (GROOVY-7638) it should be possible to control whether to execute the closure before or after adding it to the parent

2015-10-19 Thread Jochen Kemnade (JIRA)
Jochen Kemnade created GROOVY-7638:
--

 Summary: it should be possible to control whether to execute the 
closure before or after adding it to the parent
 Key: GROOVY-7638
 URL: https://issues.apache.org/jira/browse/GROOVY-7638
 Project: Groovy
  Issue Type: Improvement
Affects Versions: 2.4.5
Reporter: Jochen Kemnade


I have a builder that validates nodes when they are inserted into the "tree".
{noformat}
builder.with {
  node {
node2 {
  requiredChild()
}
  }
}
{noformat}
If I add node2 before adding requiredChild, the validation will fail. That 
means I'll have to have the closure called before the call to {{setParent}}. 
Currently. that means I'll have to override the whole {{doInvokeMethod}} 
method. It would be nice if I only had to override a smaller portion of 
{{BuilderSupport}} or pass some configuration to the {{BuilderSupport}} 
constructor.
I can create a patch but I'd like to know which approach I should use.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-10-06 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944961#comment-14944961
 ] 

Jochen Kemnade commented on GROOVY-7552:


Thanks for taking care of that.
Yes, the patches are the same, but they are different from the first one I 
submitted (and deleted today), which had a broken test *and* a wrong 
implementation.

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>  Components: groovy-jdk
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods-fixed.patch, 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-10-06 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7552:
---
Attachment: 
0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods-fixed.patch

New patch with new name

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>  Components: groovy-jdk
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods-fixed.patch, 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-10-06 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944840#comment-14944840
 ] 

Jochen Kemnade commented on GROOVY-7552:


That doesn't help, it's UP-TO-DATE anyway.

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>  Components: groovy-jdk
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-10-06 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944824#comment-14944824
 ] 

Jochen Kemnade commented on GROOVY-7552:


Somehow that doesn't work. Gradle (2.7) always tells me that the task is 
UP-TO-DATE.

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>  Components: groovy-jdk
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-10-06 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7552:
---
Attachment: (was: 
0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch)

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>  Components: groovy-jdk
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-10-06 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7552:
---
Attachment: 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch

Updated patch attached

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>  Components: groovy-jdk
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-10-06 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944800#comment-14944800
 ] 

Jochen Kemnade commented on GROOVY-7552:


Sure, I've seen the error already and I'm currently fixing it. Can I somehow 
run only the Javadoc test suite from the command line?

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>  Components: groovy-jdk
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-10-06 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944635#comment-14944635
 ] 

Jochen Kemnade commented on GROOVY-7074:


still in 2.4.5

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-3341) MissingMethodException in Builder is misleading

2015-10-06 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944633#comment-14944633
 ] 

Jochen Kemnade commented on GROOVY-3341:


2.4.5 is still affected. [~blackdrag], do you need anything else to be able to 
apply the patch?

> MissingMethodException in Builder is misleading
> ---
>
> Key: GROOVY-3341
> URL: https://issues.apache.org/jira/browse/GROOVY-3341
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-jdk
>Affects Versions: 1.6-beta-1
>Reporter: Noah Sloan
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-3341-If-an-exception-is-thrown-from-a-builder.patch
>
>
> Test Case:
> {code}
> class Foo extends BuilderSupport {
> public void setParent(Object parent, Object child){
> parent.setFoo(child)
> }
> public Object createNode(Object name){
> return createNode(name,(Object)null)
> }
> 
> public Object createNode(Object name, Object value){
> return createNode(name,[:],value)
> }
> 
> public Object createNode(Object name, Map attributes){
> return createNode(name,attributes,null)
> }
> 
> public Object createNode(Object name, Map attributes, Object value){
>   return "${name}"  
> }
> }
> try {
>   def f = new Foo()
>   f.foo {
> bar()
>   }
> } catch(MissingMethodException e) {
>   assert e.method == "setFoo",  "was ${e.method}"
> }
> {code}
> It's actually the method setFoo that is missing, but it is reported as bar 
> that is missing. Any MissingMethodException thrown while inside a Builder 
> will be misreported in this way.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-10-06 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7552:
---
Affects Version/s: 2.4.5

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7502) Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)

2015-10-06 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7502:
---
Affects Version/s: 2.4.5

> Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)
> --
>
> Key: GROOVY-7502
> URL: https://issues.apache.org/jira/browse/GROOVY-7502
> Project: Groovy
>  Issue Type: Wish
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7502-Add-IOGroovyMethods.getText-ByteArrayOut.patch
>
>
> A {{ByteArrayOutputStream}} can be transformed to a String via 
> {{toByteArray}}. Groovy should provide a shortcut for that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7546) Misleasing error message for null + something-that-is-not-a-string

2015-10-06 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7546:
---
Affects Version/s: (was: 2.4.4)
   2.4.5

> Misleasing error message for null + something-that-is-not-a-string
> --
>
> Key: GROOVY-7546
> URL: https://issues.apache.org/jira/browse/GROOVY-7546
> Project: Groovy
>  Issue Type: Improvement
>Affects Versions: 2.4.5
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7546-fix-NullPointerException-message-when-tr.patch
>
>
> {noformat}
> groovy:000> null + 1
> Cannot execute null+null
> groovy:000> null + []
> Cannot execute null+null
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-08-19 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7552:
---
Priority: Minor  (was: Major)

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-08-19 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7552:
---
Attachment: 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-08-19 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7552:
---
Labels: patch-available  (was: )

> add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
> --
>
> Key: GROOVY-7552
> URL: https://issues.apache.org/jira/browse/GROOVY-7552
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>  Labels: patch-available
> Attachments: 
> 0001-add-org.codehaus.groovy.runtime.DefaultGroovyMethods.patch
>
>
> {code}
> def items = [1]
> def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
> Iterator } as Iterable
> assert !iterable.isEmpty()
> iterable.next()
> assert iterable.isEmpty()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Created] (GROOVY-7552) add org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)

2015-08-19 Thread Jochen Kemnade (JIRA)
Jochen Kemnade created GROOVY-7552:
--

 Summary: add 
org.codehaus.groovy.runtime.DefaultGroovyMethods.isEmpty(Iterable)
 Key: GROOVY-7552
 URL: https://issues.apache.org/jira/browse/GROOVY-7552
 Project: Groovy
  Issue Type: Improvement
Reporter: Jochen Kemnade


{code}
def items = [1]
def iterable = { [ hasNext:{ !items.isEmpty() }, next:{ items.pop() } ] as 
Iterator } as Iterable
assert !iterable.isEmpty()
iterable.next()
assert iterable.isEmpty()
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Created] (GROOVY-7547) null values break AssertionRenderer.valueToString

2015-08-12 Thread Jochen Kemnade (JIRA)
Jochen Kemnade created GROOVY-7547:
--

 Summary: null values break AssertionRenderer.valueToString
 Key: GROOVY-7547
 URL: https://issues.apache.org/jira/browse/GROOVY-7547
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.4.4
Reporter: Jochen Kemnade


While trying to write a test for GROOVY-6958, I got the following trace:
{noformat}
java.lang.NullPointerException
at 
org.codehaus.groovy.runtime.powerassert.AssertionRenderer.javaLangObjectToString(AssertionRenderer.java:179)
at 
org.codehaus.groovy.runtime.powerassert.AssertionRenderer.valueToString(AssertionRenderer.java:166)
at 
org.codehaus.groovy.runtime.powerassert.AssertionRenderer.renderValues(AssertionRenderer.java:100)
at 
org.codehaus.groovy.runtime.powerassert.AssertionRenderer.render(AssertionRenderer.java:60)
at 
org.codehaus.groovy.runtime.powerassert.AssertionRenderer.render(AssertionRenderer.java:54)
at 
org.codehaus.groovy.runtime.NullObjectTest$_testCategory_closure2.doCall(NullObjectTest.groovy:62)
at 
org.codehaus.groovy.runtime.NullObjectTest$_testCategory_closure2.doCall(NullObjectTest.groovy)
{noformat}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7540) Add a method to StringGroovyMethods for replacing String pairs supplied as a Map

2015-08-10 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14679680#comment-14679680
 ] 

Jochen Kemnade commented on GROOVY-7540:


Looks good to me, thanks!

> Add a method to StringGroovyMethods for replacing String pairs supplied as a 
> Map
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Assignee: Paul King
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7540) Add a method to StringGroovyMethods for replacing String pairs supplied as a Map

2015-08-07 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14661696#comment-14661696
 ] 

Jochen Kemnade commented on GROOVY-7540:


Then I guess we still have to create a ReplaceState object even if we're not 
going to replace anything. But the StringBuilder init could be moved down to 
line 2888.
We could determine the correct size for the StringBuilder, but that might be 
more resource-intensive than having it expand on demand. We could just go for x 
* text.length() and hope that it will be enough. I'd prefer a larger factor 
though, maybe even 100%.

> Add a method to StringGroovyMethods for replacing String pairs supplied as a 
> Map
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7540) Add a method to StringGroovyMethods for replacing String pairs supplied as a Map

2015-08-07 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14661613#comment-14661613
 ] 

Jochen Kemnade commented on GROOVY-7540:


Is the content of {{}} run as part of the test 
suite? Neat!
It looks good to me. The StringBuilder initialization could be tweaked though, 
it could be initialized with a definite capacity to avoid calls to 
ensureCapacity later. The hard part is to know the correct size. If I'm not 
mistaken, the worst case is {noformat}text.length() * 
ceil(max(replacements.values()*.length()) / 
min(replacements.keySet()*.length()){noformat}. And if 
{noformat}replacements.keySet().find{text.indexOf(it) >= 0} == null{noformat}, 
we can exit early to improve the performance of things like 
{noformat}'foobar'.replace([x:'y']){noformat}.

> Add a method to StringGroovyMethods for replacing String pairs supplied as a 
> Map
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-3341) MissingMethodException in Builder is misleading

2015-08-06 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14659905#comment-14659905
 ] 

Jochen Kemnade commented on GROOVY-3341:


Do you need anything else?

> MissingMethodException in Builder is misleading
> ---
>
> Key: GROOVY-3341
> URL: https://issues.apache.org/jira/browse/GROOVY-3341
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-jdk
>Affects Versions: 1.6-beta-1
>Reporter: Noah Sloan
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-3341-If-an-exception-is-thrown-from-a-builder.patch
>
>
> Test Case:
> {code}
> class Foo extends BuilderSupport {
> public void setParent(Object parent, Object child){
> parent.setFoo(child)
> }
> public Object createNode(Object name){
> return createNode(name,(Object)null)
> }
> 
> public Object createNode(Object name, Object value){
> return createNode(name,[:],value)
> }
> 
> public Object createNode(Object name, Map attributes){
> return createNode(name,attributes,null)
> }
> 
> public Object createNode(Object name, Map attributes, Object value){
>   return "${name}"  
> }
> }
> try {
>   def f = new Foo()
>   f.foo {
> bar()
>   }
> } catch(MissingMethodException e) {
>   assert e.method == "setFoo",  "was ${e.method}"
> }
> {code}
> It's actually the method setFoo that is missing, but it is reported as bar 
> that is missing. Any MissingMethodException thrown while inside a Builder 
> will be misreported in this way.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7502) Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)

2015-08-06 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7502:
---
Labels: patch-available  (was: contributers-welcome patch-available)

> Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)
> --
>
> Key: GROOVY-7502
> URL: https://issues.apache.org/jira/browse/GROOVY-7502
> Project: Groovy
>  Issue Type: Wish
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7502-Add-IOGroovyMethods.getText-ByteArrayOut.patch
>
>
> A {{ByteArrayOutputStream}} can be transformed to a String via 
> {{toByteArray}}. Groovy should provide a shortcut for that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7540) Add StringGroovyMethods.collectReplacements(String, Map)

2015-08-06 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14659854#comment-14659854
 ] 

Jochen Kemnade commented on GROOVY-7540:


If we don't do "incremental" replacement, the order is only relevant for those 
cases where the source strings overlap, right?
String.replace also compiles the String to a Pattern and creates a Matcher, 
creating multiple StringBuilders and whatnot on the way. I'd like to avoid most 
of that.
I also wouldn't try to do repeats. Should we just copy the relevant parts of 
{{StringUtils}}?

> Add StringGroovyMethods.collectReplacements(String, Map)
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Comment Edited] (GROOVY-7540) Add StringGroovyMethods.collectReplacements(String, Map)

2015-08-05 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14659569#comment-14659569
 ] 

Jochen Kemnade edited comment on GROOVY-7540 at 8/6/15 6:39 AM:


{quote}
There are questions to answer though, like should the method be regex aware 
{quote}
I'm not sure. I don't need it to be regex aware, but I can see how that would 
be a nice feature. I'd like to avoid the overhead of compiling a Pattern for 
simple strings though. Also, if we allow regexes, people will want to pass in a 
pattern. We cannot provide two methods ({{Map}} and 
{{Map}}) because of type erasure, but we could allow 
{{Map}} and check the keys's types. Allowing regexes will 
definitely make things more complicated.
{quote}
and as per your earlier comment, are the transformations sequential in nature 
(the 'bar' and 'baz') alternatives
{quote}
I'd say no.
{code}
"foo".collectReplacements(["foo":"bar", "bar":"baz"])// 
should become "bar", if I want "baz", I can call
"foo".collectReplacements(["foo":"bar"]).collectReplacements(["bar":"baz"])  // 
but if the replacements are done sequentially, 
 // 
there's no way to do the "faabor" -> "foobor" example.
{code}
But I've got another one: What happens here?
{code}
"foo".collectReplacements(["f":"g", "foo":"bar"])// goo? bar? Exception?
{code}
I'd go for exception, but those cases can be hard to detect, if not impossible, 
especially if we do allow regexes. StringUtils does this:
{code}
StringUtils.replaceEach("foo", new String[] { "f", "foo" }, new String[] { "g", 
"bar" }) // => goo
StringUtils.replaceEach("foo", new String[] { "foo", "f" }, new String[] { 
"bar", "g" }) // => bar
{code}


was (Author: jkemnade):
{quote}
There are questions to answer though, like should the method be regex aware 
{quote}
I'm not sure. I don't need it to be regex aware, but I can see how that would 
be a nice feature. I'd like to avoid the overhead of compiling a Pattern for 
simple strings though. Also, if we allow regexes, people will want to pass in a 
pattern. We cannot provide two methods ({{Map}} and 
{{Map}}) because of type erasure, but we could allow 
{{Map}} and check the keys's types. Allowing regexes will 
definitely make things more complicated.
{quote}
and as per your earlier comment, are the transformations sequential in nature 
(the 'bar' and 'baz') alternatives
{quote}
I'd say no.
{code}
"foo".collectReplacements(["foo":"bar", "bar":"baz"])// 
should become "bar", if I want "baz", I can call
"foo".collectReplacements(["foo":"bar"]).collectReplacements(["bar":"baz"])  // 
but if the replacements are done sequentially, 
 // 
there's no way to do the "faabor" -> "foobor" example.
{code}
But I've got another one: What happens here?
{code}
"foo".collectReplacements(["f":"g", "foo":"bar"])// goo? bar? Exception?
{code}
I'd go for exception, but those cases can be hard to detect, if not impossible, 
especially if we do allow regexes. StringUtils does this:
{code}


> Add StringGroovyMethods.collectReplacements(String, Map)
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7540) Add StringGroovyMethods.collectReplacements(String, Map)

2015-08-05 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14659569#comment-14659569
 ] 

Jochen Kemnade commented on GROOVY-7540:


{quote}
There are questions to answer though, like should the method be regex aware 
{quote}
I'm not sure. I don't need it to be regex aware, but I can see how that would 
be a nice feature. I'd like to avoid the overhead of compiling a Pattern for 
simple strings though. Also, if we allow regexes, people will want to pass in a 
pattern. We cannot provide two methods ({{Map}} and 
{{Map}}) because of type erasure, but we could allow 
{{Map}} and check the keys's types. Allowing regexes will 
definitely make things more complicated.
{quote}
and as per your earlier comment, are the transformations sequential in nature 
(the 'bar' and 'baz') alternatives
{quote}
I'd say no.
{code}
"foo".collectReplacements(["foo":"bar", "bar":"baz"])// 
should become "bar", if I want "baz", I can call
"foo".collectReplacements(["foo":"bar"]).collectReplacements(["bar":"baz"])  // 
but if the replacements are done sequentially, 
 // 
there's no way to do the "faabor" -> "foobor" example.
{code}
But I've got another one: What happens here?
{code}
"foo".collectReplacements(["f":"g", "foo":"bar"])// goo? bar? Exception?
{code}
I'd go for exception, but those cases can be hard to detect, if not impossible, 
especially if we do allow regexes. StringUtils does this:
{code}


> Add StringGroovyMethods.collectReplacements(String, Map)
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7540) Add StringGroovyMethods.collectReplacements(String, Map)

2015-08-05 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14655275#comment-14655275
 ] 

Jochen Kemnade commented on GROOVY-7540:


Well, I need to be able to use both single- and multi-char strings as source 
and replacement. And {{tr}} also does conversion to list and back again. I can 
live with using {{StringUtils}}, but I'd like to see the functionality built 
into Groovy. But I'm okay if you say the request is invalid.

> Add StringGroovyMethods.collectReplacements(String, Map)
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Comment Edited] (GROOVY-7540) Add StringGroovyMethods.collectReplacements(String, Map)

2015-08-04 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14654896#comment-14654896
 ] 

Jochen Kemnade edited comment on GROOVY-7540 at 8/5/15 6:41 AM:


Yes, of course, there are ways to do it, but I'd like to do it as efficiently 
as possible. I've ended up delegating to 
{{org.apache.commons.lang3.StringUtils.replaceEach(String, String[], 
String[])}}.
I think the {{collectReplacements}} with a closure needs to work 
character-wise. Making it work with multi-character strings would be quite 
complicated to implement and to use as well.


was (Author: jkemnade):
Yes, of course, there are ways to do it. I've ended up delegating to 
{{org.apache.commons.lang3.StringUtils.replaceEach(String, String[], 
String[])}}.
I think the {{collectReplacements}} with a closure needs to work 
character-wise. Making it work with multi-character strings would be quite 
complicated to implement and to use as well.

> Add StringGroovyMethods.collectReplacements(String, Map)
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7540) Add StringGroovyMethods.collectReplacements(String, Map)

2015-08-04 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14654896#comment-14654896
 ] 

Jochen Kemnade commented on GROOVY-7540:


Yes, of course, there are ways to do it. I've ended up delegating to 
{{org.apache.commons.lang3.StringUtils.replaceEach(String, String[], 
String[])}}.
I think the {{collectReplacements}} with a closure needs to work 
character-wise. Making it work with multi-character strings would be quite 
complicated to implement and to use as well.

> Add StringGroovyMethods.collectReplacements(String, Map)
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7540) Add StringGroovyMethods.collectReplacements(String, Map)

2015-08-04 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14653199#comment-14653199
 ] 

Jochen Kemnade commented on GROOVY-7540:


If we allow strings as keys, this becomes difficult if the values "overlap":
{code}
"foobar".collectReplacements(["o":"a", "a":"o"]) // should become "faabor", not 
"foobor"
"foo".collectReplacements(["foo":"bar", "bar":"baz"]) // should become "bar"... 
I guess...
{code}



> Add StringGroovyMethods.collectReplacements(String, Map)
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7540) Add StringGroovyMethods.collectReplacements(String, Map)

2015-08-03 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7540:
---
  Priority: Minor  (was: Major)
Issue Type: Improvement  (was: Bug)

> Add StringGroovyMethods.collectReplacements(String, Map)
> 
>
> Key: GROOVY-7540
> URL: https://issues.apache.org/jira/browse/GROOVY-7540
> Project: Groovy
>  Issue Type: Improvement
>Reporter: Jochen Kemnade
>Priority: Minor
>
> It should be possible to use a map with {{collectReplacements}}, like in
> {code}
> "f006ar".collectReplacements(["0":"o", "6":"b"])
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Created] (GROOVY-7540) Add StringGroovyMethods.collectReplacements(String, Map)

2015-08-03 Thread Jochen Kemnade (JIRA)
Jochen Kemnade created GROOVY-7540:
--

 Summary: Add StringGroovyMethods.collectReplacements(String, Map)
 Key: GROOVY-7540
 URL: https://issues.apache.org/jira/browse/GROOVY-7540
 Project: Groovy
  Issue Type: Bug
Reporter: Jochen Kemnade


It should be possible to use a map with {{collectReplacements}}, like in
{code}
"f006ar".collectReplacements(["0":"o", "6":"b"])
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-6958) null != NullObject when using Categories

2015-07-23 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-6958?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-6958:
---
Affects Version/s: 2.4.4

> null != NullObject when using Categories
> 
>
> Key: GROOVY-6958
> URL: https://issues.apache.org/jira/browse/GROOVY-6958
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.4, 2.4.0-rc-2, 2.4.1, 2.4.4, 2.5.0-beta-1
>Reporter: Jochen Kemnade
>Priority: Minor
>
> {code}
> def val = null
> class Helper {
>   
>   static boolean isNull(value) {
> value == null 
>   }
>   
> }
> use(Helper){
>   assert val == null
>   assert val.isNull()
> }
> {code}
> The last assertion fails because value isnt {{null}} but a {{NullObject}} and 
> inside the {{isNull}} method, those are apparently not equal.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-6958) null != NullObject when using Categories

2015-07-23 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-6958?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-6958:
---
Affects Version/s: 2.5.0-beta-1

> null != NullObject when using Categories
> 
>
> Key: GROOVY-6958
> URL: https://issues.apache.org/jira/browse/GROOVY-6958
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.4, 2.4.0-rc-2, 2.4.1, 2.4.4, 2.5.0-beta-1
>Reporter: Jochen Kemnade
>Priority: Minor
>
> {code}
> def val = null
> class Helper {
>   
>   static boolean isNull(value) {
> value == null 
>   }
>   
> }
> use(Helper){
>   assert val == null
>   assert val.isNull()
> }
> {code}
> The last assertion fails because value isnt {{null}} but a {{NullObject}} and 
> inside the {{isNull}} method, those are apparently not equal.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7502) Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)

2015-07-23 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7502:
---
Labels: contributers-welcome patch-available  (was: contributers-welcome)

> Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)
> --
>
> Key: GROOVY-7502
> URL: https://issues.apache.org/jira/browse/GROOVY-7502
> Project: Groovy
>  Issue Type: Wish
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: contributers-welcome, patch-available
> Attachments: 
> 0001-GROOVY-7502-Add-IOGroovyMethods.getText-ByteArrayOut.patch
>
>
> A {{ByteArrayOutputStream}} can be transformed to a String via 
> {{toByteArray}}. Groovy should provide a shortcut for that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7502) Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)

2015-07-23 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7502:
---
Attachment: 0001-GROOVY-7502-Add-IOGroovyMethods.getText-ByteArrayOut.patch

> Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)
> --
>
> Key: GROOVY-7502
> URL: https://issues.apache.org/jira/browse/GROOVY-7502
> Project: Groovy
>  Issue Type: Wish
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: contributers-welcome, patch-available
> Attachments: 
> 0001-GROOVY-7502-Add-IOGroovyMethods.getText-ByteArrayOut.patch
>
>
> A {{ByteArrayOutputStream}} can be transformed to a String via 
> {{toByteArray}}. Groovy should provide a shortcut for that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7502) Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)

2015-07-23 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14638959#comment-14638959
 ] 

Jochen Kemnade commented on GROOVY-7502:


Is it sufficient to add the method to {{IOGroovyMethods}} or do I need to touch 
{{DefaultGroovyMethods}} as well?

> Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)
> --
>
> Key: GROOVY-7502
> URL: https://issues.apache.org/jira/browse/GROOVY-7502
> Project: Groovy
>  Issue Type: Wish
>Reporter: Jochen Kemnade
>Priority: Minor
>  Labels: contributers-welcome
>
> A {{ByteArrayOutputStream}} can be transformed to a String via 
> {{toByteArray}}. Groovy should provide a shortcut for that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-07-23 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14638895#comment-14638895
 ] 

Jochen Kemnade commented on GROOVY-7074:


No, the metaclass doesn't seem to change, at lest it's the same before and 
after the script's execution. I think the reason is that for a Builder, we need 
to invoke the method on the Builder itself and not on the metaClass. 
{{InvokerHelper#invokePogoMethod}} does that in line 920 (2.4.4).

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Comment Edited] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-07-23 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14638895#comment-14638895
 ] 

Jochen Kemnade edited comment on GROOVY-7074 at 7/23/15 2:21 PM:
-

No, the metaclass doesn't seem to change, at lest it's the same before and 
after the script's execution. I think the reason is that for a Builder (and any 
other object that overrides 
{{groovy.lang.GroovyObjectSupport.invokeMethod(String, Object)}}), we need to 
invoke the {{invokeMethod}} method on the Builder itself and not on the 
metaClass. {{InvokerHelper#invokePogoMethod}} does that in line 920 (2.4.4).


was (Author: jkemnade):
No, the metaclass doesn't seem to change, at lest it's the same before and 
after the script's execution. I think the reason is that for a Builder, we need 
to invoke the {{invokeMethod}} method on the Builder itself and not on the 
metaClass. {{InvokerHelper#invokePogoMethod}} does that in line 920 (2.4.4).

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Comment Edited] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-07-23 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14638895#comment-14638895
 ] 

Jochen Kemnade edited comment on GROOVY-7074 at 7/23/15 2:20 PM:
-

No, the metaclass doesn't seem to change, at lest it's the same before and 
after the script's execution. I think the reason is that for a Builder, we need 
to invoke the {{invokeMethod}} method on the Builder itself and not on the 
metaClass. {{InvokerHelper#invokePogoMethod}} does that in line 920 (2.4.4).


was (Author: jkemnade):
No, the metaclass doesn't seem to change, at lest it's the same before and 
after the script's execution. I think the reason is that for a Builder, we need 
to invoke the method on the Builder itself and not on the metaClass. 
{{InvokerHelper#invokePogoMethod}} does that in line 920 (2.4.4).

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-3341) MissingMethodException in Builder is misleading

2015-07-23 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14638831#comment-14638831
 ] 

Jochen Kemnade commented on GROOVY-3341:


Just go ahead and {{git am}} it. I've signed the CLA so there shouldn't be any 
legal issues.

> MissingMethodException in Builder is misleading
> ---
>
> Key: GROOVY-3341
> URL: https://issues.apache.org/jira/browse/GROOVY-3341
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-jdk
>Affects Versions: 1.6-beta-1
>Reporter: Noah Sloan
>Priority: Minor
>  Labels: patch-available
> Attachments: 
> 0001-GROOVY-3341-If-an-exception-is-thrown-from-a-builder.patch
>
>
> Test Case:
> {code}
> class Foo extends BuilderSupport {
> public void setParent(Object parent, Object child){
> parent.setFoo(child)
> }
> public Object createNode(Object name){
> return createNode(name,(Object)null)
> }
> 
> public Object createNode(Object name, Object value){
> return createNode(name,[:],value)
> }
> 
> public Object createNode(Object name, Map attributes){
> return createNode(name,attributes,null)
> }
> 
> public Object createNode(Object name, Map attributes, Object value){
>   return "${name}"  
> }
> }
> try {
>   def f = new Foo()
>   f.foo {
> bar()
>   }
> } catch(MissingMethodException e) {
>   assert e.method == "setFoo",  "was ${e.method}"
> }
> {code}
> It's actually the method setFoo that is missing, but it is reported as bar 
> that is missing. Any MissingMethodException thrown while inside a Builder 
> will be misreported in this way.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-07-23 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7074:
---
Attachment: 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch

Test and fix for {{GROOVY_2_4_X}} branch

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
> Attachments: 
> 0001-GROOVY-7074-fix-for-using-a-Builder-as-delegate-in-a.patch
>
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7499) DelegatingScript should support resolve strategies

2015-07-23 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7499?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7499:
---
Affects Version/s: 2.4.4

> DelegatingScript should support resolve strategies
> --
>
> Key: GROOVY-7499
> URL: https://issues.apache.org/jira/browse/GROOVY-7499
> Project: Groovy
>  Issue Type: Improvement
>Affects Versions: 2.4.3, 2.4.4
>Reporter: Jochen Kemnade
>
> It should be possible to configure a {{DelegatingScript}} wrt. its resolution 
> strategies. In some cases, it might be desirable to try to resolve properties 
> in the script binding before trying the delegate.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-3341) MissingMethodException in Builder is misleading

2015-07-23 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-3341:
---
Attachment: 0001-GROOVY-3341-If-an-exception-is-thrown-from-a-builder.patch

This affects recent Groovy versions (including 2.5 snapshots) as well. Patch 
and test for {{GROOVY_2_4_X}} branch attached.

> MissingMethodException in Builder is misleading
> ---
>
> Key: GROOVY-3341
> URL: https://issues.apache.org/jira/browse/GROOVY-3341
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-jdk
>Affects Versions: 1.6-beta-1
>Reporter: Noah Sloan
>Priority: Minor
> Attachments: 
> 0001-GROOVY-3341-If-an-exception-is-thrown-from-a-builder.patch
>
>
> Test Case:
> {code}
> class Foo extends BuilderSupport {
> public void setParent(Object parent, Object child){
> parent.setFoo(child)
> }
> public Object createNode(Object name){
> return createNode(name,(Object)null)
> }
> 
> public Object createNode(Object name, Object value){
> return createNode(name,[:],value)
> }
> 
> public Object createNode(Object name, Map attributes){
> return createNode(name,attributes,null)
> }
> 
> public Object createNode(Object name, Map attributes, Object value){
>   return "${name}"  
> }
> }
> try {
>   def f = new Foo()
>   f.foo {
> bar()
>   }
> } catch(MissingMethodException e) {
>   assert e.method == "setFoo",  "was ${e.method}"
> }
> {code}
> It's actually the method setFoo that is missing, but it is reported as bar 
> that is missing. Any MissingMethodException thrown while inside a Builder 
> will be misreported in this way.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Closed] (GROOVY-7156) Builders behave strange when closures throw MissingMethodException

2015-07-23 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade closed GROOVY-7156.
--
Resolution: Duplicate

Duplicate of GROOVY-3341.

> Builders behave strange when closures throw MissingMethodException
> --
>
> Key: GROOVY-7156
> URL: https://issues.apache.org/jira/browse/GROOVY-7156
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.7, 2.4.0-rc-2, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4
>Reporter: Jochen Kemnade
> Attachments: groovy-7156.zip
>
>
> I noticed some strange behavior when closures inside a builder throw 
> exceptions:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class TestBuilder extends BuilderSupport {
>   Object createNode(Object name, Map map){
> println "Create node $name: $map"
> new Node(null, name, map)
>   }
>   Object createNode(Object name){
> println "Create node $name"
> new Node(null, name)
>   }
>   Object createNode(Object name, Object value){
> println "Create node $name, value $value"
> new Node(null, name, value)
>   }
>   Object createNode(Object name, Map map, Object value){
> println "Create node $name: $map, value $value"
> new Node(null, name, map, value)
>   }
>   void setParent(Object parent, Object child){
> println "set parent of $child to $parent"
> ((Node)parent).append( (Node) child)
>   }
> }
> def builder = new TestBuilder()
> // First case
> // expected: MissingMethodException tring to call String.foo()
> // actual: MissingMethodException tring to call b(Closure)
> try {
>   builder.a {
> b {
>   error('xy'.foo())
> }
>   }
> }catch (e){
>   assert e instanceof MissingMethodException
>   assert e.method == "foo"
> }
> // Second case
> // expected: one call to buidler.createNode('b')
> // actual: two calls to buidler.createNode('b')
> builder.with {
>   a {
> b {
>   error("xy".foo())
> }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7156) Builders behave strange when closures throw MissingMethodException

2015-07-22 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14636969#comment-14636969
 ] 

Jochen Kemnade commented on GROOVY-7156:


I think I've got a fix: Inside 
{{groovy.util.BuilderSupport.doInvokeMethod(String, Object, Object)}}, wrap the 
{{closure.call();}} in a try-catch block and re-throw the exception wrapped in 
a {{GroovyRuntimeException}}. I'l see if I can come up with a test and a patch.

> Builders behave strange when closures throw MissingMethodException
> --
>
> Key: GROOVY-7156
> URL: https://issues.apache.org/jira/browse/GROOVY-7156
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.7, 2.4.0-rc-2, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4
>Reporter: Jochen Kemnade
> Attachments: groovy-7156.zip
>
>
> I noticed some strange behavior when closures inside a builder throw 
> exceptions:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class TestBuilder extends BuilderSupport {
>   Object createNode(Object name, Map map){
> println "Create node $name: $map"
> new Node(null, name, map)
>   }
>   Object createNode(Object name){
> println "Create node $name"
> new Node(null, name)
>   }
>   Object createNode(Object name, Object value){
> println "Create node $name, value $value"
> new Node(null, name, value)
>   }
>   Object createNode(Object name, Map map, Object value){
> println "Create node $name: $map, value $value"
> new Node(null, name, map, value)
>   }
>   void setParent(Object parent, Object child){
> println "set parent of $child to $parent"
> ((Node)parent).append( (Node) child)
>   }
> }
> def builder = new TestBuilder()
> // First case
> // expected: MissingMethodException tring to call String.foo()
> // actual: MissingMethodException tring to call b(Closure)
> try {
>   builder.a {
> b {
>   error('xy'.foo())
> }
>   }
> }catch (e){
>   assert e instanceof MissingMethodException
>   assert e.method == "foo"
> }
> // Second case
> // expected: one call to buidler.createNode('b')
> // actual: two calls to buidler.createNode('b')
> builder.with {
>   a {
> b {
>   error("xy".foo())
> }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7156) Builders behave strange when closures throw MissingMethodException

2015-07-22 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14636947#comment-14636947
 ] 

Jochen Kemnade commented on GROOVY-7156:


It's apparently related to the exception type. I assume the 
MissingMethodException is caught and turned into something else. I'm not too 
familiar with Groovy's internals, but if someone can give me a hint where this 
is happening, I can try to create a patch.

> Builders behave strange when closures throw MissingMethodException
> --
>
> Key: GROOVY-7156
> URL: https://issues.apache.org/jira/browse/GROOVY-7156
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.7, 2.4.0-rc-2, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4
>Reporter: Jochen Kemnade
> Attachments: groovy-7156.zip
>
>
> I noticed some strange behavior when closures inside a builder throw 
> exceptions:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class TestBuilder extends BuilderSupport {
>   Object createNode(Object name, Map map){
> println "Create node $name: $map"
> new Node(null, name, map)
>   }
>   Object createNode(Object name){
> println "Create node $name"
> new Node(null, name)
>   }
>   Object createNode(Object name, Object value){
> println "Create node $name, value $value"
> new Node(null, name, value)
>   }
>   Object createNode(Object name, Map map, Object value){
> println "Create node $name: $map, value $value"
> new Node(null, name, map, value)
>   }
>   void setParent(Object parent, Object child){
> println "set parent of $child to $parent"
> ((Node)parent).append( (Node) child)
>   }
> }
> def builder = new TestBuilder()
> // First case
> // expected: MissingMethodException tring to call String.foo()
> // actual: MissingMethodException tring to call b(Closure)
> try {
>   builder.a {
> b {
>   error('xy'.foo())
> }
>   }
> }catch (e){
>   assert e instanceof MissingMethodException
>   assert e.method == "foo"
> }
> // Second case
> // expected: one call to buidler.createNode('b')
> // actual: two calls to buidler.createNode('b')
> builder.with {
>   a {
> b {
>   error("xy".foo())
> }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7156) Builders behave strange when closures throw MissingMethodException

2015-07-22 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7156:
---
Summary: Builders behave strange when closures throw MissingMethodException 
 (was: Builders behave strange when closures throw exceptions)

> Builders behave strange when closures throw MissingMethodException
> --
>
> Key: GROOVY-7156
> URL: https://issues.apache.org/jira/browse/GROOVY-7156
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.7, 2.4.0-rc-2, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4
>Reporter: Jochen Kemnade
> Attachments: groovy-7156.zip
>
>
> I noticed some strange behavior when closures inside a builder throw 
> exceptions:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class TestBuilder extends BuilderSupport {
>   Object createNode(Object name, Map map){
> println "Create node $name: $map"
> new Node(null, name, map)
>   }
>   Object createNode(Object name){
> println "Create node $name"
> new Node(null, name)
>   }
>   Object createNode(Object name, Object value){
> println "Create node $name, value $value"
> new Node(null, name, value)
>   }
>   Object createNode(Object name, Map map, Object value){
> println "Create node $name: $map, value $value"
> new Node(null, name, map, value)
>   }
>   void setParent(Object parent, Object child){
> println "set parent of $child to $parent"
> ((Node)parent).append( (Node) child)
>   }
> }
> def builder = new TestBuilder()
> // First case
> // expected: MissingMethodException tring to call String.foo()
> // actual: MissingMethodException tring to call b(Closure)
> try {
>   builder.a {
> b {
>   error('xy'.foo())
> }
>   }
> }catch (e){
>   assert e instanceof MissingMethodException
>   assert e.method == "foo"
> }
> // Second case
> // expected: one call to buidler.createNode('b')
> // actual: two calls to buidler.createNode('b')
> builder.with {
>   a {
> b {
>   error("xy".foo())
> }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7156) Builders behave strange when closures throw exceptions

2015-07-22 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14636907#comment-14636907
 ] 

Jochen Kemnade commented on GROOVY-7156:


And groovy-binary-2.5.0-20150722.114831-291.zip is affected too.

> Builders behave strange when closures throw exceptions
> --
>
> Key: GROOVY-7156
> URL: https://issues.apache.org/jira/browse/GROOVY-7156
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.7, 2.4.0-rc-2, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4
>Reporter: Jochen Kemnade
> Attachments: groovy-7156.zip
>
>
> I noticed some strange behavior when closures inside a builder throw 
> exceptions:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class TestBuilder extends BuilderSupport {
>   Object createNode(Object name, Map map){
> println "Create node $name: $map"
> new Node(null, name, map)
>   }
>   Object createNode(Object name){
> println "Create node $name"
> new Node(null, name)
>   }
>   Object createNode(Object name, Object value){
> println "Create node $name, value $value"
> new Node(null, name, value)
>   }
>   Object createNode(Object name, Map map, Object value){
> println "Create node $name: $map, value $value"
> new Node(null, name, map, value)
>   }
>   void setParent(Object parent, Object child){
> println "set parent of $child to $parent"
> ((Node)parent).append( (Node) child)
>   }
> }
> def builder = new TestBuilder()
> // First case
> // expected: MissingMethodException tring to call String.foo()
> // actual: MissingMethodException tring to call b(Closure)
> try {
>   builder.a {
> b {
>   error('xy'.foo())
> }
>   }
> }catch (e){
>   assert e instanceof MissingMethodException
>   assert e.method == "foo"
> }
> // Second case
> // expected: one call to buidler.createNode('b')
> // actual: two calls to buidler.createNode('b')
> builder.with {
>   a {
> b {
>   error("xy".foo())
> }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7156) Builders behave strange when closures throw exceptions

2015-07-22 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7156:
---
Affects Version/s: 2.4.4

> Builders behave strange when closures throw exceptions
> --
>
> Key: GROOVY-7156
> URL: https://issues.apache.org/jira/browse/GROOVY-7156
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.7, 2.4.0-rc-2, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4
>Reporter: Jochen Kemnade
> Attachments: groovy-7156.zip
>
>
> I noticed some strange behavior when closures inside a builder throw 
> exceptions:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class TestBuilder extends BuilderSupport {
>   Object createNode(Object name, Map map){
> println "Create node $name: $map"
> new Node(null, name, map)
>   }
>   Object createNode(Object name){
> println "Create node $name"
> new Node(null, name)
>   }
>   Object createNode(Object name, Object value){
> println "Create node $name, value $value"
> new Node(null, name, value)
>   }
>   Object createNode(Object name, Map map, Object value){
> println "Create node $name: $map, value $value"
> new Node(null, name, map, value)
>   }
>   void setParent(Object parent, Object child){
> println "set parent of $child to $parent"
> ((Node)parent).append( (Node) child)
>   }
> }
> def builder = new TestBuilder()
> // First case
> // expected: MissingMethodException tring to call String.foo()
> // actual: MissingMethodException tring to call b(Closure)
> try {
>   builder.a {
> b {
>   error('xy'.foo())
> }
>   }
> }catch (e){
>   assert e instanceof MissingMethodException
>   assert e.method == "foo"
> }
> // Second case
> // expected: one call to buidler.createNode('b')
> // actual: two calls to buidler.createNode('b')
> builder.with {
>   a {
> b {
>   error("xy".foo())
> }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Comment Edited] (GROOVY-7156) Builders behave strange when closures throw exceptions

2015-07-22 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14636882#comment-14636882
 ] 

Jochen Kemnade edited comment on GROOVY-7156 at 7/22/15 1:06 PM:
-

Just checked 2.4.4, no change. And I just noticed that the second test in the 
compiled version doesn't work correctly either, it also calls 
{{builder.createNode('b')}} twice.


was (Author: jkemnade):
Just checked 2.4.4, no change. And I just noticed that the second test in the 
compiled version doesn't work correctly either, it also calls 
{{buidler.createNode('b')}} twice.

> Builders behave strange when closures throw exceptions
> --
>
> Key: GROOVY-7156
> URL: https://issues.apache.org/jira/browse/GROOVY-7156
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.7, 2.4.0-rc-2, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4
>Reporter: Jochen Kemnade
> Attachments: groovy-7156.zip
>
>
> I noticed some strange behavior when closures inside a builder throw 
> exceptions:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class TestBuilder extends BuilderSupport {
>   Object createNode(Object name, Map map){
> println "Create node $name: $map"
> new Node(null, name, map)
>   }
>   Object createNode(Object name){
> println "Create node $name"
> new Node(null, name)
>   }
>   Object createNode(Object name, Object value){
> println "Create node $name, value $value"
> new Node(null, name, value)
>   }
>   Object createNode(Object name, Map map, Object value){
> println "Create node $name: $map, value $value"
> new Node(null, name, map, value)
>   }
>   void setParent(Object parent, Object child){
> println "set parent of $child to $parent"
> ((Node)parent).append( (Node) child)
>   }
> }
> def builder = new TestBuilder()
> // First case
> // expected: MissingMethodException tring to call String.foo()
> // actual: MissingMethodException tring to call b(Closure)
> try {
>   builder.a {
> b {
>   error('xy'.foo())
> }
>   }
> }catch (e){
>   assert e instanceof MissingMethodException
>   assert e.method == "foo"
> }
> // Second case
> // expected: one call to buidler.createNode('b')
> // actual: two calls to buidler.createNode('b')
> builder.with {
>   a {
> b {
>   error("xy".foo())
> }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7156) Builders behave strange when closures throw exceptions

2015-07-22 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14636882#comment-14636882
 ] 

Jochen Kemnade commented on GROOVY-7156:


Just checked 2.4.4, no change. And I just noticed that the second test in the 
compiled version doesn't work correctly either, it also calls 
{{buidler.createNode('b')}} twice.

> Builders behave strange when closures throw exceptions
> --
>
> Key: GROOVY-7156
> URL: https://issues.apache.org/jira/browse/GROOVY-7156
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.7, 2.4.0-rc-2, 2.4.0, 2.4.1, 2.4.2, 2.4.3
>Reporter: Jochen Kemnade
> Attachments: groovy-7156.zip
>
>
> I noticed some strange behavior when closures inside a builder throw 
> exceptions:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class TestBuilder extends BuilderSupport {
>   Object createNode(Object name, Map map){
> println "Create node $name: $map"
> new Node(null, name, map)
>   }
>   Object createNode(Object name){
> println "Create node $name"
> new Node(null, name)
>   }
>   Object createNode(Object name, Object value){
> println "Create node $name, value $value"
> new Node(null, name, value)
>   }
>   Object createNode(Object name, Map map, Object value){
> println "Create node $name: $map, value $value"
> new Node(null, name, map, value)
>   }
>   void setParent(Object parent, Object child){
> println "set parent of $child to $parent"
> ((Node)parent).append( (Node) child)
>   }
> }
> def builder = new TestBuilder()
> // First case
> // expected: MissingMethodException tring to call String.foo()
> // actual: MissingMethodException tring to call b(Closure)
> try {
>   builder.a {
> b {
>   error('xy'.foo())
> }
>   }
> }catch (e){
>   assert e instanceof MissingMethodException
>   assert e.method == "foo"
> }
> // Second case
> // expected: one call to buidler.createNode('b')
> // actual: two calls to buidler.createNode('b')
> builder.with {
>   a {
> b {
>   error("xy".foo())
> }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Created] (GROOVY-7502) Add org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)

2015-07-12 Thread Jochen Kemnade (JIRA)
Jochen Kemnade created GROOVY-7502:
--

 Summary: Add 
org.codehaus.groovy.runtime.IOGroovyMethods.getText(ByteArrayOutputStream)
 Key: GROOVY-7502
 URL: https://issues.apache.org/jira/browse/GROOVY-7502
 Project: Groovy
  Issue Type: Wish
Reporter: Jochen Kemnade
Priority: Minor


A {{ByteArrayOutputStream}} can be transformed to a String via {{toByteArray}}. 
Groovy should provide a shortcut for that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Created] (GROOVY-7499) DelegatingScript should support resolve strategies

2015-07-10 Thread Jochen Kemnade (JIRA)
Jochen Kemnade created GROOVY-7499:
--

 Summary: DelegatingScript should support resolve strategies
 Key: GROOVY-7499
 URL: https://issues.apache.org/jira/browse/GROOVY-7499
 Project: Groovy
  Issue Type: Improvement
Affects Versions: 2.4.3
Reporter: Jochen Kemnade


It should be possible to configure a {{DelegatingScript}} wrt. its resolution 
strategies. In some cases, it might be desirable to try to resolve properties 
in the script binding before trying the delegate.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-07-10 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=1468#comment-1468
 ] 

Jochen Kemnade commented on GROOVY-7074:


What about changing {{DelegatingScript}} to call 
{{InvokerHelper.invokeMethod(delegate, name, args)}} instead of 
{{metaClass.invokeMethod(delegate,name,args)}}?

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7074) DelegatingScript does not work with Builder as delegate

2015-07-10 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-7074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14622177#comment-14622177
 ] 

Jochen Kemnade commented on GROOVY-7074:


Still an issue with 2.4.3. 

> DelegatingScript does not work with Builder as delegate
> ---
>
> Key: GROOVY-7074
> URL: https://issues.apache.org/jira/browse/GROOVY-7074
> Project: Groovy
>  Issue Type: Bug
>  Components: GroovyScriptEngine
>Affects Versions: 2.4.0-beta-3
> Environment: Windows 7, Linux Mint 16 Petra
>Reporter: Tobias Schulte
>
> DelegatingScript does not work, if the delegate is e.g. a MarkupBuilder 
> instance.
> import org.codehaus.groovy.control.CompilerConfiguration
> import groovy.xml.MarkupBuilder
> def cc = new CompilerConfiguration()
> cc.scriptBaseClass = DelegatingScript.class.name
> def sh = new GroovyShell(new Binding(), cc)
> def script = sh.parse('''
> foo {
> bar()
> }
> ''')
> def markupBuilder = new MarkupBuilder()
> script.setDelegate(markupBuilder)
> script.run()
> does throw a groovy.lang.MissingMethodException. If I change the script to
> delegate.foo {
> bar()
> }
> it works.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (GROOVY-7156) Builders behave strange when closures throw exceptions

2015-05-11 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-7156?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated GROOVY-7156:
---
Affects Version/s: 2.4.3

> Builders behave strange when closures throw exceptions
> --
>
> Key: GROOVY-7156
> URL: https://issues.apache.org/jira/browse/GROOVY-7156
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.7, 2.4.0-rc-2, 2.4.0, 2.4.1, 2.4.2, 2.4.3
>Reporter: Jochen Kemnade
> Attachments: groovy-7156.zip
>
>
> I noticed some strange behavior when closures inside a builder throw 
> exceptions:
> {code}
> import groovy.transform.TypeChecked
> @TypeChecked
> class TestBuilder extends BuilderSupport {
>   Object createNode(Object name, Map map){
> println "Create node $name: $map"
> new Node(null, name, map)
>   }
>   Object createNode(Object name){
> println "Create node $name"
> new Node(null, name)
>   }
>   Object createNode(Object name, Object value){
> println "Create node $name, value $value"
> new Node(null, name, value)
>   }
>   Object createNode(Object name, Map map, Object value){
> println "Create node $name: $map, value $value"
> new Node(null, name, map, value)
>   }
>   void setParent(Object parent, Object child){
> println "set parent of $child to $parent"
> ((Node)parent).append( (Node) child)
>   }
> }
> def builder = new TestBuilder()
> // First case
> // expected: MissingMethodException tring to call String.foo()
> // actual: MissingMethodException tring to call b(Closure)
> try {
>   builder.a {
> b {
>   error('xy'.foo())
> }
>   }
> }catch (e){
>   assert e instanceof MissingMethodException
>   assert e.method == "foo"
> }
> // Second case
> // expected: one call to buidler.createNode('b')
> // actual: two calls to buidler.createNode('b')
> builder.with {
>   a {
> b {
>   error("xy".foo())
> }
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)