Debugger: Remove widget argument from tooltip request

The only information ever used is whether it's c++ or not.

Change-Id: I4ca00663856dd66cbdf58c468f175a8c9e41d6a5
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
hjk
2015-03-06 13:36:42 +01:00
parent 34c807a11a
commit 46fcfa9018
18 changed files with 35 additions and 55 deletions

View File

@@ -412,10 +412,8 @@ void CdbEngine::syncVerboseLog(bool verboseLog)
postCommand(m_verboseLog ? QByteArray("!sym noisy") : QByteArray("!sym quiet"), 0); postCommand(m_verboseLog ? QByteArray("!sym noisy") : QByteArray("!sym quiet"), 0);
} }
bool CdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget, bool CdbEngine::setToolTipExpression(const DebuggerToolTipContext &context)
const DebuggerToolTipContext &context)
{ {
Q_UNUSED(editorWidget);
Q_UNUSED(context); Q_UNUSED(context);
// Tooltips matching local variables are already handled in the // Tooltips matching local variables are already handled in the
// base class. We don't handle anything else here in CDB // base class. We don't handle anything else here in CDB

View File

@@ -77,8 +77,7 @@ public:
// Factory function that returns 0 if the debug engine library cannot be found. // Factory function that returns 0 if the debug engine library cannot be found.
virtual bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget, virtual bool setToolTipExpression(const DebuggerToolTipContext &context);
const DebuggerToolTipContext &context);
virtual DebuggerEngine *cppEngine() { return this; } virtual DebuggerEngine *cppEngine() { return this; }

View File

@@ -1434,8 +1434,7 @@ Terminal *DebuggerEngine::terminal() const
return &d->m_terminal; return &d->m_terminal;
} }
bool DebuggerEngine::setToolTipExpression(TextEditorWidget *, bool DebuggerEngine::setToolTipExpression(const DebuggerToolTipContext &)
const DebuggerToolTipContext &)
{ {
return false; return false;
} }

View File

@@ -137,8 +137,7 @@ public:
const DebuggerStartParameters &startParameters() const; const DebuggerStartParameters &startParameters() const;
DebuggerStartParameters &startParameters(); DebuggerStartParameters &startParameters();
virtual bool setToolTipExpression(TextEditor::TextEditorWidget *, virtual bool setToolTipExpression(const Internal::DebuggerToolTipContext &);
const Internal::DebuggerToolTipContext &);
virtual void updateWatchData(const Internal::WatchData &data); virtual void updateWatchData(const Internal::WatchData &data);
virtual void watchDataSelected(const QByteArray &iname); virtual void watchDataSelected(const QByteArray &iname);

View File

