Commit e1ed5e48 authored by Tobias Hunger's avatar Tobias Hunger

FileUtils: Replace FileNameList with an alias

The functionality in that class is covered by initializers and
Utils::unique, so there is no need to keep a custom class.

This way FileNameList plays way nicer with utils/algorithm.h.

Change-Id: I8eeae6aca0558ecd998920c4fdfc5ea56bf75501
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 1bb16ad6
......@@ -763,25 +763,6 @@ QTextStream &operator<<(QTextStream &s, const FileName &fn)
return s << fn.toString();
}
int FileNameList::removeDuplicates()
{
QSet<FileName> seen;
int removed = 0;
for (int i = 0; i < size(); ) {
const FileName &fn = at(i);
if (seen.contains(fn)) {
removeAt(i);
++removed;
} else {
seen.insert(fn);
++i;
}
}
return removed;
}
} // namespace Utils
QT_BEGIN_NAMESPACE
......
......@@ -105,16 +105,7 @@ private:
QTCREATOR_UTILS_EXPORT QTextStream &operator<<(QTextStream &s, const FileName &fn);
class QTCREATOR_UTILS_EXPORT FileNameList : public QList<FileName>
{
public:
inline FileNameList() { }
inline explicit FileNameList(const FileName &i) { append(i); }
inline FileNameList(const FileNameList &l) : QList<FileName>(l) { }
inline FileNameList(const QList<FileName> &l) : QList<FileName>(l) { }
int removeDuplicates();
};
using FileNameList = QList<FileName>;
class QTCREATOR_UTILS_EXPORT FileUtils {
public:
......
......@@ -40,6 +40,7 @@
#include <coreplugin/progressmanager/progressmanager.h>
#include <texteditor/basefilefind.h>
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <utils/runextensions.h>
#include <utils/textfileformat.h>
......@@ -280,7 +281,7 @@ static void find_helper(QFutureInterface<Usage> &future,
const Utils::FileName sourceFile = Utils::FileName::fromUtf8(symbol->fileName(),
symbol->fileNameLength());
Utils::FileNameList files(sourceFile);
Utils::FileNameList files {sourceFile};
if (symbol->isClass()
|| symbol->isForwardClassDeclaration()
......@@ -300,7 +301,7 @@ static void find_helper(QFutureInterface<Usage> &future,
} else {
files += snapshot.filesDependingOn(sourceFile);
}
files.removeDuplicates();
files = Utils::filteredUnique(files);
future.setProgressRange(0, files.size());
......@@ -617,9 +618,8 @@ static void findMacroUses_helper(QFutureInterface<Usage> &future,
const Macro macro)
{
const Utils::FileName sourceFile = Utils::FileName::fromString(macro.fileName());
Utils::FileNameList files(sourceFile);
files += snapshot.filesDependingOn(sourceFile);
files.removeDuplicates();
Utils::FileNameList files {sourceFile};
files = Utils::filteredUnique(files + snapshot.filesDependingOn(sourceFile));
future.setProgressRange(0, files.size());
FindMacroUsesInFile process(workingCopy, snapshot, macro, &future);
......
......@@ -39,6 +39,7 @@
#include <cplusplus/Overview.h>
#include <cplusplus/LookupContext.h>
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QDebug>
......@@ -290,11 +291,9 @@ bool skipFileDueToSizeLimit(const QFileInfo &fileInfo, int limitInMB)
Utils::FileNameList modifiedFiles()
{
Utils::FileNameList files;
foreach (Core::IDocument *doc, Core::DocumentManager::modifiedDocuments())
files.append(doc->filePath());
files.removeDuplicates();
return files;
Utils::FileNameList files = Utils::transform(Core::DocumentManager::modifiedDocuments(),
&Core::IDocument::filePath);
return Utils::filteredUnique(files);
}
} // CppTools
......@@ -37,6 +37,8 @@
#include <cplusplus/CppDocument.h>
#include <utils/fileutils.h>
QT_BEGIN_NAMESPACE
class QChar;
class QFileInfo;
......@@ -44,10 +46,6 @@ class QStringRef;
class QTextCursor;
QT_END_NAMESPACE
namespace Utils {
class FileNameList;
} // namespace Utils
namespace CPlusPlus {
class Macro;
class Symbol;
......
......@@ -2427,8 +2427,7 @@ FileNameList QmakeProFileNode::subDirsPaths(QtSupport::ProFileReader *reader,
}
}
subProjectPaths.removeDuplicates();
return subProjectPaths;
return Utils::filteredUnique(subProjectPaths);
}
TargetInformation QmakeProFileNode::targetInformation(QtSupport::ProFileReader *reader, QtSupport::ProFileReader *readerBuildPass, const QString &buildDir, const QString &projectFilePath)
......
......@@ -450,9 +450,8 @@ static void findSystemQt()
systemQMakes << systemQMakePath;
systemQMakes.append(gatherQmakePathsFromQtChooser());
systemQMakes.removeDuplicates();
foreach (const FileName &qmakePath, systemQMakes) {
foreach (const FileName &qmakePath, Utils::filteredUnique(systemQMakes)) {
BaseQtVersion *version
= QtVersionFactory::createQtVersionFromQMakePath(qmakePath, false, QLatin1String("PATH"));
if (version) {
......
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