Developer Tools/ObjectUI - added "Add property path to watch".
Added "Add property path to watch" for quickly adding an
inspected object property expression to watch.
This is not smart enough to infer the original expression
that triggered the property list, but it works without a user
intervention for the scope variables section.
Also -
- Removed a redundant . that is prepended to every
property path.
- Escaped the property name when it is a string.
[email protected]
Bug: none
Change-Id: I984bad781786668bb708084dbb1a8537dabf02a3
Reviewed-on: https://chromium-review.googlesource.com/1001232
Reviewed-by: Pavel Feldman <[email protected]>
Commit-Queue: PhistucK <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#556325}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 3fae2c4abeb22b18d486a29f74cbafcce5668b8c
diff --git a/front_end/sources/WatchExpressionsSidebarPane.js b/front_end/sources/WatchExpressionsSidebarPane.js
index 320aef7..c546259 100644
--- a/front_end/sources/WatchExpressionsSidebarPane.js
+++ b/front_end/sources/WatchExpressionsSidebarPane.js
@@ -180,6 +180,23 @@
}
/**
+ * @param {string} expression
+ */
+ _focusAndAddExpressionToWatch(expression) {
+ UI.viewManager.showView('sources.watch');
+ this.doUpdate();
+ this._addExpressionToWatch(expression);
+ }
+
+ /**
+ * @param {string} expression
+ */
+ _addExpressionToWatch(expression) {
+ this._createWatchExpression(expression);
+ this._saveExpressions();
+ }
+
+ /**
* @override
* @param {!UI.Context} context
* @param {string} actionId
@@ -190,20 +207,29 @@
if (!frame)
return false;
const text = frame.textEditor.text(frame.textEditor.selection());
- UI.viewManager.showView('sources.watch');
- this.doUpdate();
- this._createWatchExpression(text);
- this._saveExpressions();
+ this._focusAndAddExpressionToWatch(text);
return true;
}
/**
+ * @param {!ObjectUI.ObjectPropertyTreeElement} target
+ */
+ _addPropertyPathToWatch(target) {
+ this._addExpressionToWatch(target.path());
+ }
+
+ /**
* @override
* @param {!Event} event
* @param {!UI.ContextMenu} contextMenu
* @param {!Object} target
*/
appendApplicableItems(event, contextMenu, target) {
+ if (target instanceof ObjectUI.ObjectPropertyTreeElement) {
+ contextMenu.debugSection().appendItem(
+ ls`Add property path to watch`, this._addPropertyPathToWatch.bind(this, target));
+ }
+
const frame = UI.context.flavor(Sources.UISourceCodeFrame);
if (!frame || frame.textEditor.selection().isEmpty())
return;