groovy

select code in groovyconsole and fails to execute selected code via ctrl + enter

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.1-rc-1
  • Fix Version/s: 1.1-rc-2
  • Component/s: Groovysh
  • Labels:
    None
  • Number of attachments :
    0

Description

select code in groovyconsole and fails to execute selected code via ctrl + enter

Activity

Hide
Daniel.Sun added a comment -
test.groovy
class Person {
    String name
}
Person person = new Person()
person.name = "Daniel"
println person.name

If I select code

class Person {
    String name
}
Person person = new Person()
person.name = "Daniel"

and ctrl + enter to execute it.

Groovy Console complains:

groovy> class Person { groovy> String name groovy> }
groovy> Person person = new Person()
groovy> person.name = "Dan

Exception thrown: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script9: 5: unexpected char: 0xFFFF @ line 5, column 19.
1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script9: 5: unexpected char: 0xFFFF @ line 5, column 19.
1 error

Show
Daniel.Sun added a comment -
test.groovy
class Person {
    String name
}
Person person = new Person()
person.name = "Daniel"
println person.name
If I select code
class Person {
    String name
}
Person person = new Person()
person.name = "Daniel"
and ctrl + enter to execute it. Groovy Console complains: groovy> class Person { groovy> String name groovy> } groovy> Person person = new Person() groovy> person.name = "Dan Exception thrown: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script9: 5: unexpected char: 0xFFFF @ line 5, column 19. 1 error org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script9: 5: unexpected char: 0xFFFF @ line 5, column 19. 1 error
Hide
Daniel.Sun added a comment -

I'm using groovy1.1rc1 and jdk6u3 on winxp.

Show
Daniel.Sun added a comment - I'm using groovy1.1rc1 and jdk6u3 on winxp.
Hide
Hamlet D'Arcy added a comment -

I was unable to reproduce this using JDK 5.12 on Win XP.

However, I got the exact same exception if I only selected this:
<raw>
class Person {
String name
}
Person person = new Person()
person.name = "Dan
</raw>

Silly question, but are you sure the entire line was selected? If you were then I'll upgrade my JDK and try again.

Show
Hamlet D'Arcy added a comment - I was unable to reproduce this using JDK 5.12 on Win XP. However, I got the exact same exception if I only selected this: <raw> class Person { String name } Person person = new Person() person.name = "Dan </raw> Silly question, but are you sure the entire line was selected? If you were then I'll upgrade my JDK and try again.
Hide
Daniel.Sun added a comment -

> but are you sure the entire line was selected?
I tried again and the issue exactly exists.

I'm using jdk6u3 on winxp.

Thanks,
Daniel.Sun

Show
Daniel.Sun added a comment - > but are you sure the entire line was selected? I tried again and the issue exactly exists. I'm using jdk6u3 on winxp. Thanks, Daniel.Sun
Hide
Danno Ferrin added a comment -

This looks like an intentional piece of code introduced by dierk. Basically, the scriptRun command is sensitive to the selected text. If there is no selection, all of the text is run. If there is a selection, only the selectoin is run,

This amounts to a feature that is poorly documented and in it's current form is of questionalble usability.

My recommendation is to either (a) remove it or (b) make it explicit, add a Script->run and Script->run selected option (ctrl-R and ctrl-shift-R with ctrl-enter and ctrl-shift-enter as well, respectively).

Assigning to Dierk since he was the initiator of the changed code for his opinion.

Show
Danno Ferrin added a comment - This looks like an intentional piece of code introduced by dierk. Basically, the scriptRun command is sensitive to the selected text. If there is no selection, all of the text is run. If there is a selection, only the selectoin is run, This amounts to a feature that is poorly documented and in it's current form is of questionalble usability. My recommendation is to either (a) remove it or (b) make it explicit, add a Script->run and Script->run selected option (ctrl-R and ctrl-shift-R with ctrl-enter and ctrl-shift-enter as well, respectively). Assigning to Dierk since he was the initiator of the changed code for his opinion.
Hide
Dierk Koenig added a comment -

Occasionally, I find this feature very useful. It allows to do some kind of poor-man's debugging of scripts as long as you work with the binding.

I don't agree with the view that it is 'poorly documented'. There isn't much to document and what needs to be said is available in http://groovy.codehaus.org/Groovy+Console and in Groovy in Action.
I understand that it may be surprising for those that haven't read the documentation, though.

Currently, I don't see any issue with this feature but I would be happy about any suggestion for improvement.

Show
Dierk Koenig added a comment - Occasionally, I find this feature very useful. It allows to do some kind of poor-man's debugging of scripts as long as you work with the binding. I don't agree with the view that it is 'poorly documented'. There isn't much to document and what needs to be said is available in http://groovy.codehaus.org/Groovy+Console and in Groovy in Action. I understand that it may be surprising for those that haven't read the documentation, though. Currently, I don't see any issue with this feature but I would be happy about any suggestion for improvement.
Hide
Danno Ferrin added a comment -

The point is that a UI that appears simple and does something unexpected is something that should be avoided. When the unexpected behavior can be explained away by saying that it's documented somewhere raises a big usability red flag. Especially when it is an open source project and the referenced documentation is a €37 book.

How about my (b) option? Split this into a run and run selection option? Unless you object Dierk I will go ahead and implement that to address the usability issues, it fits in with some of the other usability quirks that have been changed.

Show
Danno Ferrin added a comment - The point is that a UI that appears simple and does something unexpected is something that should be avoided. When the unexpected behavior can be explained away by saying that it's documented somewhere raises a big usability red flag. Especially when it is an open source project and the referenced documentation is a €37 book. How about my (b) option? Split this into a run and run selection option? Unless you object Dierk I will go ahead and implement that to address the usability issues, it fits in with some of the other usability quirks that have been changed.
Hide
Danno Ferrin added a comment -

Split the run and run selected commands into two commands, with the shift key modifying the run into run selected in it's various key combinations.

Show
Danno Ferrin added a comment - Split the run and run selected commands into two commands, with the shift key modifying the run into run selected in it's various key combinations.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: