Skip to content
Permalink
Browse files
Complete in scope variables in the Console when paused.
        https://bugs.webkit.org/show_bug.cgi?id=19115

        Reviewed by Geoffrey Garen.

        * page/inspector/Console.js:
        (WebInspector.Console.prototype.completions): If the expressionString
        is null or empty and the debugger is paused, call variablesInScopeForSelectedCallFrame
        to get an object that declares all the in scope variables. That way
        "top level" expressions are completed.
        * page/inspector/ScriptsPanel.js:
        (WebInspector.ScriptsPanel.prototype.variablesInScopeForSelectedCallFrame):
        Return an object that has all the variables that are in scope for the
        selected call frame. The value of each property is just true.
        The return object is useful for quick lookups or auto completion.

Canonical link: https://commits.webkit.org/28222@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
xeenon committed Aug 18, 2008
1 parent 0643a6a commit 48e4a267263b512a6054ab768fcdb0382949c2cd
Showing 3 changed files with 44 additions and 1 deletion.
@@ -1,3 +1,22 @@
2008-08-17 Timothy Hatcher <timothy@apple.com>

Complete in scope variables in the Console when paused.

https://bugs.webkit.org/show_bug.cgi?id=19115

Reviewed by Geoffrey Garen.

* page/inspector/Console.js:
(WebInspector.Console.prototype.completions): If the expressionString
is null or empty and the debugger is paused, call variablesInScopeForSelectedCallFrame
to get an object that declares all the in scope variables. That way
"top level" expressions are completed.
* page/inspector/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype.variablesInScopeForSelectedCallFrame):
Return an object that has all the variables that are in scope for the
selected call frame. The value of each property is just true.
The return object is useful for quick lookups or auto completion.

2008-08-17 Cameron Zwarich <cwzwarich@uwaterloo.ca>

Not reviewed.
@@ -200,13 +200,20 @@ WebInspector.Console.prototype = {
if (!expressionString && !prefix)
return;

var result = InspectorController.inspectedWindow();
var result;
if (expressionString) {
try {
result = this._evalInInspectedWindow(expressionString);
} catch(e) {
// Do nothing, the prefix will be considered a window property.
}
} else {
// There is no expressionString, so the completion should happen against global properties.
// Or if the debugger is paused, against properties in scope of the selected call frame.
if (WebInspector.panels.scripts.paused)
result = WebInspector.panels.scripts.variablesInScopeForSelectedCallFrame();
else
result = InspectorController.inspectedWindow();
}

if (bracketNotation) {
@@ -293,6 +293,23 @@ WebInspector.ScriptsPanel.prototype = {
return result;
},

variablesInScopeForSelectedCallFrame: function()
{
var selectedCallFrame = this.sidebarPanes.callstack.selectedCallFrame;
if (!this._paused || !selectedCallFrame)
return {};

var result = {};
var scopeChain = selectedCallFrame.scopeChain;
for (var i = 0; i < scopeChain.length; ++i) {
var scopeObject = scopeChain[i];
for (var property in scopeObject)
result[property] = true;
}

return result;
},

debuggerPaused: function()
{
this._paused = true;

0 comments on commit 48e4a26

Please sign in to comment.