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;
|
&& 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
|
QString DebuggerToolTipContext::toolTip() const
|
||||||
{
|
{
|
||||||
return DebuggerToolTipManager::tr("Expression %1 in function %2 from line %3 to %4")
|
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();
|
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
|
DEBUG("UPDATE TOOLTIP: STATE " << state << context.iname
|
||||||
<< "PINNED: " << widget->isPinned
|
<< "PINNED: " << widget->isPinned
|
||||||
<< "SHOW NEEDED: " << widget->isPinned
|
<< "SHOW NEEDED: " << widget->isPinned
|
||||||
|
@@ -45,6 +45,7 @@ namespace Debugger {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class DebuggerEngine;
|
class DebuggerEngine;
|
||||||
|
class DebuggerCommand;
|
||||||
class StackFrame;
|
class StackFrame;
|
||||||
|
|
||||||
class DebuggerToolTipContext
|
class DebuggerToolTipContext
|
||||||
@@ -54,6 +55,7 @@ public:
|
|||||||
bool isValid() const { return !expression.isEmpty(); }
|
bool isValid() const { return !expression.isEmpty(); }
|
||||||
bool matchesFrame(const StackFrame &frame) const;
|
bool matchesFrame(const StackFrame &frame) const;
|
||||||
bool isSame(const DebuggerToolTipContext &other) const;
|
bool isSame(const DebuggerToolTipContext &other) const;
|
||||||
|
void appendFormatRequest(DebuggerCommand *cmd) const;
|
||||||
QString toolTip() const;
|
QString toolTip() const;
|
||||||
|
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
@@ -452,69 +452,16 @@ void PdbEngine::handleListSymbols(const DebuggerResponse &response, const QStrin
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
static WatchData m_toolTip;
|
bool PdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *,
|
||||||
static QPoint m_toolTipPos;
|
|
||||||
|
|
||||||
bool PdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
|
|
||||||
const DebuggerToolTipContext &ctx)
|
const DebuggerToolTipContext &ctx)
|
||||||
{
|
{
|
||||||
if (state() != InferiorStopOk) {
|
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;
|
return false;
|
||||||
|
|
||||||
int line;
|
DebuggerCommand cmd("evaluateTooltip");
|
||||||
int column;
|
ctx.appendFormatRequest(&cmd);
|
||||||
QString exp = cppExpressionAt(editorWidget, ctx.position, &line, &column);
|
runCommand(cmd);
|
||||||
|
|
||||||
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;
|
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 shutdownInferior();
|
||||||
void shutdownEngine();
|
void shutdownEngine();
|
||||||
|
|
||||||
bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
|
bool setToolTipExpression(TextEditor::TextEditorWidget *,
|
||||||
const DebuggerToolTipContext &);
|
const DebuggerToolTipContext &);
|
||||||
|
|
||||||
void continueInferior();
|
void continueInferior();
|
||||||
|
Reference in New Issue
Block a user