aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/debugger/watchhandler.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <[email protected]>2012-08-31 11:34:27 +0200
committerhjk <[email protected]>2012-09-03 09:02:56 +0200
commit6886e485de59bc1fe1fe84ca6c1fb1263b18420b (patch)
treeebb953981f3d743036da24aeb4bdb1c12cf61f65 /src/plugins/debugger/watchhandler.cpp
parenta37eca63b61360c509c7dbe287fec88b281d1c56 (diff)
Handle watching/tooltips of C++ editor tokens consistently.
For editor tooltips and the editor context menu 'Watch expression', always try to find a local variable first and use its expression. Change the tooltip manager/widgets not to rely on the debugger model enum and obscure expression, filter by complete iname instead. Remove obsolete enumeration. Change gdb's handling of tooltips such that local variables are displayed immediately without creating additional tooltip items. Change-Id: I9b55823428029ba50d84d3a8cab55eb58942e72b Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins/debugger/watchhandler.cpp')
-rw-r--r--src/plugins/debugger/watchhandler.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index fb1cdf29d7b..966bf8c8651 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -1550,7 +1550,7 @@ QByteArray WatchHandler::watcherName(const QByteArray &exp)
return "watch." + QByteArray::number(theWatcherNames[exp]);
}
-void WatchHandler::watchExpression(const QString &exp)
+void WatchHandler::watchExpression(const QString &exp, const QString &name)
{
QTC_ASSERT(m_engine, return);
// Do not insert the same entry more then once.
@@ -1560,7 +1560,7 @@ void WatchHandler::watchExpression(const QString &exp)
// FIXME: 'exp' can contain illegal characters
WatchData data;
data.exp = exp.toLatin1();
- data.name = exp;
+ data.name = name.isEmpty() ? exp : name;
theWatcherNames[data.exp] = m_watcherCounter++;
saveWatchers();
@@ -1794,6 +1794,20 @@ const WatchData *WatchHandler::findData(const QByteArray &iname) const
return m_model->findItem(iname);
}
+const WatchData *WatchHandler::findCppLocalVariable(const QString &name) const
+{
+ // Can this be found as a local variable?
+ const QByteArray localsPrefix("local.");
+ QByteArray iname = localsPrefix + name.toLatin1();
+ if (const WatchData *wd = findData(iname))
+ return wd;
+ // Nope, try a 'local.this.m_foo'.
+ iname.insert(localsPrefix.size(), "this.");
+ if (const WatchData *wd = findData(iname))
+ return wd;
+ return 0;
+}
+
QString WatchHandler::displayForAutoTest(const QByteArray &iname) const
{
return m_model->displayForAutoTest(iname);