forked from qt-creator/qt-creator
Debugger: Simple tooltips for the PdbEngine
Change-Id: I320860ddf06a82bd35fb172eda6a5f6f812ae415 Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -691,6 +691,13 @@ bool DebuggerToolTipContext::isSame(const DebuggerToolTipContext &other) const
|
||||
&& iname == other.iname;
|
||||
}
|
||||
|
||||
void DebuggerToolTipContext::appendFormatRequest(DebuggerCommand *cmd) const
|
||||
{
|
||||
cmd->arg("expression", expression);
|
||||
cmd->arg("fileName", fileName);
|
||||
cmd->arg("iname", iname);
|
||||
}
|
||||
|
||||
QString DebuggerToolTipContext::toolTip() const
|
||||
{
|
||||
return DebuggerToolTipManager::tr("Expression %1 in function %2 from line %3 to %4")
|
||||
@@ -787,7 +794,10 @@ void DebuggerToolTipHolder::updateTooltip(DebuggerEngine *engine)
|
||||
|
||||
StackFrame frame = engine->stackHandler()->currentFrame();
|
||||
|
||||
const bool sameFrame = context.matchesFrame(frame);
|
||||
// FIXME: The engine should decide on whether it likes
|
||||
// the context.
|
||||
const bool sameFrame = context.matchesFrame(frame)
|
||||
|| context.fileName.endsWith(QLatin1String(".py"));
|
||||
DEBUG("UPDATE TOOLTIP: STATE " << state << context.iname
|
||||
<< "PINNED: " << widget->isPinned
|
||||
<< "SHOW NEEDED: " << widget->isPinned
|
||||
|
@@ -45,6 +45,7 @@ namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
class DebuggerEngine;
|
||||
class DebuggerCommand;
|
||||
class StackFrame;
|
||||
|
||||
class DebuggerToolTipContext
|
||||
@@ -54,6 +55,7 @@ public:
|
||||
bool isValid() const { return !expression.isEmpty(); }
|
||||
bool matchesFrame(const StackFrame &frame) const;
|
||||
bool isSame(const DebuggerToolTipContext &other) const;
|
||||
void appendFormatRequest(DebuggerCommand *cmd) const;
|
||||
QString toolTip() const;
|
||||
|
||||
QString fileName;
|
||||
|
@@ -452,71 +452,18 @@ void PdbEngine::handleListSymbols(const DebuggerResponse &response, const QStrin
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static WatchData m_toolTip;
|
||||
static QPoint m_toolTipPos;
|
||||
|
||||
bool PdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
|
||||
bool PdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *,
|
||||
const DebuggerToolTipContext &ctx)
|
||||
{
|
||||
if (state() != InferiorStopOk) {
|
||||
//SDEBUG("SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED");
|
||||
return false;
|
||||
}
|
||||
// Check mime type and get expression (borrowing some C++ - functions)
|
||||
const QString javaPythonMimeType = QLatin1String("application/javascript");
|
||||
if (editorWidget->textDocument()->mimeType() != javaPythonMimeType)
|
||||
if (state() != InferiorStopOk)
|
||||
return false;
|
||||
|
||||
int line;
|
||||
int column;
|
||||
QString exp = cppExpressionAt(editorWidget, ctx.position, &line, &column);
|
||||
|
||||
QToolTip::hideText();
|
||||
if (exp.isEmpty() || exp.startsWith(QLatin1Char('#'))) {
|
||||
QToolTip::hideText();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!hasLetterOrNumber(exp)) {
|
||||
QToolTip::showText(m_toolTipPos, tr("\"%1\" contains no identifier").arg(exp));
|
||||
DebuggerCommand cmd("evaluateTooltip");
|
||||
ctx.appendFormatRequest(&cmd);
|
||||
runCommand(cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (exp.startsWith(QLatin1Char('"')) && exp.endsWith(QLatin1Char('"'))) {
|
||||
QToolTip::showText(m_toolTipPos, tr("String literal %1").arg(exp));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (exp.startsWith(QLatin1String("++")) || exp.startsWith(QLatin1String("--")))
|
||||
exp.remove(0, 2);
|
||||
|
||||
if (exp.endsWith(QLatin1String("++")) || exp.endsWith(QLatin1String("--")))
|
||||
exp.remove(0, 2);
|
||||
|
||||
if (exp.startsWith(QLatin1Char('<')) || exp.startsWith(QLatin1Char('[')))
|
||||
return false;
|
||||
|
||||
if (hasSideEffects(exp)) {
|
||||
QToolTip::showText(m_toolTipPos,
|
||||
tr("Cowardly refusing to evaluate expression \"%1\" "
|
||||
"with potential side effects").arg(exp));
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
//if (status() != InferiorStopOk)
|
||||
// return;
|
||||
|
||||
// FIXME: 'exp' can contain illegal characters
|
||||
m_toolTip = WatchData();
|
||||
m_toolTip.exp = exp;
|
||||
m_toolTip.name = exp;
|
||||
m_toolTip.iname = tooltipIName;
|
||||
insertData(m_toolTip);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@@ -72,7 +72,7 @@ private:
|
||||
void shutdownInferior();
|
||||
void shutdownEngine();
|
||||
|
||||
bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
|
||||
bool setToolTipExpression(TextEditor::TextEditorWidget *,
|
||||
const DebuggerToolTipContext &);
|
||||
|
||||
void continueInferior();
|
||||
|
Reference in New Issue
Block a user