forked from qt-creator/qt-creator
debugger: use ITextEditor in DebuggerManager
The dependency was there for a while. No need to jump through hoops hoping to maintain a stand-alone debugger anymore.
This commit is contained in:
@@ -186,6 +186,7 @@ DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &p)
|
|||||||
|
|
||||||
using namespace Constants;
|
using namespace Constants;
|
||||||
using namespace Debugger::Internal;
|
using namespace Debugger::Internal;
|
||||||
|
using namespace TextEditor;
|
||||||
|
|
||||||
static const QString tooltipIName = "tooltip";
|
static const QString tooltipIName = "tooltip";
|
||||||
|
|
||||||
@@ -863,12 +864,12 @@ BreakpointData *DebuggerManager::findBreakpoint(const QString &fileName, int lin
|
|||||||
|
|
||||||
void DebuggerManager::toggleBreakpoint()
|
void DebuggerManager::toggleBreakpoint()
|
||||||
{
|
{
|
||||||
QString fileName;
|
ITextEditor *textEditor = d->m_plugin->currentTextEditor();
|
||||||
int lineNumber = -1;
|
QTC_ASSERT(textEditor, return);
|
||||||
d->m_plugin->currentTextEditor(&fileName, &lineNumber);
|
QString fileName = textEditor->file()->fileName();
|
||||||
if (lineNumber == -1)
|
int lineNumber = textEditor->currentLine();
|
||||||
return;
|
if (lineNumber >= 0)
|
||||||
toggleBreakpoint(fileName, lineNumber);
|
toggleBreakpoint(fileName, lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerManager::toggleBreakpoint(const QString &fileName, int lineNumber)
|
void DebuggerManager::toggleBreakpoint(const QString &fileName, int lineNumber)
|
||||||
@@ -915,7 +916,8 @@ void DebuggerManager::attemptBreakpointSynchronization()
|
|||||||
d->m_engine->attemptBreakpointSynchronization();
|
d->m_engine->attemptBreakpointSynchronization();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerManager::setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos)
|
void DebuggerManager::setToolTipExpression(const QPoint &mousePos,
|
||||||
|
TextEditor::ITextEditor *editor, int cursorPos)
|
||||||
{
|
{
|
||||||
if (d->m_engine)
|
if (d->m_engine)
|
||||||
d->m_engine->setToolTipExpression(mousePos, editor, cursorPos);
|
d->m_engine->setToolTipExpression(mousePos, editor, cursorPos);
|
||||||
@@ -933,34 +935,30 @@ static QString msgEngineNotAvailable(const char *engine)
|
|||||||
"which is disabled.").arg(QLatin1String(engine));
|
"which is disabled.").arg(QLatin1String(engine));
|
||||||
}
|
}
|
||||||
|
|
||||||
static IDebuggerEngine *debuggerEngineForToolChain(ProjectExplorer::ToolChain::ToolChainType tc)
|
static IDebuggerEngine *debuggerEngineForToolChain(int toolChainType)
|
||||||
{
|
{
|
||||||
IDebuggerEngine *rc = 0;
|
switch (toolChainType) {
|
||||||
switch (tc) {
|
|
||||||
//case ProjectExplorer::ToolChain::LinuxICC:
|
//case ProjectExplorer::ToolChain::LinuxICC:
|
||||||
case ProjectExplorer::ToolChain::MinGW:
|
case ProjectExplorer::ToolChain::MinGW:
|
||||||
case ProjectExplorer::ToolChain::GCC:
|
case ProjectExplorer::ToolChain::GCC:
|
||||||
rc = gdbEngine;
|
return gdbEngine;
|
||||||
break;
|
|
||||||
case ProjectExplorer::ToolChain::MSVC:
|
case ProjectExplorer::ToolChain::MSVC:
|
||||||
case ProjectExplorer::ToolChain::WINCE:
|
case ProjectExplorer::ToolChain::WINCE:
|
||||||
rc = winEngine;
|
return winEngine;
|
||||||
break;
|
|
||||||
case ProjectExplorer::ToolChain::WINSCW: // S60
|
case ProjectExplorer::ToolChain::WINSCW: // S60
|
||||||
case ProjectExplorer::ToolChain::GCCE:
|
case ProjectExplorer::ToolChain::GCCE:
|
||||||
case ProjectExplorer::ToolChain::RVCT_ARMV5:
|
case ProjectExplorer::ToolChain::RVCT_ARMV5:
|
||||||
case ProjectExplorer::ToolChain::RVCT_ARMV6:
|
case ProjectExplorer::ToolChain::RVCT_ARMV6:
|
||||||
case ProjectExplorer::ToolChain::RVCT_ARMV5_GNUPOC:
|
case ProjectExplorer::ToolChain::RVCT_ARMV5_GNUPOC:
|
||||||
case ProjectExplorer::ToolChain::GCCE_GNUPOC:
|
case ProjectExplorer::ToolChain::GCCE_GNUPOC:
|
||||||
rc = gdbEngine;
|
return gdbEngine;
|
||||||
break;
|
|
||||||
case ProjectExplorer::ToolChain::OTHER:
|
case ProjectExplorer::ToolChain::OTHER:
|
||||||
case ProjectExplorer::ToolChain::UNKNOWN:
|
case ProjectExplorer::ToolChain::UNKNOWN:
|
||||||
case ProjectExplorer::ToolChain::INVALID:
|
case ProjectExplorer::ToolChain::INVALID:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return rc;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out the debugger type of an executable. Analyze executable
|
// Figure out the debugger type of an executable. Analyze executable
|
||||||
@@ -988,8 +986,7 @@ static IDebuggerEngine *determineDebuggerEngine(const QString &executable,
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (IDebuggerEngine *tce = debuggerEngineForToolChain(
|
if (IDebuggerEngine *tce = debuggerEngineForToolChain(toolChainType))
|
||||||
static_cast<ProjectExplorer::ToolChain::ToolChainType>(toolChainType)))
|
|
||||||
return tce;
|
return tce;
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
@@ -1024,8 +1021,7 @@ static IDebuggerEngine *determineDebuggerEngine(int /* pid */,
|
|||||||
int toolChainType,
|
int toolChainType,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (IDebuggerEngine *tce = debuggerEngineForToolChain(
|
if (IDebuggerEngine *tce = debuggerEngineForToolChain(toolChainType))
|
||||||
static_cast<ProjectExplorer::ToolChain::ToolChainType>(toolChainType)))
|
|
||||||
return tce;
|
return tce;
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Preferably Windows debugger
|
// Preferably Windows debugger
|
||||||
@@ -1380,9 +1376,10 @@ void DebuggerManager::interruptDebuggingRequest()
|
|||||||
|
|
||||||
void DebuggerManager::runToLineExec()
|
void DebuggerManager::runToLineExec()
|
||||||
{
|
{
|
||||||
QString fileName;
|
ITextEditor *textEditor = d->m_plugin->currentTextEditor();
|
||||||
int lineNumber = -1;
|
QTC_ASSERT(textEditor, return);
|
||||||
d->m_plugin->currentTextEditor(&fileName, &lineNumber);
|
QString fileName = textEditor->file()->fileName();
|
||||||
|
int lineNumber = textEditor->currentLine();
|
||||||
if (d->m_engine && !fileName.isEmpty()) {
|
if (d->m_engine && !fileName.isEmpty()) {
|
||||||
STATE_DEBUG(fileName << lineNumber);
|
STATE_DEBUG(fileName << lineNumber);
|
||||||
d->m_engine->runToLineExec(fileName, lineNumber);
|
d->m_engine->runToLineExec(fileName, lineNumber);
|
||||||
@@ -1391,10 +1388,10 @@ void DebuggerManager::runToLineExec()
|
|||||||
|
|
||||||
void DebuggerManager::runToFunctionExec()
|
void DebuggerManager::runToFunctionExec()
|
||||||
{
|
{
|
||||||
QString fileName;
|
ITextEditor *textEditor = d->m_plugin->currentTextEditor();
|
||||||
int lineNumber = -1;
|
QTC_ASSERT(textEditor, return);
|
||||||
QObject *object = d->m_plugin->currentTextEditor(&fileName, &lineNumber);
|
QString fileName = textEditor->file()->fileName();
|
||||||
QPlainTextEdit *ed = qobject_cast<QPlainTextEdit*>(object);
|
QPlainTextEdit *ed = qobject_cast<QPlainTextEdit*>(textEditor->widget());
|
||||||
if (!ed)
|
if (!ed)
|
||||||
return;
|
return;
|
||||||
QTextCursor cursor = ed->textCursor();
|
QTextCursor cursor = ed->textCursor();
|
||||||
@@ -1423,9 +1420,10 @@ void DebuggerManager::runToFunctionExec()
|
|||||||
|
|
||||||
void DebuggerManager::jumpToLineExec()
|
void DebuggerManager::jumpToLineExec()
|
||||||
{
|
{
|
||||||
QString fileName;
|
ITextEditor *textEditor = d->m_plugin->currentTextEditor();
|
||||||
int lineNumber = -1;
|
QTC_ASSERT(textEditor, return);
|
||||||
d->m_plugin->currentTextEditor(&fileName, &lineNumber);
|
QString fileName = textEditor->file()->fileName();
|
||||||
|
int lineNumber = textEditor->currentLine();
|
||||||
if (d->m_engine && !fileName.isEmpty()) {
|
if (d->m_engine && !fileName.isEmpty()) {
|
||||||
STATE_DEBUG(fileName << lineNumber);
|
STATE_DEBUG(fileName << lineNumber);
|
||||||
d->m_engine->jumpToLineExec(fileName, lineNumber);
|
d->m_engine->jumpToLineExec(fileName, lineNumber);
|
||||||
|
|||||||
@@ -1033,20 +1033,13 @@ void DebuggerPlugin::activateDebugMode()
|
|||||||
modeManager->activateMode(QLatin1String(MODE_DEBUG));
|
modeManager->activateMode(QLatin1String(MODE_DEBUG));
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *DebuggerPlugin::currentTextEditor(QString *fileName, int *lineNumber)
|
TextEditor::ITextEditor *DebuggerPlugin::currentTextEditor()
|
||||||
{
|
{
|
||||||
EditorManager *editorManager = EditorManager::instance();
|
EditorManager *editorManager = EditorManager::instance();
|
||||||
if (!editorManager)
|
if (!editorManager)
|
||||||
return 0;
|
return 0;
|
||||||
Core::IEditor *editor = editorManager->currentEditor();
|
Core::IEditor *editor = editorManager->currentEditor();
|
||||||
ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor);
|
return qobject_cast<ITextEditor*>(editor);
|
||||||
if (!textEditor)
|
|
||||||
return 0;
|
|
||||||
if (fileName)
|
|
||||||
*fileName = textEditor->file()->fileName();
|
|
||||||
if (lineNumber)
|
|
||||||
*lineNumber = textEditor->currentLine();
|
|
||||||
return textEditor->widget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPlugin::editorOpened(Core::IEditor *editor)
|
void DebuggerPlugin::editorOpened(Core::IEditor *editor)
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ private:
|
|||||||
virtual void remoteCommand(const QStringList &options, const QStringList &arguments);
|
virtual void remoteCommand(const QStringList &options, const QStringList &arguments);
|
||||||
|
|
||||||
QVariant configValue(const QString &name) const;
|
QVariant configValue(const QString &name) const;
|
||||||
QWidget *currentTextEditor(QString *fileName, int *line);
|
TextEditor::ITextEditor *currentTextEditor();
|
||||||
QVariant sessionValue(const QString &name);
|
QVariant sessionValue(const QString &name);
|
||||||
void setSessionValue(const QString &name, const QVariant &value);
|
void setSessionValue(const QString &name, const QVariant &value);
|
||||||
QVariant configValue(const QString &name);
|
QVariant configValue(const QString &name);
|
||||||
|
|||||||
Reference in New Issue
Block a user