diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 5855b03366a..c4fe34872de 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -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 diff --git a/src/plugins/debugger/debuggertooltipmanager.h b/src/plugins/debugger/debuggertooltipmanager.h index 0538c8089a6..3174006c5e9 100644 --- a/src/plugins/debugger/debuggertooltipmanager.h +++ b/src/plugins/debugger/debuggertooltipmanager.h @@ -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; diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index b3041de9424..5ac68dbb715 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -452,69 +452,16 @@ 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)); - 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; + DebuggerCommand cmd("evaluateTooltip"); + ctx.appendFormatRequest(&cmd); + runCommand(cmd); + return true; } diff --git a/src/plugins/debugger/pdb/pdbengine.h b/src/plugins/debugger/pdb/pdbengine.h index de99e6f03ec..bfd565f36b4 100644 --- a/src/plugins/debugger/pdb/pdbengine.h +++ b/src/plugins/debugger/pdb/pdbengine.h @@ -72,7 +72,7 @@ private: void shutdownInferior(); void shutdownEngine(); - bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget, + bool setToolTipExpression(TextEditor::TextEditorWidget *, const DebuggerToolTipContext &); void continueInferior();