Commit d0b448aa authored by hjk's avatar hjk

Debugger: Simple tooltips for the PdbEngine

Change-Id: I320860ddf06a82bd35fb172eda6a5f6f812ae415
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent d4797015
......@@ -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,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)
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('[')))
if (state() != InferiorStopOk)
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;
}
......
......@@ -72,7 +72,7 @@ private:
void shutdownInferior();
void shutdownEngine();
bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
bool setToolTipExpression(TextEditor::TextEditorWidget *,
const DebuggerToolTipContext &);
void continueInferior();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment