Commit d2bd092b authored by Friedemann Kleint's avatar Friedemann Kleint

Code model: Fix Windows issues (duplicate matches).

Ensure the code model receives file names with clean paths ('/')
and fix paths in the relevant places of the code model. Pass on clean
paths from Cpp reference find and display them correctly in the search
window tooltip.
Reviewed-by: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent 6320b06b
......@@ -42,6 +42,7 @@
#include <QtCore/QByteArray>
#include <QtCore/QBitArray>
#include <QtCore/QDir>
#include <QtCore/QtDebug>
/*!
......@@ -108,7 +109,7 @@ private:
Document::Document(const QString &fileName)
: _fileName(fileName),
: _fileName(QDir::cleanPath(fileName)),
_globalNamespace(0),
_revision(0)
{
......@@ -173,7 +174,7 @@ QStringList Document::includedFiles() const
void Document::addIncludeFile(const QString &fileName, unsigned line)
{
_includes.append(Include(fileName, line));
_includes.append(Include(QDir::cleanPath(fileName), line));
}
void Document::appendMacro(const Macro &macro)
......@@ -569,3 +570,8 @@ QStringList Snapshot::dependsOn(const QString &fileName) const
return deps;
}
Document::Ptr Snapshot::value(const QString &fileName) const
{
return QMap<QString, Document::Ptr>::value(QDir::cleanPath(fileName));
}
......@@ -341,6 +341,7 @@ public:
QStringList dependsOn(const QString &fileName) const;
void insert(Document::Ptr doc);
Document::Ptr value(const QString &fileName) const;
using _Base::insert;
......
......@@ -121,8 +121,7 @@ void FindUsages::reportResult(unsigned tokenIndex)
const int len = tk.f.length;
if (_future) {
const QString path = QDir::toNativeSeparators(_doc->fileName());
_future->reportResult(Usage(path, line, lineText, col, len));
_future->reportResult(Usage(_doc->fileName(), line, lineText, col, len));
}
_references.append(tokenIndex);
......
......@@ -110,7 +110,6 @@ static void find_helper(QFutureInterface<Usage> &future,
Q_ASSERT(symbolId != 0);
const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
QStringList files(sourceFile);
if (symbol->isClass() || symbol->isForwardClassDeclaration()) {
......@@ -126,9 +125,7 @@ static void find_helper(QFutureInterface<Usage> &future,
} else {
files += snapshot.dependsOn(sourceFile);
}
files.removeDuplicates();
//qDebug() << "done in:" << tm.elapsed() << "number of files to parse:" << files.size();
future.setProgressRange(0, files.size());
......@@ -232,7 +229,6 @@ void CppFindReferences::findAll_helper(Symbol *symbol)
const QMap<QString, QString> wl = _modelManager->workingCopy();
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
QFuture<Usage> result = QtConcurrent::run(&find_helper, wl, snapshot, symbol);
m_watcher.setFuture(result);
......
......@@ -532,7 +532,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
return;
QString contents = tryIncludeFile(fileName, type);
fileName = QDir::cleanPath(fileName);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(fileName, line);
......
......@@ -243,7 +243,7 @@ QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) con
break;
case ItemDataRoles::FileNameRole:
case Qt::ToolTipRole:
result = file->fileName();
result = QDir::toNativeSeparators(file->fileName());
break;
case ItemDataRoles::ResultLinesCountRole:
result = file->childrenCount();
......@@ -270,6 +270,10 @@ QVariant SearchResultTreeModel::headerData(int section, Qt::Orientation orientat
void SearchResultTreeModel::appendResultFile(const QString &fileName)
{
#ifdef Q_OS_WIN
if (fileName.contains(QLatin1Char('\\')))
qWarning("SearchResultTreeModel::appendResultFile: File name with native separators added %s.\n", qPrintable(fileName));
#endif
m_lastAppendedResultFile = new SearchResultFile(fileName, m_rootItem);
if (m_showReplaceUI) {
......
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