forked from qt-creator/qt-creator
Debugger: filepathify DiagnosticLocation
Change-Id: Ibbbf137231b313ec10e3d57c0230217b0c1e0a6c Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1277,14 +1277,14 @@ FilePath FilePath::onDevice(const FilePath &deviceTemplate) const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath FilePath::pathAppended(const QString &str) const
|
FilePath FilePath::pathAppended(const QString &path) const
|
||||||
{
|
{
|
||||||
FilePath fn = *this;
|
FilePath fn = *this;
|
||||||
if (str.isEmpty())
|
if (path.isEmpty())
|
||||||
return fn;
|
return fn;
|
||||||
if (!fn.m_data.isEmpty() && !fn.m_data.endsWith(QLatin1Char('/')))
|
if (!fn.m_data.isEmpty() && !fn.m_data.endsWith(QLatin1Char('/')))
|
||||||
fn.m_data.append('/');
|
fn.m_data.append('/');
|
||||||
fn.m_data.append(str);
|
fn.m_data.append(path);
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -209,7 +209,7 @@ public:
|
|||||||
ApplyFixIts(const QVector<DiagnosticItem *> &diagnosticItems)
|
ApplyFixIts(const QVector<DiagnosticItem *> &diagnosticItems)
|
||||||
{
|
{
|
||||||
for (DiagnosticItem *diagnosticItem : diagnosticItems) {
|
for (DiagnosticItem *diagnosticItem : diagnosticItems) {
|
||||||
const QString &filePath = diagnosticItem->diagnostic().location.filePath;
|
const Utils::FilePath &filePath = diagnosticItem->diagnostic().location.filePath;
|
||||||
QTC_ASSERT(!filePath.isEmpty(), continue);
|
QTC_ASSERT(!filePath.isEmpty(), continue);
|
||||||
|
|
||||||
// Get or create refactoring file
|
// Get or create refactoring file
|
||||||
@@ -245,14 +245,14 @@ public:
|
|||||||
|
|
||||||
const Debugger::DiagnosticLocation start = step.ranges.first();
|
const Debugger::DiagnosticLocation start = step.ranges.first();
|
||||||
const Debugger::DiagnosticLocation end = step.ranges.last();
|
const Debugger::DiagnosticLocation end = step.ranges.last();
|
||||||
const int startPos = file.position(start.filePath, start.line, start.column);
|
const int startPos = file.position(start.filePath.toString(), start.line, start.column);
|
||||||
const int endPos = file.position(start.filePath, end.line, end.column);
|
const int endPos = file.position(start.filePath.toString(), end.line, end.column);
|
||||||
|
|
||||||
auto op = new ReplacementOperation;
|
auto op = new ReplacementOperation;
|
||||||
op->pos = startPos;
|
op->pos = startPos;
|
||||||
op->length = endPos - startPos;
|
op->length = endPos - startPos;
|
||||||
op->text = step.message;
|
op->text = step.message;
|
||||||
op->fileName = start.filePath;
|
op->fileName = start.filePath.toString();
|
||||||
op->apply = apply;
|
op->apply = apply;
|
||||||
|
|
||||||
replacements += op;
|
replacements += op;
|
||||||
@@ -322,7 +322,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<QString, RefactoringFileInfo> m_refactoringFileInfos;
|
QMap<Utils::FilePath, RefactoringFileInfo> m_refactoringFileInfos;
|
||||||
};
|
};
|
||||||
|
|
||||||
static FileInfos sortedFileInfos(const QVector<CppTools::ProjectPart::Ptr> &projectParts)
|
static FileInfos sortedFileInfos(const QVector<CppTools::ProjectPart::Ptr> &projectParts)
|
||||||
@@ -1119,7 +1119,7 @@ QSet<Diagnostic> ClangTool::diagnostics() const
|
|||||||
{
|
{
|
||||||
return Utils::filtered(m_diagnosticModel->diagnostics(), [](const Diagnostic &diagnostic) {
|
return Utils::filtered(m_diagnosticModel->diagnostics(), [](const Diagnostic &diagnostic) {
|
||||||
using CppTools::ProjectFile;
|
using CppTools::ProjectFile;
|
||||||
return ProjectFile::isSource(ProjectFile::classify(diagnostic.location.filePath));
|
return ProjectFile::isSource(ProjectFile::classify(diagnostic.location.filePath.toString()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ static Q_LOGGING_CATEGORY(LOG, "qtc.clangtools.model", QtWarningMsg)
|
|||||||
namespace ClangTools {
|
namespace ClangTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
FilePathItem::FilePathItem(const QString &filePath)
|
FilePathItem::FilePathItem(const Utils::FilePath &filePath)
|
||||||
: m_filePath(filePath)
|
: m_filePath(filePath)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -56,11 +56,11 @@ QVariant FilePathItem::data(int column, int role) const
|
|||||||
if (column == DiagnosticView::DiagnosticColumn) {
|
if (column == DiagnosticView::DiagnosticColumn) {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return m_filePath;
|
return m_filePath.toUserOutput();
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
return Core::FileIconProvider::icon(QFileInfo(m_filePath));
|
return Core::FileIconProvider::icon(m_filePath.toFileInfo());
|
||||||
case Debugger::DetailedErrorView::FullTextRole:
|
case Debugger::DetailedErrorView::FullTextRole:
|
||||||
return m_filePath;
|
return m_filePath.toUserOutput();
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@@ -119,12 +119,12 @@ void ClangToolsDiagnosticModel::addDiagnostics(const Diagnostics &diagnostics, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create file path item if necessary
|
// Create file path item if necessary
|
||||||
const QString filePath = d.location.filePath;
|
const Utils::FilePath &filePath = d.location.filePath;
|
||||||
FilePathItem *&filePathItem = m_filePathToItem[filePath];
|
FilePathItem *&filePathItem = m_filePathToItem[filePath];
|
||||||
if (!filePathItem) {
|
if (!filePathItem) {
|
||||||
filePathItem = new FilePathItem(filePath);
|
filePathItem = new FilePathItem(filePath);
|
||||||
rootItem()->appendChild(filePathItem);
|
rootItem()->appendChild(filePathItem);
|
||||||
addWatchedPath(d.location.filePath);
|
addWatchedPath(filePath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to file path item
|
// Add to file path item
|
||||||
@@ -184,7 +184,7 @@ void ClangToolsDiagnosticModel::clearAndSetupCache()
|
|||||||
void ClangToolsDiagnosticModel::onFileChanged(const QString &path)
|
void ClangToolsDiagnosticModel::onFileChanged(const QString &path)
|
||||||
{
|
{
|
||||||
forItemsAtLevel<2>([&](DiagnosticItem *item){
|
forItemsAtLevel<2>([&](DiagnosticItem *item){
|
||||||
if (item->diagnostic().location.filePath == path)
|
if (item->diagnostic().location.filePath == Utils::FilePath::fromString(path))
|
||||||
item->setFixItStatus(FixitStatus::Invalidated);
|
item->setFixItStatus(FixitStatus::Invalidated);
|
||||||
});
|
});
|
||||||
removeWatchedPath(path);
|
removeWatchedPath(path);
|
||||||
@@ -238,7 +238,7 @@ static QString createExplainingStepToolTipString(const ExplainingStep &step)
|
|||||||
|
|
||||||
static QString createLocationString(const Debugger::DiagnosticLocation &location)
|
static QString createLocationString(const Debugger::DiagnosticLocation &location)
|
||||||
{
|
{
|
||||||
const QString filePath = location.filePath;
|
const QString filePath = location.filePath.toUserOutput();
|
||||||
const QString lineNumber = QString::number(location.line);
|
const QString lineNumber = QString::number(location.line);
|
||||||
const QString fileAndLine = filePath + QLatin1Char(':') + lineNumber;
|
const QString fileAndLine = filePath + QLatin1Char(':') + lineNumber;
|
||||||
return QLatin1String("in ") + fileAndLine;
|
return QLatin1String("in ") + fileAndLine;
|
||||||
@@ -262,7 +262,7 @@ static QString createExplainingStepString(const ExplainingStep &explainingStep,
|
|||||||
|
|
||||||
static QString fullText(const Diagnostic &diagnostic)
|
static QString fullText(const Diagnostic &diagnostic)
|
||||||
{
|
{
|
||||||
QString text = diagnostic.location.filePath + QLatin1Char(':');
|
QString text = diagnostic.location.filePath.toUserOutput() + QLatin1Char(':');
|
||||||
text += lineColumnString(diagnostic.location) + QLatin1String(": ");
|
text += lineColumnString(diagnostic.location) + QLatin1String(": ");
|
||||||
if (!diagnostic.category.isEmpty())
|
if (!diagnostic.category.isEmpty())
|
||||||
text += diagnostic.category + QLatin1String(": ");
|
text += diagnostic.category + QLatin1String(": ");
|
||||||
@@ -452,7 +452,9 @@ QVariant ExplainingStepItem::data(int column, int role) const
|
|||||||
return QVariant::fromValue(m_step.location);
|
return QVariant::fromValue(m_step.location);
|
||||||
case Debugger::DetailedErrorView::FullTextRole: {
|
case Debugger::DetailedErrorView::FullTextRole: {
|
||||||
return QString("%1:%2: %3")
|
return QString("%1:%2: %3")
|
||||||
.arg(m_step.location.filePath, lineColumnString(m_step.location), m_step.message);
|
.arg(m_step.location.filePath.toUserOutput(),
|
||||||
|
lineColumnString(m_step.location),
|
||||||
|
m_step.message);
|
||||||
}
|
}
|
||||||
case ClangToolsDiagnosticModel::TextRole:
|
case ClangToolsDiagnosticModel::TextRole:
|
||||||
return m_step.message;
|
return m_step.message;
|
||||||
@@ -461,11 +463,12 @@ QVariant ExplainingStepItem::data(int column, int role) const
|
|||||||
case ClangToolsDiagnosticModel::DocumentationUrlRole:
|
case ClangToolsDiagnosticModel::DocumentationUrlRole:
|
||||||
return parent()->data(column, role);
|
return parent()->data(column, role);
|
||||||
case Qt::DisplayRole: {
|
case Qt::DisplayRole: {
|
||||||
const QString mainFilePath = static_cast<DiagnosticItem *>(parent())->diagnostic().location.filePath;
|
const Utils::FilePath mainFilePath
|
||||||
|
= static_cast<DiagnosticItem *>(parent())->diagnostic().location.filePath;
|
||||||
const QString locationString
|
const QString locationString
|
||||||
= m_step.location.filePath == mainFilePath
|
= m_step.location.filePath == mainFilePath
|
||||||
? lineColumnString(m_step.location)
|
? lineColumnString(m_step.location)
|
||||||
: QString("%1:%2").arg(QFileInfo(m_step.location.filePath).fileName(),
|
: QString("%1:%2").arg(m_step.location.filePath.fileName(),
|
||||||
lineColumnString(m_step.location));
|
lineColumnString(m_step.location));
|
||||||
|
|
||||||
if (m_step.isFixIt) {
|
if (m_step.isFixIt) {
|
||||||
@@ -645,10 +648,9 @@ bool DiagnosticFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
|
|||||||
foreach (const SuppressedDiagnostic &d, m_suppressedDiagnostics) {
|
foreach (const SuppressedDiagnostic &d, m_suppressedDiagnostics) {
|
||||||
if (d.description != diag.description)
|
if (d.description != diag.description)
|
||||||
continue;
|
continue;
|
||||||
QString filePath = d.filePath.toString();
|
Utils::FilePath filePath = d.filePath;
|
||||||
QFileInfo fi(filePath);
|
if (d.filePath.toFileInfo().isRelative())
|
||||||
if (fi.isRelative())
|
filePath = m_lastProjectDirectory.pathAppended(filePath.toString());
|
||||||
filePath = m_lastProjectDirectory.toString() + QLatin1Char('/') + filePath;
|
|
||||||
if (filePath == diag.location.filePath) {
|
if (filePath == diag.location.filePath) {
|
||||||
diagnosticItem->setTextMarkVisible(false);
|
diagnosticItem->setTextMarkVisible(false);
|
||||||
return false;
|
return false;
|
||||||
|
@@ -54,11 +54,11 @@ class ClangToolsDiagnosticModel;
|
|||||||
class FilePathItem : public Utils::TreeItem
|
class FilePathItem : public Utils::TreeItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FilePathItem(const QString &filePath);
|
FilePathItem(const Utils::FilePath &filePath);
|
||||||
QVariant data(int column, int role) const override;
|
QVariant data(int column, int role) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_filePath;
|
const Utils::FilePath m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiagnosticMark;
|
class DiagnosticMark;
|
||||||
@@ -139,7 +139,7 @@ private:
|
|||||||
void clearAndSetupCache();
|
void clearAndSetupCache();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QString, FilePathItem *> m_filePathToItem;
|
QHash<Utils::FilePath, FilePathItem *> m_filePathToItem;
|
||||||
QSet<Diagnostic> m_diagnostics;
|
QSet<Diagnostic> m_diagnostics;
|
||||||
std::map<QVector<ExplainingStep>, QVector<DiagnosticItem *>> stepsToItemsCache;
|
std::map<QVector<ExplainingStep>, QVector<DiagnosticItem *>> stepsToItemsCache;
|
||||||
std::unique_ptr<QFileSystemWatcher> m_filesWatcher;
|
std::unique_ptr<QFileSystemWatcher> m_filesWatcher;
|
||||||
|
@@ -222,7 +222,7 @@ void DiagnosticView::suppressCurrentDiagnostic()
|
|||||||
diags << diag;
|
diags << diag;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Utils::FilePath filePath = Utils::FilePath::fromString(diag.location.filePath);
|
Utils::FilePath filePath = diag.location.filePath;
|
||||||
const Utils::FilePath relativeFilePath
|
const Utils::FilePath relativeFilePath
|
||||||
= filePath.relativeChildPath(project->projectDirectory());
|
= filePath.relativeChildPath(project->projectDirectory());
|
||||||
if (!relativeFilePath.isEmpty())
|
if (!relativeFilePath.isEmpty())
|
||||||
@@ -402,7 +402,7 @@ void DiagnosticView::openEditorForCurrentIndex()
|
|||||||
const QVariant v = model()->data(currentIndex(), Debugger::DetailedErrorView::LocationRole);
|
const QVariant v = model()->data(currentIndex(), Debugger::DetailedErrorView::LocationRole);
|
||||||
const auto loc = v.value<Debugger::DiagnosticLocation>();
|
const auto loc = v.value<Debugger::DiagnosticLocation>();
|
||||||
if (loc.isValid())
|
if (loc.isValid())
|
||||||
Core::EditorManager::openEditorAt(loc.filePath, loc.line, loc.column - 1);
|
Core::EditorManager::openEditorAt(Utils::Link(loc.filePath, loc.line, loc.column - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -155,16 +155,16 @@ public:
|
|||||||
int extraOffset = 0)
|
int extraOffset = 0)
|
||||||
: m_node(node)
|
: m_node(node)
|
||||||
, m_fileCache(fileCache)
|
, m_fileCache(fileCache)
|
||||||
, m_filePath(QDir::cleanPath(asString(node["FilePath"])))
|
, m_filePath(Utils::FilePath::fromUserInput(asString(node["FilePath"])))
|
||||||
, m_fileOffsetKey(fileOffsetKey)
|
, m_fileOffsetKey(fileOffsetKey)
|
||||||
, m_extraOffset(extraOffset)
|
, m_extraOffset(extraOffset)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QString filePath() const { return m_filePath; }
|
Utils::FilePath filePath() const { return m_filePath; }
|
||||||
|
|
||||||
Debugger::DiagnosticLocation toDiagnosticLocation() const
|
Debugger::DiagnosticLocation toDiagnosticLocation() const
|
||||||
{
|
{
|
||||||
FileCache::Item &cacheItem = m_fileCache.item(m_filePath);
|
FileCache::Item &cacheItem = m_fileCache.item(m_filePath.toString());
|
||||||
const QByteArray fileContents = cacheItem.fileContents();
|
const QByteArray fileContents = cacheItem.fileContents();
|
||||||
|
|
||||||
const char *data = fileContents.data();
|
const char *data = fileContents.data();
|
||||||
@@ -205,7 +205,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
const YAML::Node &m_node;
|
const YAML::Node &m_node;
|
||||||
FileCache &m_fileCache;
|
FileCache &m_fileCache;
|
||||||
QString m_filePath;
|
Utils::FilePath m_filePath;
|
||||||
const char *m_fileOffsetKey = nullptr;
|
const char *m_fileOffsetKey = nullptr;
|
||||||
int m_extraOffset = 0;
|
int m_extraOffset = 0;
|
||||||
};
|
};
|
||||||
@@ -232,10 +232,8 @@ Diagnostics readExportedDiagnostics(const Utils::FilePath &logFilePath,
|
|||||||
Location loc(node, fileCache);
|
Location loc(node, fileCache);
|
||||||
if (loc.filePath().isEmpty())
|
if (loc.filePath().isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (acceptFromFilePath
|
if (acceptFromFilePath && !acceptFromFilePath(loc.filePath()))
|
||||||
&& !acceptFromFilePath(Utils::FilePath::fromString(loc.filePath()))) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
Diagnostic diag;
|
Diagnostic diag;
|
||||||
diag.location = loc.toDiagnosticLocation();
|
diag.location = loc.toDiagnosticLocation();
|
||||||
|
@@ -232,7 +232,7 @@ ClangToolsProjectSettings::ClangToolsProjectSettingsPtr
|
|||||||
}
|
}
|
||||||
|
|
||||||
SuppressedDiagnostic::SuppressedDiagnostic(const Diagnostic &diag)
|
SuppressedDiagnostic::SuppressedDiagnostic(const Diagnostic &diag)
|
||||||
: filePath(Utils::FilePath::fromString(diag.location.filePath))
|
: filePath(diag.location.filePath)
|
||||||
, description(diag.description)
|
, description(diag.description)
|
||||||
, uniquifier(diag.explainingSteps.count())
|
, uniquifier(diag.explainingSteps.count())
|
||||||
{
|
{
|
||||||
|
@@ -115,7 +115,7 @@ QString createDiagnosticToolTipString(
|
|||||||
if (!steps.second.isEmpty())
|
if (!steps.second.isEmpty())
|
||||||
steps.second += "<br>";
|
steps.second += "<br>";
|
||||||
steps.second += QString("%1:%2: %3")
|
steps.second += QString("%1:%2: %3")
|
||||||
.arg(step.location.filePath,
|
.arg(step.location.filePath.toUserOutput(),
|
||||||
lineColumnString(step.location),
|
lineColumnString(step.location),
|
||||||
step.message);
|
step.message);
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ QString createDiagnosticToolTipString(
|
|||||||
|
|
||||||
QString createFullLocationString(const Debugger::DiagnosticLocation &location)
|
QString createFullLocationString(const Debugger::DiagnosticLocation &location)
|
||||||
{
|
{
|
||||||
return location.filePath + QLatin1Char(':') + QString::number(location.line)
|
return location.filePath.toUserOutput() + QLatin1Char(':') + QString::number(location.line)
|
||||||
+ QLatin1Char(':') + QString::number(location.column);
|
+ QLatin1Char(':') + QString::number(location.column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1162,8 +1162,8 @@ void disableChecks(const QList<Diagnostic> &diagnostics)
|
|||||||
Utils::Id activeConfigId = settings->runSettings().diagnosticConfigId();
|
Utils::Id activeConfigId = settings->runSettings().diagnosticConfigId();
|
||||||
ClangToolsProjectSettings::ClangToolsProjectSettingsPtr projectSettings;
|
ClangToolsProjectSettings::ClangToolsProjectSettingsPtr projectSettings;
|
||||||
|
|
||||||
if (ProjectExplorer::Project *project = ProjectExplorer::SessionManager
|
if (ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(
|
||||||
::projectForFile(Utils::FilePath::fromString(diagnostics.first().location.filePath))) {
|
diagnostics.first().location.filePath)) {
|
||||||
projectSettings = ClangToolsProjectSettings::getSettings(project);
|
projectSettings = ClangToolsProjectSettings::getSettings(project);
|
||||||
if (!projectSettings->useGlobalSettings())
|
if (!projectSettings->useGlobalSettings())
|
||||||
activeConfigId = projectSettings->runSettings().diagnosticConfigId();
|
activeConfigId = projectSettings->runSettings().diagnosticConfigId();
|
||||||
|
@@ -39,7 +39,7 @@ namespace ClangTools {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
||||||
: TextEditor::TextMark(Utils::FilePath::fromString(diagnostic.location.filePath),
|
: TextEditor::TextMark(diagnostic.location.filePath,
|
||||||
diagnostic.location.line,
|
diagnostic.location.line,
|
||||||
Utils::Id(Constants::DIAGNOSTIC_MARK_ID))
|
Utils::Id(Constants::DIAGNOSTIC_MARK_ID))
|
||||||
, m_diagnostic(diagnostic)
|
, m_diagnostic(diagnostic)
|
||||||
|
@@ -264,7 +264,7 @@ void DocumentClangToolRunner::runNext()
|
|||||||
|
|
||||||
static void updateLocation(Debugger::DiagnosticLocation &location)
|
static void updateLocation(Debugger::DiagnosticLocation &location)
|
||||||
{
|
{
|
||||||
location.filePath = vfso().originalFilePath(Utils::FilePath::fromString(location.filePath)).toString();
|
location.filePath = vfso().originalFilePath(location.filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentClangToolRunner::onSuccess()
|
void DocumentClangToolRunner::onSuccess()
|
||||||
@@ -364,10 +364,9 @@ bool DocumentClangToolRunner::isSuppressed(const Diagnostic &diagnostic) const
|
|||||||
auto equalsSuppressed = [this, &diagnostic](const SuppressedDiagnostic &suppressed) {
|
auto equalsSuppressed = [this, &diagnostic](const SuppressedDiagnostic &suppressed) {
|
||||||
if (suppressed.description != diagnostic.description)
|
if (suppressed.description != diagnostic.description)
|
||||||
return false;
|
return false;
|
||||||
QString filePath = suppressed.filePath.toString();
|
Utils::FilePath filePath = suppressed.filePath;
|
||||||
QFileInfo fi(filePath);
|
if (filePath.toFileInfo().isRelative())
|
||||||
if (fi.isRelative())
|
filePath = m_lastProjectDirectory.pathAppended(filePath.toString());
|
||||||
filePath = m_lastProjectDirectory.toString() + QLatin1Char('/') + filePath;
|
|
||||||
return filePath == diagnostic.location.filePath;
|
return filePath == diagnostic.location.filePath;
|
||||||
};
|
};
|
||||||
return Utils::anyOf(m_suppressed, equalsSuppressed);
|
return Utils::anyOf(m_suppressed, equalsSuppressed);
|
||||||
|
@@ -68,9 +68,10 @@ void ClangToolQuickFixOperation::perform()
|
|||||||
for (const ExplainingStep &step : m_diagnostic.explainingSteps) {
|
for (const ExplainingStep &step : m_diagnostic.explainingSteps) {
|
||||||
if (!step.isFixIt)
|
if (!step.isFixIt)
|
||||||
continue;
|
continue;
|
||||||
TextEditor::RefactoringFilePtr &refactoringFile = refactoringFiles[step.location.filePath];
|
TextEditor::RefactoringFilePtr &refactoringFile
|
||||||
|
= refactoringFiles[step.location.filePath.toString()];
|
||||||
if (refactoringFile.isNull())
|
if (refactoringFile.isNull())
|
||||||
refactoringFile = changes.file(Utils::FilePath::fromString(step.location.filePath));
|
refactoringFile = changes.file(step.location.filePath);
|
||||||
Utils::ChangeSet changeSet = refactoringFile->changeSet();
|
Utils::ChangeSet changeSet = refactoringFile->changeSet();
|
||||||
Range range = toRange(refactoringFile->document(), {step.ranges.first(), step.ranges.last()});
|
Range range = toRange(refactoringFile->document(), {step.ranges.first(), step.ranges.last()});
|
||||||
changeSet.replace(range, step.message);
|
changeSet.replace(range, step.message);
|
||||||
|
@@ -79,7 +79,7 @@ QVariant DiagnosticItem::data(int column, int role) const
|
|||||||
if (column == DiagnosticsModel::DiagnosticColumn) {
|
if (column == DiagnosticsModel::DiagnosticColumn) {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case DetailedErrorView::LocationRole: {
|
case DetailedErrorView::LocationRole: {
|
||||||
const auto location = DiagnosticLocation(m_diagnostic.fileName.toString(),
|
const auto location = DiagnosticLocation(m_diagnostic.fileName,
|
||||||
m_diagnostic.lineNumber,
|
m_diagnostic.lineNumber,
|
||||||
0);
|
0);
|
||||||
return QVariant::fromValue(location);
|
return QVariant::fromValue(location);
|
||||||
@@ -92,7 +92,7 @@ QVariant DiagnosticItem::data(int column, int role) const
|
|||||||
return getIcon(m_diagnostic.severity);
|
return getIcon(m_diagnostic.severity);
|
||||||
case Debugger::DetailedErrorView::FullTextRole:
|
case Debugger::DetailedErrorView::FullTextRole:
|
||||||
return QString("%1:%2: %3")
|
return QString("%1:%2: %3")
|
||||||
.arg(m_diagnostic.fileName.toString())
|
.arg(m_diagnostic.fileName.toUserOutput())
|
||||||
.arg(m_diagnostic.lineNumber)
|
.arg(m_diagnostic.lineNumber)
|
||||||
.arg(m_diagnostic.message);
|
.arg(m_diagnostic.message);
|
||||||
default:
|
default:
|
||||||
|
@@ -103,7 +103,7 @@ void DiagnosticView::openEditorForCurrentIndex()
|
|||||||
const QVariant v = model()->data(currentIndex(), Debugger::DetailedErrorView::LocationRole);
|
const QVariant v = model()->data(currentIndex(), Debugger::DetailedErrorView::LocationRole);
|
||||||
const auto loc = v.value<Debugger::DiagnosticLocation>();
|
const auto loc = v.value<Debugger::DiagnosticLocation>();
|
||||||
if (loc.isValid())
|
if (loc.isValid())
|
||||||
Core::EditorManager::openEditorAt(loc.filePath, loc.line, loc.column - 1);
|
Core::EditorManager::openEditorAt(Utils::Link(loc.filePath, loc.line, loc.column - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticView::mouseDoubleClickEvent(QMouseEvent *event)
|
void DiagnosticView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
@@ -66,7 +66,7 @@ DetailedErrorView::DetailedErrorView(QWidget *parent) :
|
|||||||
const auto loc = index.model()->data(index, DetailedErrorView::LocationRole)
|
const auto loc = index.model()->data(index, DetailedErrorView::LocationRole)
|
||||||
.value<DiagnosticLocation>();
|
.value<DiagnosticLocation>();
|
||||||
if (loc.isValid())
|
if (loc.isValid())
|
||||||
Core::EditorManager::openEditorAt(loc.filePath, loc.line, loc.column - 1);
|
Core::EditorManager::openEditorAt(Utils::Link(loc.filePath, loc.line, loc.column - 1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -123,12 +123,12 @@ QVariant DetailedErrorView::locationData(int role, const DiagnosticLocation &loc
|
|||||||
return QVariant::fromValue(location);
|
return QVariant::fromValue(location);
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return location.isValid() ? QString::fromLatin1("%1:%2:%3")
|
return location.isValid() ? QString::fromLatin1("%1:%2:%3")
|
||||||
.arg(QFileInfo(location.filePath).fileName())
|
.arg(location.filePath.fileName())
|
||||||
.arg(location.line)
|
.arg(location.line)
|
||||||
.arg(location.column)
|
.arg(location.column)
|
||||||
: QString();
|
: QString();
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
return location.filePath.isEmpty() ? QVariant() : QVariant(location.filePath);
|
return location.filePath.isEmpty() ? QVariant() : QVariant(location.filePath.toUserOutput());
|
||||||
case Qt::FontRole: {
|
case Qt::FontRole: {
|
||||||
QFont font = QApplication::font();
|
QFont font = QApplication::font();
|
||||||
font.setUnderline(true);
|
font.setUnderline(true);
|
||||||
|
@@ -29,7 +29,7 @@ namespace Debugger {
|
|||||||
|
|
||||||
DiagnosticLocation::DiagnosticLocation() = default;
|
DiagnosticLocation::DiagnosticLocation() = default;
|
||||||
|
|
||||||
DiagnosticLocation::DiagnosticLocation(const QString &filePath, int line, int column)
|
DiagnosticLocation::DiagnosticLocation(const Utils::FilePath &filePath, int line, int column)
|
||||||
: filePath(filePath), line(line), column(column)
|
: filePath(filePath), line(line), column(column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include <debugger/debugger_global.h>
|
#include <debugger/debugger_global.h>
|
||||||
|
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -37,11 +39,11 @@ class DEBUGGER_EXPORT DiagnosticLocation
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DiagnosticLocation();
|
DiagnosticLocation();
|
||||||
DiagnosticLocation(const QString &filePath, int line, int column);
|
DiagnosticLocation(const Utils::FilePath &filePath, int line, int column);
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
QString filePath;
|
Utils::FilePath filePath;
|
||||||
|
|
||||||
// Both values start at 1.
|
// Both values start at 1.
|
||||||
int line = 0;
|
int line = 0;
|
||||||
|
@@ -175,7 +175,9 @@ ErrorItem::ErrorItem(const ErrorListModel *model, const Error &error)
|
|||||||
|
|
||||||
static QVariant locationData(int role, const Frame &frame)
|
static QVariant locationData(int role, const Frame &frame)
|
||||||
{
|
{
|
||||||
const Debugger::DiagnosticLocation location(frame.filePath(), frame.line(), 0);
|
const Debugger::DiagnosticLocation location(Utils::FilePath::fromString(frame.filePath()),
|
||||||
|
frame.line(),
|
||||||
|
0);
|
||||||
return Debugger::DetailedErrorView::locationData(role, location);
|
return Debugger::DetailedErrorView::locationData(role, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,16 +112,18 @@ static QString appendYamlSuffix(const char *filePathFragment)
|
|||||||
|
|
||||||
TEST_F(ReadExportedDiagnostics, Tidy)
|
TEST_F(ReadExportedDiagnostics, Tidy)
|
||||||
{
|
{
|
||||||
const QString sourceFile = TESTDATA "tidy.modernize-use-nullptr.cpp";
|
const Utils::FilePath sourceFile = Utils::FilePath::fromString(
|
||||||
|
TESTDATA "tidy.modernize-use-nullptr.cpp");
|
||||||
const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "tidy.modernize-use-nullptr"),
|
const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "tidy.modernize-use-nullptr"),
|
||||||
sourceFile);
|
sourceFile.toString());
|
||||||
Diagnostic expectedDiag;
|
Diagnostic expectedDiag;
|
||||||
expectedDiag.name = "modernize-use-nullptr";
|
expectedDiag.name = "modernize-use-nullptr";
|
||||||
expectedDiag.location = {sourceFile, 2, 25};
|
expectedDiag.location = {sourceFile, 2, 25};
|
||||||
expectedDiag.description = "use nullptr [modernize-use-nullptr]";
|
expectedDiag.description = "use nullptr [modernize-use-nullptr]";
|
||||||
expectedDiag.type = "warning";
|
expectedDiag.type = "warning";
|
||||||
expectedDiag.hasFixits = true;
|
expectedDiag.hasFixits = true;
|
||||||
expectedDiag.explainingSteps = {ExplainingStep{"nullptr",
|
expectedDiag.explainingSteps = {
|
||||||
|
ExplainingStep{"nullptr",
|
||||||
expectedDiag.location,
|
expectedDiag.location,
|
||||||
{expectedDiag.location, {sourceFile, 2, 26}},
|
{expectedDiag.location, {sourceFile, 2, 26}},
|
||||||
true}};
|
true}};
|
||||||
@@ -151,9 +153,10 @@ TEST_F(ReadExportedDiagnostics, AcceptDiagsFromFilePaths_None)
|
|||||||
// Diagnostics from clang (static) analyzer passed through via clang-tidy
|
// Diagnostics from clang (static) analyzer passed through via clang-tidy
|
||||||
TEST_F(ReadExportedDiagnostics, Tidy_ClangAnalyzer)
|
TEST_F(ReadExportedDiagnostics, Tidy_ClangAnalyzer)
|
||||||
{
|
{
|
||||||
const QString sourceFile = TESTDATA "clang-analyzer.dividezero.cpp";
|
const Utils::FilePath sourceFile = Utils::FilePath::fromString(TESTDATA
|
||||||
|
"clang-analyzer.dividezero.cpp");
|
||||||
const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "clang-analyzer.dividezero"),
|
const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "clang-analyzer.dividezero"),
|
||||||
sourceFile);
|
sourceFile.toString());
|
||||||
Diagnostic expectedDiag;
|
Diagnostic expectedDiag;
|
||||||
expectedDiag.name = "clang-analyzer-core.DivideZero";
|
expectedDiag.name = "clang-analyzer-core.DivideZero";
|
||||||
expectedDiag.location = {sourceFile, 4, 15};
|
expectedDiag.location = {sourceFile, 4, 15};
|
||||||
@@ -188,8 +191,9 @@ TEST_F(ReadExportedDiagnostics, Tidy_ClangAnalyzer)
|
|||||||
|
|
||||||
TEST_F(ReadExportedDiagnostics, Clazy)
|
TEST_F(ReadExportedDiagnostics, Clazy)
|
||||||
{
|
{
|
||||||
const QString sourceFile = TESTDATA "clazy.qgetenv.cpp";
|
const Utils::FilePath sourceFile = Utils::FilePath::fromString(TESTDATA "clazy.qgetenv.cpp");
|
||||||
const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "clazy.qgetenv"), sourceFile);
|
const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "clazy.qgetenv"),
|
||||||
|
sourceFile.toString());
|
||||||
Diagnostic expectedDiag;
|
Diagnostic expectedDiag;
|
||||||
expectedDiag.name = "clazy-qgetenv";
|
expectedDiag.name = "clazy-qgetenv";
|
||||||
expectedDiag.location = {sourceFile, 7, 5};
|
expectedDiag.location = {sourceFile, 7, 5};
|
||||||
|
Reference in New Issue
Block a user