views:

1065

answers:

1

hi,

I have started to learn groovy by building a pet project. I fetch some html with XmlSlurper and parse it etc. I am using eclipse3.4 with groovy 1.6 plugin. I am having a very difficult time trying to iterate thorugh all the html elements etc. I expected to set some breakpoint, inspect the current variable where my contents are, see what it contains, what do I have to iterate over, evaluate some expressions etc etc.

But I almost cannot do anything like that: - some variables don't appear in the variables view (maybe its the ones not having a type?) - select any expression but you cannot evaluate - and worst of all (for me) is that any variable is shown with all its groovy stuff (metaclass, value...). The things that most of the time will interest the developer are buried inside the hierarchy and very difficult to find.

I had thougth that the ObjectExplorer mentioned in the doco would be able to help but I was unable to get it running with my script.

What do people use for this sort of thing while developing in groovy?

+2  A: 

Option 1:

Give following a try in your script

groovy.inspect.swingui.ObjectBrowser.inspect(object)

This gives all public fields, properties, methods, etc

Option 2:

You can also use obj.dump() and or object.inspect() method to see values of the object e.g. println obj.inspect() or assert obj.inspect() == "some values"

Other options:

  • Eclipse 3.4 debug perspective works pretty well. Even the one without type information show up. Can you give specific problem that you are facing with debugging in 3.4
  • println variables
  • Writing Unit test with asserts regarding expected output of the xml
peacefulfire
Option 1 is discarded cause my code is very difficult to run on groovyshOption 2 helps, specially the dump, but no too muchIn Eclipse 3.4 debugging is not working well for me: * it goes to lines where the code does not enter (wrong part of the if else), but its just a display problem the code works fine * not all variables can be seen, i think it depends whether you have declared with def, they are static etc etc * when inspecting a variable its difficult to find the info I want as all groovy plumbing stuff is shown too.I have started using Idea and it works better for debugging
raticulin