Debugger: Use more FilePath in source file handling

Needed for the double-remote case.

With this we have proper breakpoint markers in the text editor for a remotely
running gdb on a remotely loaded project.

Change-Id: If80e4a4108a4a0bcdd7612a59e2bd695213f5ea5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2023-03-14 18:18:39 +01:00
parent 47ed25e95d
commit 0dc61f55c3
14 changed files with 87 additions and 83 deletions

View File

@@ -1802,10 +1802,10 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data)
updateScriptSource(name, lineOffset, columnOffset, source);
}
QMap<QString,QString> files;
QMap<QString, FilePath> files;
for (const QString &file : std::as_const(sourceFiles)) {
QString shortName = file;
QString fullName = engine->toFileInProject(file);
FilePath fullName = engine->toFileInProject(file);
files.insert(shortName, fullName);
}
@@ -1915,7 +1915,7 @@ void QmlEnginePrivate::messageReceived(const QByteArray &data)
const QVariantMap script = body.value("script").toMap();
QUrl fileUrl(script.value(NAME).toString());
QString filePath = engine->toFileInProject(fileUrl);
FilePath filePath = engine->toFileInProject(fileUrl);
const QVariantMap exception = body.value("exception").toMap();
QString errorMessage = exception.value("text").toString();
@@ -2045,8 +2045,7 @@ StackFrame QmlEnginePrivate::extractStackFrame(const QVariant &bodyVal)
stackFrame.function = extractString(body.value("func"));
if (stackFrame.function.isEmpty())
stackFrame.function = Tr::tr("Anonymous Function");
stackFrame.file = FilePath::fromString(
engine->toFileInProject(extractString(body.value("script"))));
stackFrame.file = engine->toFileInProject(extractString(body.value("script")));
stackFrame.usable = stackFrame.file.isReadableFile();
stackFrame.receiver = extractString(body.value("receiver"));
stackFrame.line = body.value("line").toInt() + 1;
@@ -2444,7 +2443,7 @@ void QmlEnginePrivate::flushSendBuffer()
sendBuffer.clear();
}
QString QmlEngine::toFileInProject(const QUrl &fileUrl)
FilePath QmlEngine::toFileInProject(const QUrl &fileUrl)
{
// make sure file finder is properly initialized
const DebuggerRunParameters &rp = runParameters();
@@ -2453,7 +2452,7 @@ QString QmlEngine::toFileInProject(const QUrl &fileUrl)
d->fileFinder.setAdditionalSearchDirectories(rp.additionalSearchDirectories);
d->fileFinder.setSysroot(rp.sysRoot);
return d->fileFinder.findFile(fileUrl).constFirst().toString();
return d->fileFinder.findFile(fileUrl).constFirst();
}
DebuggerEngine *createQmlEngine()

View File

@@ -25,7 +25,7 @@ public:
void logServiceActivity(const QString &service, const QString &logMessage);
void expressionEvaluated(quint32 queryId, const QVariant &result);
QString toFileInProject(const QUrl &fileUrl);
Utils::FilePath toFileInProject(const QUrl &fileUrl);
private:
void disconnected();

View File

@@ -20,6 +20,7 @@ using namespace QmlDebug;
using namespace QmlJS;
using namespace QmlJS::AST;
using namespace TextEditor;
using namespace Utils;
namespace Debugger::Internal {
@@ -218,11 +219,10 @@ void clearExceptionSelection()
}
}
QStringList highlightExceptionCode(int lineNumber, const QString &filePath, const QString &errorMessage)
QStringList highlightExceptionCode(int lineNumber, const FilePath &filePath, const QString &errorMessage)
{
QStringList messages;
const QList<IEditor *> editors = DocumentModel::editorsForFilePath(
Utils::FilePath::fromString(filePath));
const QList<IEditor *> editors = DocumentModel::editorsForFilePath(filePath);
const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::fontSettings();
QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
@@ -251,7 +251,7 @@ QStringList highlightExceptionCode(int lineNumber, const QString &filePath, cons
selections.append(sel);
ed->setExtraSelections(TextEditorWidget::DebuggerExceptionSelection, selections);
messages.append(QString::fromLatin1("%1: %2: %3").arg(filePath).arg(lineNumber).arg(errorMessage));
messages.append(QString::fromLatin1("%1: %2: %3").arg(filePath.toUserOutput()).arg(lineNumber).arg(errorMessage));
}
return messages;
}

View File

@@ -6,11 +6,13 @@
#include <qmldebug/qdebugmessageclient.h>
#include <qmldebug/qmloutputparser.h>
namespace Utils { class FilePath; }
namespace Debugger::Internal {
void appendDebugOutput(QtMsgType type, const QString &message, const QmlDebug::QDebugContextInfo &info);
void clearExceptionSelection();
QStringList highlightExceptionCode(int lineNumber, const QString &filePath, const QString &errorMessage);
QStringList highlightExceptionCode(int lineNumber, const Utils::FilePath &filePath, const QString &errorMessage);
} // Debugger::Internal

View File

@@ -32,6 +32,7 @@
using namespace QmlDebug;
using namespace QmlDebug::Constants;
using namespace Utils;
namespace Debugger::Internal {
@@ -541,8 +542,8 @@ void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref)
lineNum += match.captured(3).toInt() - 1;
}
const QString filePath = m_qmlEngine->toFileInProject(fileUrl);
m_debugIdLocations.insert(ref.debugId(), FileReference(filePath, lineNum, colNum));
const FilePath filePath = m_qmlEngine->toFileInProject(fileUrl);
m_debugIdLocations.insert(ref.debugId(), FileReference(filePath.toFSPathString(), lineNum, colNum));
const auto children = ref.children();
for (const ObjectReference &it : children)
@@ -735,7 +736,7 @@ void QmlInspectorAgent::onShowAppOnTopChanged(bool checked)
void QmlInspectorAgent::jumpToObjectDefinitionInEditor(const FileReference &objSource)
{
const auto filePath = Utils::FilePath::fromString(m_qmlEngine->toFileInProject(objSource.url()));
const FilePath filePath = m_qmlEngine->toFileInProject(objSource.url());
Core::EditorManager::openEditorAt({filePath, objSource.lineNumber()});
}