@@ -43,6 +43,9 @@
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/documentmodel.h> #include <coreplugin/editormanager/documentmodel.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppprojectfile.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
@@ -669,7 +672,7 @@ static void hideAllToolTips()
*/ */
DebuggerToolTipContext::DebuggerToolTipContext() DebuggerToolTipContext::DebuggerToolTipContext()
: position(0), line(0), column(0), scopeFromLine(0), scopeToLine(0) : position(0), line(0), column(0), scopeFromLine(0), scopeToLine(0), isCppEditor(true)
{ {
} }
@@ -1165,18 +1168,21 @@ static void slotTooltipOverrideRequested
if (!boolSetting(UseToolTipsInMainEditor)) if (!boolSetting(UseToolTipsInMainEditor))
return; return;
const TextDocument *document = editorWidget->textDocument();
DebuggerEngine *engine = currentEngine(); DebuggerEngine *engine = currentEngine();
if (!engine || !engine->canDisplayTooltip()) if (!engine || !engine->canDisplayTooltip())
return; return;
DebuggerToolTipContext context; DebuggerToolTipContext context;
context.engineType = engine->objectName(); context.engineType = engine->objectName();
context.fileName = editorWidget->textDocument()->filePath().toString(); context.fileName = document->filePath().toString();
context.position = pos; context.position = pos;
editorWidget->convertPosition(pos, &context.line, &context.column); editorWidget->convertPosition(pos, &context.line, &context.column);
QString raw = cppExpressionAt(editorWidget, context.position, &context.line, &context.column, QString raw = cppExpressionAt(editorWidget, context.position, &context.line, &context.column,
&context.function, &context.scopeFromLine, &context.scopeToLine); &context.function, &context.scopeFromLine, &context.scopeToLine);
context.expression = fixCppExpression(raw); context.expression = fixCppExpression(raw);
context.isCppEditor = CppTools::ProjectFile::classify(document->filePath().toString())
!= CppTools::ProjectFile::Unclassified;
if (context.expression.isEmpty()) { if (context.expression.isEmpty()) {
ToolTip::show(point, DebuggerToolTipManager::tr("No valid expression"), ToolTip::show(point, DebuggerToolTipManager::tr("No valid expression"),
@@ -1224,7 +1230,7 @@ static void slotTooltipOverrideRequested
tooltip->setState(PendingShown); tooltip->setState(PendingShown);
else else
QTC_CHECK(false); QTC_CHECK(false);
*handled = engine->setToolTipExpression(editorWidget, context); *handled = engine->setToolTipExpression(context);
if (!*handled) { if (!*handled) {
ToolTip::show(point, DebuggerToolTipManager::tr("Expression too complex"), ToolTip::show(point, DebuggerToolTipManager::tr("Expression too complex"),
Internal::mainWindow()); Internal::mainWindow());

View File

@@ -71,6 +71,7 @@ public:
QPoint mousePosition; QPoint mousePosition;
QString expression; QString expression;
QByteArray iname; QByteArray iname;
bool isCppEditor;
}; };
typedef QList<DebuggerToolTipContext> DebuggerToolTipContexts; typedef QList<DebuggerToolTipContext> DebuggerToolTipContexts;

View File

@@ -67,10 +67,10 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/messagebox.h> #include <coreplugin/messagebox.h>
#include <projectexplorer/devicesupport/deviceprocess.h> #include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/itaskhandler.h> #include <projectexplorer/itaskhandler.h>
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
#include <texteditor/texteditor.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
@@ -3699,10 +3699,9 @@ void GdbEngine::handleRegisterListValues(const DebuggerResponse &response)
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
bool GdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editor, bool GdbEngine::setToolTipExpression(const DebuggerToolTipContext &context)
const DebuggerToolTipContext &context)
{ {
if (state() != InferiorStopOk || !isCppEditor(editor)) if (state() != InferiorStopOk || !context.isCppEditor)
return false; return false;
UpdateParameters params; UpdateParameters params;

View File

@@ -383,8 +383,7 @@ protected:
// //
// Watch specific stuff // Watch specific stuff
// //
virtual bool setToolTipExpression(TextEditor::TextEditorWidget *editor, virtual bool setToolTipExpression(const DebuggerToolTipContext &);
const DebuggerToolTipContext &);
virtual void assignValueInDebugger(const WatchData *data, virtual void assignValueInDebugger(const WatchData *data,
const QString &expr, const QVariant &value); const QString &expr, const QVariant &value);

View File

@@ -54,8 +54,6 @@
#include <coreplugin/idocument.h> #include <coreplugin/idocument.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <texteditor/texteditor.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/savedaction.h> #include <utils/savedaction.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
@@ -795,9 +793,9 @@ void LldbEngine::refreshSymbols(const GdbMi &symbols)
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
bool LldbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget, const DebuggerToolTipContext &context) bool LldbEngine::setToolTipExpression(const DebuggerToolTipContext &context)
{ {
if (state() != InferiorStopOk || !isCppEditor(editorWidget)) { if (state() != InferiorStopOk || !context.isCppEditor) {
//qDebug() << "SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED " //qDebug() << "SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED "
// " OR NOT A CPPEDITOR"; // " OR NOT A CPPEDITOR";
return false; return false;

View File

@@ -84,8 +84,7 @@ private:
void shutdownEngine(); void shutdownEngine();
void abortDebugger(); void abortDebugger();
bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget, bool setToolTipExpression(const DebuggerToolTipContext &);
const DebuggerToolTipContext &);
void continueInferior(); void continueInferior();
void interruptInferior(); void interruptInferior();

View File

@@ -50,7 +50,6 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <texteditor/texteditor.h>
#include <coreplugin/idocument.h> #include <coreplugin/idocument.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/messagebox.h> #include <coreplugin/messagebox.h>
@@ -371,8 +370,7 @@ void PdbEngine::refreshSymbols(const GdbMi &symbols)
Internal::showModuleSymbols(moduleName, syms); Internal::showModuleSymbols(moduleName, syms);
} }
bool PdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *, bool PdbEngine::setToolTipExpression(const DebuggerToolTipContext &ctx)
const DebuggerToolTipContext &ctx)
{ {
if (state() != InferiorStopOk) if (state() != InferiorStopOk)
return false; return false;

View File

@@ -66,8 +66,7 @@ private:
void shutdownInferior(); void shutdownInferior();
void shutdownEngine(); void shutdownEngine();
bool setToolTipExpression(TextEditor::TextEditorWidget *, bool setToolTipExpression(const DebuggerToolTipContext &);
const DebuggerToolTipContext &);
void continueInferior(); void continueInferior();
void interruptInferior(); void interruptInferior();

View File

@@ -32,6 +32,7 @@
#include "qmlengine.h" #include "qmlengine.h"
#include <debugger/debuggerruncontrol.h> #include <debugger/debuggerruncontrol.h>
#include <debugger/debuggertooltipmanager.h>
#include <debugger/debuggerstartparameters.h> #include <debugger/debuggerstartparameters.h>
#include <debugger/breakhandler.h> #include <debugger/breakhandler.h>
#include <debugger/stackhandler.h> #include <debugger/stackhandler.h>
@@ -39,8 +40,6 @@
#include <debugger/watchhandler.h> #include <debugger/watchhandler.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <texteditor/texteditor.h>
#include <texteditor/textdocument.h>
#include <qmljseditor/qmljseditorconstants.h> #include <qmljseditor/qmljseditorconstants.h>
#include <cppeditor/cppeditorconstants.h> #include <cppeditor/cppeditorconstants.h>
#include <qmljs/consolemanagerinterface.h> #include <qmljs/consolemanagerinterface.h>
@@ -103,15 +102,13 @@ bool QmlCppEngine::canDisplayTooltip() const
return m_cppEngine->canDisplayTooltip() || m_qmlEngine->canDisplayTooltip(); return m_cppEngine->canDisplayTooltip() || m_qmlEngine->canDisplayTooltip();
} }
bool QmlCppEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget, const DebuggerToolTipContext &ctx) bool QmlCppEngine::setToolTipExpression(const DebuggerToolTipContext &ctx)
{ {
QTC_ASSERT(editorWidget, return false);
bool success = false; bool success = false;
Core::Id id = editorWidget->textDocument()->id(); if (ctx.isCppEditor)
if (id == CppEditor::Constants::CPPEDITOR_ID) success = m_cppEngine->setToolTipExpression(ctx);
success = m_cppEngine->setToolTipExpression(editorWidget, ctx); else
else if (id == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) success = m_qmlEngine->setToolTipExpression(ctx);
success = m_qmlEngine->setToolTipExpression(editorWidget, ctx);
return success; return success;
} }

View File

@@ -47,8 +47,7 @@ public:
~QmlCppEngine(); ~QmlCppEngine();
bool canDisplayTooltip() const; bool canDisplayTooltip() const;
bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget, bool setToolTipExpression(const DebuggerToolTipContext &);
const DebuggerToolTipContext &);
void updateWatchData(const WatchData &data); void updateWatchData(const WatchData &data);
void watchDataSelected(const QByteArray &iname); void watchDataSelected(const QByteArray &iname);

View File

@@ -973,12 +973,12 @@ void QmlEngine::requestModuleSymbols(const QString &moduleName)
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
bool QmlEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget, bool QmlEngine::setToolTipExpression(const DebuggerToolTipContext &context)
const DebuggerToolTipContext &ctx)
{ {
// This is processed by QML inspector, which has dependencies to // This is processed by QML inspector, which has dependencies to
// the qml js editor. Makes life easier. // the qml js editor. Makes life easier.
emit tooltipRequested(ctx.mousePosition, editorWidget, ctx.position); // FIXME: Except that there isn't any attached.
emit tooltipRequested(context);
return true; return true;
} }

View File

@@ -89,8 +89,7 @@ public:
void insertBreakpoint(Breakpoint bp); void insertBreakpoint(Breakpoint bp);
signals: signals:
void tooltipRequested(const QPoint &mousePos, void tooltipRequested(const DebuggerToolTipContext &context);
TextEditor::TextEditorWidget *editorWidget, int cursorPos);
private slots: private slots:
void disconnected(); void disconnected();
@@ -128,8 +127,7 @@ private:
void shutdownInferior(); void shutdownInferior();
void shutdownEngine(); void shutdownEngine();
bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget, bool setToolTipExpression(const DebuggerToolTipContext &);
const DebuggerToolTipContext &);
void continueInferior(); void continueInferior();
void interruptInferior(); void interruptInferior();

View File

@@ -261,13 +261,6 @@ bool getUninitializedVariables(const Snapshot &snapshot,
} }
// Editor tooltip support
bool isCppEditor(TextEditorWidget *editorWidget)
{
const TextDocument *document = editorWidget->textDocument();
return ProjectFile::classify(document->filePath().toString()) != ProjectFile::Unclassified;
}
QString cppFunctionAt(const QString &fileName, int line, int column) QString cppFunctionAt(const QString &fileName, int line, int column)
{ {
const Snapshot snapshot = CppModelManager::instance()->snapshot(); const Snapshot snapshot = CppModelManager::instance()->snapshot();

View File

@@ -40,7 +40,6 @@ namespace Debugger {
namespace Internal { namespace Internal {
// Editor tooltip support // Editor tooltip support
bool isCppEditor(TextEditor::TextEditorWidget *editorWidget);
QString cppExpressionAt(TextEditor::TextEditorWidget *editorWidget, int pos, QString cppExpressionAt(TextEditor::TextEditorWidget *editorWidget, int pos,
int *line, int *column, QString *function = 0, int *line, int *column, QString *function = 0,
int *scopeFromLine = 0, int *scopeToLine = 0); int *scopeFromLine = 0, int *scopeToLine = 0);