Commit 46fcfa90 authored by hjk's avatar hjk

Debugger: Remove widget argument from tooltip request

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

Change-Id: I4ca00663856dd66cbdf58c468f175a8c9e41d6a5
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent 34c807a1
......@@ -412,10 +412,8 @@ void CdbEngine::syncVerboseLog(bool verboseLog)
postCommand(m_verboseLog ? QByteArray("!sym noisy") : QByteArray("!sym quiet"), 0);
}
bool CdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
const DebuggerToolTipContext &context)
bool CdbEngine::setToolTipExpression(const DebuggerToolTipContext &context)
{
Q_UNUSED(editorWidget);
Q_UNUSED(context);
// Tooltips matching local variables are already handled in the
// base class. We don't handle anything else here in CDB
......
......@@ -77,8 +77,7 @@ public:
// Factory function that returns 0 if the debug engine library cannot be found.
virtual bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
const DebuggerToolTipContext &context);
virtual bool setToolTipExpression(const DebuggerToolTipContext &context);
virtual DebuggerEngine *cppEngine() { return this; }
......
......@@ -1434,8 +1434,7 @@ Terminal *DebuggerEngine::terminal() const
return &d->m_terminal;
}
bool DebuggerEngine::setToolTipExpression(TextEditorWidget *,
const DebuggerToolTipContext &)
bool DebuggerEngine::setToolTipExpression(const DebuggerToolTipContext &)
{
return false;
}
......
......@@ -137,8 +137,7 @@ public:
const DebuggerStartParameters &startParameters() const;
DebuggerStartParameters &startParameters();
virtual bool setToolTipExpression(TextEditor::TextEditorWidget *,
const Internal::DebuggerToolTipContext &);
virtual bool setToolTipExpression(const Internal::DebuggerToolTipContext &);
virtual void updateWatchData(const Internal::WatchData &data);
virtual void watchDataSelected(const QByteArray &iname);
......
......@@ -43,6 +43,9 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/documentmodel.h>
#include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppprojectfile.h>
#include <texteditor/texteditor.h>
#include <texteditor/textdocument.h>
......@@ -669,7 +672,7 @@ static void hideAllToolTips()
*/
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))
return;
const TextDocument *document = editorWidget->textDocument();
DebuggerEngine *engine = currentEngine();
if (!engine || !engine->canDisplayTooltip())
return;
DebuggerToolTipContext context;
context.engineType = engine->objectName();
context.fileName = editorWidget->textDocument()->filePath().toString();
context.fileName = document->filePath().toString();
context.position = pos;
editorWidget->convertPosition(pos, &context.line, &context.column);
QString raw = cppExpressionAt(editorWidget, context.position, &context.line, &context.column,
&context.function, &context.scopeFromLine, &context.scopeToLine);
context.expression = fixCppExpression(raw);
context.isCppEditor = CppTools::ProjectFile::classify(document->filePath().toString())
!= CppTools::ProjectFile::Unclassified;
if (context.expression.isEmpty()) {
ToolTip::show(point, DebuggerToolTipManager::tr("No valid expression"),
......@@ -1224,7 +1230,7 @@ static void slotTooltipOverrideRequested
tooltip->setState(PendingShown);
else
QTC_CHECK(false);
*handled = engine->setToolTipExpression(editorWidget, context);
*handled = engine->setToolTipExpression(context);
if (!*handled) {
ToolTip::show(point, DebuggerToolTipManager::tr("Expression too complex"),
Internal::mainWindow());
......
......@@ -71,6 +71,7 @@ public:
QPoint mousePosition;
QString expression;
QByteArray iname;
bool isCppEditor;
};
typedef QList<DebuggerToolTipContext> DebuggerToolTipContexts;
......
......@@ -67,10 +67,10 @@
#include <coreplugin/icore.h>
#include <coreplugin/messagebox.h>
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/itaskhandler.h>
#include <projectexplorer/taskhub.h>
#include <texteditor/texteditor.h>
#include <utils/algorithm.h>
#include <utils/hostosinfo.h>
......@@ -3699,10 +3699,9 @@ void GdbEngine::handleRegisterListValues(const DebuggerResponse &response)
//
//////////////////////////////////////////////////////////////////////
bool GdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editor,
const DebuggerToolTipContext &context)
bool GdbEngine::setToolTipExpression(const DebuggerToolTipContext &context)
{
if (state() != InferiorStopOk || !isCppEditor(editor))
if (state() != InferiorStopOk || !context.isCppEditor)
return false;
UpdateParameters params;
......
......@@ -383,8 +383,7 @@ protected:
//
// Watch specific stuff
//
virtual bool setToolTipExpression(TextEditor::TextEditorWidget *editor,
const DebuggerToolTipContext &);
virtual bool setToolTipExpression(const DebuggerToolTipContext &);
virtual void assignValueInDebugger(const WatchData *data,
const QString &expr, const QVariant &value);
......
......@@ -54,8 +54,6 @@
#include <coreplugin/idocument.h>
#include <coreplugin/icore.h>
#include <texteditor/texteditor.h>
#include <utils/qtcassert.h>
#include <utils/savedaction.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 "
// " OR NOT A CPPEDITOR";
return false;
......
......@@ -84,8 +84,7 @@ private:
void shutdownEngine();
void abortDebugger();
bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
const DebuggerToolTipContext &);
bool setToolTipExpression(const DebuggerToolTipContext &);
void continueInferior();
void interruptInferior();
......
......@@ -50,7 +50,6 @@
#include <utils/qtcassert.h>
#include <texteditor/texteditor.h>
#include <coreplugin/idocument.h>
#include <coreplugin/icore.h>
#include <coreplugin/messagebox.h>
......@@ -371,8 +370,7 @@ void PdbEngine::refreshSymbols(const GdbMi &symbols)
Internal::showModuleSymbols(moduleName, syms);
}
bool PdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *,
const DebuggerToolTipContext &ctx)
bool PdbEngine::setToolTipExpression(const DebuggerToolTipContext &ctx)
{
if (state() != InferiorStopOk)
return false;
......
......@@ -66,8 +66,7 @@ private:
void shutdownInferior();
void shutdownEngine();
bool setToolTipExpression(TextEditor::TextEditorWidget *,
const DebuggerToolTipContext &);
bool setToolTipExpression(const DebuggerToolTipContext &);
void continueInferior();
void interruptInferior();
......
......@@ -32,6 +32,7 @@
#include "qmlengine.h"
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggertooltipmanager.h>
#include <debugger/debuggerstartparameters.h>
#include <debugger/breakhandler.h>
#include <debugger/stackhandler.h>
......@@ -39,8 +40,6 @@
#include <debugger/watchhandler.h>
#include <utils/qtcassert.h>
#include <texteditor/texteditor.h>
#include <texteditor/textdocument.h>
#include <qmljseditor/qmljseditorconstants.h>
#include <cppeditor/cppeditorconstants.h>
#include <qmljs/consolemanagerinterface.h>
......@@ -103,15 +102,13 @@ bool QmlCppEngine::canDisplayTooltip() const
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;
Core::Id id = editorWidget->textDocument()->id();
if (id == CppEditor::Constants::CPPEDITOR_ID)
success = m_cppEngine->setToolTipExpression(editorWidget, ctx);
else if (id == QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
success = m_qmlEngine->setToolTipExpression(editorWidget, ctx);
if (ctx.isCppEditor)
success = m_cppEngine->setToolTipExpression(ctx);
else
success = m_qmlEngine->setToolTipExpression(ctx);
return success;
}
......
......@@ -47,8 +47,7 @@ public:
~QmlCppEngine();
bool canDisplayTooltip() const;
bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
const DebuggerToolTipContext &);
bool setToolTipExpression(const DebuggerToolTipContext &);
void updateWatchData(const WatchData &data);
void watchDataSelected(const QByteArray &iname);
......
......@@ -973,12 +973,12 @@ void QmlEngine::requestModuleSymbols(const QString &moduleName)
//
//////////////////////////////////////////////////////////////////////
bool QmlEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
const DebuggerToolTipContext &ctx)
bool QmlEngine::setToolTipExpression(const DebuggerToolTipContext &context)
{
// This is processed by QML inspector, which has dependencies to
// 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;
}
......
......@@ -89,8 +89,7 @@ public:
void insertBreakpoint(Breakpoint bp);
signals:
void tooltipRequested(const QPoint &mousePos,
TextEditor::TextEditorWidget *editorWidget, int cursorPos);
void tooltipRequested(const DebuggerToolTipContext &context);
private slots:
void disconnected();
......@@ -128,8 +127,7 @@ private:
void shutdownInferior();
void shutdownEngine();
bool setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
const DebuggerToolTipContext &);
bool setToolTipExpression(const DebuggerToolTipContext &);
void continueInferior();
void interruptInferior();
......
......@@ -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)
{
const Snapshot snapshot = CppModelManager::instance()->snapshot();
......
......@@ -40,7 +40,6 @@ namespace Debugger {
namespace Internal {
// Editor tooltip support
bool isCppEditor(TextEditor::TextEditorWidget *editorWidget);
QString cppExpressionAt(TextEditor::TextEditorWidget *editorWidget, int pos,
int *line, int *column, QString *function = 0,
int *scopeFromLine = 0, int *scopeToLine = 0);
......
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