Adding Add To Watch Support To Scope Variables

20 views
Skip to first unread message

PhistucK

unread,
Mar 26, 2018, 1:03:32 PM3/26/18
to Google Chrome Developer Tools, Pavel Feldman, Dmitry Gozman, Eugene Ostroukhov
I want to implement a feature I tried to implement a few years ago (continuing the work of someone else back then). Original WebKit bug - https://bugs.webkit.org/show_bug.cgi?id=101929.

Sorry - I looked around for some hours and could not find a sensible way to easily implement it.

Gathering the property path should be easy ("Copy property path" does most of the work, with a extraneous prepended dot (.) that I need to remove - though I do not think it should be there anyway, so I generally plan to remove it from "Copy property path" as well).
However, passing the property path (or any value for that matter) in a UI.Action (module.json/extension/type=action) seems to be impossible with the current API.
Perhaps I need to use a different module.json/extension type?

I do not think I should add this action to WatchExpressionsSidebarPane.js within appendApplicableAction because it would be too much work to recreate the property path from there (it only gets the SDK.RemoteObject).

Any suggestion or advice?

Thank you.


PhistucK

Pavel Feldman

unread,
Mar 26, 2018, 4:09:16 PM3/26/18
to PhistucK, Google Chrome Developer Tools, Dmitry Gozman, Eugene Ostroukhov
You are right, there is no good solution. We are lacking information on the selection / context in the action system.

- In ObjectPropertiesSection:817 add contextMenu.appendApplicableItems(this);
- Make Sources.WatchExpressionsSidebarPane that is @UI.ContextMenu.Provider applicable to ObjectUI.ObjectPropertyTreeElement
- Introduce Sources.ScopeChainSidebarPane.pathFor(treeElement). it would resolve element to ObjectPropertySection and then would resolve Sources.ScopeChainSidebarPane from there. That way your action won't trigger for any ObjectPropertyTreeElement. You can bind Sources.ScopeChainSidebarPane on ObjectPropertySection as a symbol.

PhistucK

unread,
Apr 7, 2018, 12:53:54 PM4/7/18
to Pavel Feldman, Google Chrome Developer Tools, Dmitry Gozman, Eugene Ostroukhov
I cooked up a more generic approach here -

It is not ready for review, of course (it should not bring up the Sources panel when you choose that option and there are no tests and there is a merge conflict). I wanted your opinion on the general approach, if you can.

I generalized it to always show up on ObjectPropertiesTreeElement. In scope variables, it should work without a user intervention (meaning, without manually prepending a variable name to the expression afterwards), but in other cases, the user will likely have to prepend something on their own, which is why I named it "Add property path to watch", since it works pretty much the same as "Copy property path".
I thought about helping the user a bit in case this is selected within the context of an object popover, by plumbing the original expression that triggered the popover in buildObjectPopover, (and from there to an ObjectPropertiesSection and ObjectPropertiesTreeElement or its root) but I was not sure it was worth it. Console object properties cannot be inferred, I would guess, because they can result from whatever it is that was evaluated there last. We can do some basic query, if the last evaluated string is /^[\w\[\]().];?$/.

Also, can I add (non-code) comments in Gerrit only after I start the review, or are my eyes missing a button/text box that lets me add a comment?

Thank you for the lead and the help!


PhistucK

PhistucK

unread,
Apr 12, 2018, 2:37:42 AM4/12/18
to Pavel Feldman, Google Chrome Developer Tools, Dmitry Gozman, Eugene Ostroukhov
Ping... Any suggestion?

Thank you!


PhistucK
Reply all
Reply to author
Forward
0 new messages