Bug 793375 - Search operator for finding a variable in scope(s) while the debugger is paused, r=past

This commit is contained in:
Victor Porof
2012-11-04 01:01:05 +02:00
parent e3eb1ccbba
commit f27c6aaf17
15 changed files with 781 additions and 84 deletions

View File

@@ -199,7 +199,8 @@ function OptionsView() {
dumpn("OptionsView was instantiated");
this._togglePauseOnExceptions = this._togglePauseOnExceptions.bind(this);
this._toggleShowPanesOnStartup = this._toggleShowPanesOnStartup.bind(this);
this._toggleShowNonEnum = this._toggleShowNonEnum.bind(this);
this._toggleShowVariablesNonEnum = this._toggleShowVariablesNonEnum.bind(this);
this._toggleShowVariablesSearchbox = this._toggleShowVariablesSearchbox.bind(this);
}
OptionsView.prototype = {
@@ -211,11 +212,13 @@ OptionsView.prototype = {
this._button = document.getElementById("debugger-options");
this._pauseOnExceptionsItem = document.getElementById("pause-on-exceptions");
this._showPanesOnStartupItem = document.getElementById("show-panes-on-startup");
this._showNonEnumItem = document.getElementById("show-nonenum");
this._showVariablesNonEnumItem = document.getElementById("show-vars-nonenum");
this._showVariablesSearchboxItem = document.getElementById("show-vars-searchbox");
this._pauseOnExceptionsItem.setAttribute("checked", "false");
this._showPanesOnStartupItem.setAttribute("checked", Prefs.panesVisibleOnStartup);
this._showNonEnumItem.setAttribute("checked", Prefs.nonEnumVisible);
this._showVariablesNonEnumItem.setAttribute("checked", Prefs.variablesNonEnumVisible);
this._showVariablesSearchboxItem.setAttribute("checked", Prefs.variablesSearchboxVisible);
},
/**
@@ -259,15 +262,24 @@ OptionsView.prototype = {
/**
* Listener handling the 'show non-enumerables' menuitem command.
*/
_toggleShowNonEnum: function DVO__toggleShowNonEnum() {
DebuggerView.Variables.nonEnumVisible = Prefs.nonEnumVisible =
this._showNonEnumItem.getAttribute("checked") == "true";
_toggleShowVariablesNonEnum: function DVO__toggleShowVariablesNonEnum() {
DebuggerView.Variables.nonEnumVisible = Prefs.variablesNonEnumVisible =
this._showVariablesNonEnumItem.getAttribute("checked") == "true";
},
/**
* Listener handling the 'show variables searchbox' menuitem command.
*/
_toggleShowVariablesSearchbox: function DVO__toggleShowVariablesSearchbox() {
DebuggerView.Variables.searchEnabled = Prefs.variablesSearchboxVisible =
this._showVariablesSearchboxItem.getAttribute("checked") == "true";
},
_button: null,
_pauseOnExceptionsItem: null,
_showPanesOnStartupItem: null,
_showNonEnumItem: null
_showVariablesNonEnumItem: null,
_showVariablesSearchboxItem: null
};
/**
@@ -562,11 +574,14 @@ FilterView.prototype = {
this._tokenOperatorLabel = document.getElementById("token-operator-label");
this._lineOperatorButton = document.getElementById("line-operator-button");
this._lineOperatorLabel = document.getElementById("line-operator-label");
this._variableOperatorButton = document.getElementById("variable-operator-button");
this._variableOperatorLabel = document.getElementById("variable-operator-label");
this._globalSearchKey = LayoutHelpers.prettyKey(document.getElementById("globalSearchKey"));
this._fileSearchKey = LayoutHelpers.prettyKey(document.getElementById("fileSearchKey"));
this._lineSearchKey = LayoutHelpers.prettyKey(document.getElementById("lineSearchKey"));
this._tokenSearchKey = LayoutHelpers.prettyKey(document.getElementById("tokenSearchKey"));
this._variableSearchKey = LayoutHelpers.prettyKey(document.getElementById("variableSearchKey"));
this._searchbox.addEventListener("click", this._onClick, false);
this._searchbox.addEventListener("select", this._onSearch, false);
@@ -577,6 +592,7 @@ FilterView.prototype = {
this._globalOperatorButton.setAttribute("label", SEARCH_GLOBAL_FLAG);
this._tokenOperatorButton.setAttribute("label", SEARCH_TOKEN_FLAG);
this._lineOperatorButton.setAttribute("label", SEARCH_LINE_FLAG);
this._variableOperatorButton.setAttribute("label", SEARCH_VARIABLE_FLAG);
this._globalOperatorLabel.setAttribute("value",
L10N.getFormatStr("searchPanelGlobal", [this._globalSearchKey]));
@@ -584,6 +600,8 @@ FilterView.prototype = {
L10N.getFormatStr("searchPanelToken", [this._tokenSearchKey]));
this._lineOperatorLabel.setAttribute("value",
L10N.getFormatStr("searchPanelLine", [this._lineSearchKey]));
this._variableOperatorLabel.setAttribute("value",
L10N.getFormatStr("searchPanelVariable", [this._variableSearchKey]));
// TODO: bug 806775
// if (window._isChromeDebugger) {
@@ -628,16 +646,17 @@ FilterView.prototype = {
* @return array
*/
get searchboxInfo() {
let file, line, token, global;
let file, line, token, isGlobal, isVariable;
let rawValue = this._searchbox.value;
let rawLength = rawValue.length;
let globalFlagIndex = rawValue.indexOf(SEARCH_GLOBAL_FLAG);
let variableFlagIndex = rawValue.indexOf(SEARCH_VARIABLE_FLAG);
let lineFlagIndex = rawValue.lastIndexOf(SEARCH_LINE_FLAG);
let tokenFlagIndex = rawValue.lastIndexOf(SEARCH_TOKEN_FLAG);
// This is not a global search, allow file or line flags.
if (globalFlagIndex != 0) {
// This is not a global or variable search, allow file or line flags.
if (globalFlagIndex != 0 && variableFlagIndex != 0) {
let fileEnd = lineFlagIndex != -1
? lineFlagIndex
: tokenFlagIndex != -1 ? tokenFlagIndex : rawLength;
@@ -649,17 +668,27 @@ FilterView.prototype = {
file = rawValue.slice(0, fileEnd);
line = ~~(rawValue.slice(fileEnd + 1, lineEnd)) || -1;
token = rawValue.slice(lineEnd + 1);
global = false;
isGlobal = false;
isVariable = false;
}
// Global searches dissalow the use of file or line flags.
else {
else if (globalFlagIndex == 0) {
file = "";
line = -1;
token = rawValue.slice(1);
global = true;
isGlobal = true;
isVariable = false;
}
// Variable searches dissalow the use of file or line flags.
else if (variableFlagIndex == 0) {
file = "";
line = -1;
token = rawValue.slice(1);
isGlobal = false;
isVariable = true;
}
return [file, line, token, global];
return [file, line, token, isGlobal, isVariable];
},
/**
@@ -787,25 +816,33 @@ FilterView.prototype = {
*/
_onSearch: function DVF__onScriptsSearch() {
this._searchboxPanel.hidePopup();
let [file, line, token, global] = this.searchboxInfo;
let [file, line, token, isGlobal, isVariable] = this.searchboxInfo;
// If this is a global search, schedule it for when the user stops typing,
// or hide the corresponding pane otherwise.
if (global) {
if (isGlobal) {
DebuggerView.GlobalSearch.scheduleSearch();
} else {
DebuggerView.GlobalSearch.clearView();
this._performFileSearch(file);
this._performLineSearch(line);
this._performTokenSearch(token);
return;
}
// If this is a variable search, defer the action to the corresponding
// variables view instance.
if (isVariable) {
DebuggerView.Variables.performSearch(token);
return;
}
DebuggerView.GlobalSearch.clearView();
this._performFileSearch(file);
this._performLineSearch(line);
this._performTokenSearch(token);
},
/**
* The key press listener for the search container.
*/
_onKeyPress: function DVF__onScriptsKeyPress(e) {
let [file, line, token, global] = this.searchboxInfo;
let [file, line, token, isGlobal, isVariable] = this.searchboxInfo;
let action;
switch (e.keyCode) {
@@ -835,18 +872,26 @@ FilterView.prototype = {
e.preventDefault();
e.stopPropagation();
if (global) {
// Perform a global search based on the specified operator.
if (isGlobal) {
if (DebuggerView.GlobalSearch.hidden) {
DebuggerView.GlobalSearch.scheduleSearch();
} else {
DebuggerView.GlobalSearch[["focusNextMatch", "focusPrevMatch"][action]]();
}
} else {
let editor = DebuggerView.editor;
let offset = editor[["findNext", "findPrevious"][action]](true);
if (offset > -1) {
editor.setSelection(offset, offset + token.length)
}
return;
}
// Perform a variable search based on the specified operator.
if (isVariable) {
DebuggerView.Variables.expandFirstSearchResults();
return;
}
let editor = DebuggerView.editor;
let offset = editor[["findNext", "findPrevious"][action]](true);
if (offset > -1) {
editor.setSelection(offset, offset + token.length)
}
},
@@ -855,6 +900,7 @@ FilterView.prototype = {
*/
_onBlur: function DVF__onBlur() {
DebuggerView.GlobalSearch.clearView();
DebuggerView.Variables.performSearch(null);
this._searchboxPanel.hidePopup();
},
@@ -902,6 +948,14 @@ FilterView.prototype = {
this._searchboxPanel.hidePopup();
},
/**
* Called when the variable search filter key sequence was pressed.
*/
_doVariableSearch: function DVF__doVariableSearch() {
this._doSearch(SEARCH_VARIABLE_FLAG);
this._searchboxPanel.hidePopup();
},
_searchbox: null,
_searchboxPanel: null,
_globalOperatorButton: null,