softwareCobbler / luceedebug

line debugger for lucee
GNU Lesser General Public License v2.1
44 stars 15 forks source link

Improved Inspection of CFML Data Structures? #16

Open jamiejackson opened 1 year ago

jamiejackson commented 1 year ago

lucedebug is already great, but I'm looking ahead...

For a good percentage of use cases, the variable inspection for query objects probably isn't going to be adequate, without copying the value to clipboard and pasting it to file. (I'm happy to have the existing stringified version available to paste, though. It's a good workaround.)

In this screen shot, you can see the hover-over display of the stringified query object and in the right pane, you can see the full stringified query object that I've pasted in.

image

I haven't tried VS Code with (for instance) Java yet, but I wonder if, say, Java ResultSets are rendered in a more structured way or if the VS Code debugger is always limited in this way.

jamiejackson commented 1 year ago

Hmm, maybe the way that it's implemented now is the best compromise since that alternative might look something like this array of structures (which is normal for debuggers):

image

Maybe an easily pastable string is more usable than a drill-down structure. It's too bad all you get by copying FOO in the variables key is Array (17). It would be useful if each level stringified to json or something.

Sorry for the ramble.

Maybe what I would like is a scrollable mouseover popup, since it only gives you a fixed-size popup that can truncate the value. I'm guessing this is a general VS Code issue, though.

Anyway, maybe you've already put some thought into this and this was the best compromise (seems likely), but I'm interested in your thoughts.

softwareCobbler commented 1 year ago

The query-as-a-string output is the (or maybe just one of?) Lucee's default internal stringified representations of a query object, it just kinda fell out of Lucee as-is. I've considered showing a query as an array-of-structs. Probably that is a big use case so making it nice would be a good value add. Maybe some combination of both, would have to putz with what DAP can shuttle and VS Code will surface.

I wonder if it supports context menus, you could right click it and do "stream to browser tab on localhost" and get a nice <div> based output, or even just the writedump which is often pretty usable. I don't know if it supports context menus like that on right-clicking a value in that pane, though.

softwareCobbler commented 1 year ago

Experimenting on branch dump-to-webview with leveraging existing writeDump functionality, exposing it via context menu on values in the debug pane. This might be near the intersection of easy to implement and useful. Could fall over on large dumps, but that would be expected in a browser environment, too. image

jamiejackson commented 1 year ago

I just tried it and it works great! I think it would cover all the cases I can think of.

Because I now have this option at every level within a data structure, it also works around the not-so-useful way that VS Code handles "Copy Value" on arrays and structures. For example:

Maybe someday we'll have a use case for a luceedebug json (serializeJson()) option (or maybe luceedebug csv (for queries) but I haven't personally had a need for that yet.

jamiejackson commented 1 year ago

Is there anything left to do before releasing?

softwareCobbler commented 1 year ago

I left the "(experimental)" tag but otherwise it's in production.

I think your serializeJSON idea is a good one, that would probably come in handy.