forked from qt-creator/qt-creator
Project: Make Project::files return a FileNameList
Change-Id: I75ceb22ac65b8288d824f229d44089cba6fc8ea3 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
@@ -157,7 +158,8 @@ bool AndroidBuildApkStep::init(QList<const BuildStep *> &earlierSteps)
|
||||
}
|
||||
|
||||
JavaParser *parser = new JavaParser;
|
||||
parser->setProjectFileList(target()->project()->files(ProjectExplorer::Project::AllFiles));
|
||||
parser->setProjectFileList(Utils::transform(target()->project()->files(ProjectExplorer::Project::AllFiles),
|
||||
&Utils::FileName::toString));
|
||||
parser->setSourceDirectory(androidPackageSourceDir());
|
||||
parser->setBuildDirectory(Utils::FileName::fromString(bc->buildDirectory().appendPath(Constants::ANDROID_BUILDDIRECTORY).toString()));
|
||||
setOutputParser(parser);
|
||||
|
@@ -343,7 +343,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList, ITestParser *pars
|
||||
return;
|
||||
QStringList list;
|
||||
if (isFullParse) {
|
||||
list = project->files(Project::SourceFiles);
|
||||
list = Utils::transform(project->files(Project::SourceFiles), &Utils::FileName::toString);
|
||||
if (list.isEmpty()) {
|
||||
// at least project file should be there, but might happen if parsing current project
|
||||
// takes too long, especially when opening sessions holding multiple projects
|
||||
|
@@ -118,13 +118,13 @@ QString ArtisticStyle::configurationFile() const
|
||||
if (m_settings->useOtherFiles()) {
|
||||
if (const ProjectExplorer::Project *project
|
||||
= ProjectExplorer::ProjectTree::currentProject()) {
|
||||
const QStringList files = project->files(ProjectExplorer::Project::AllFiles);
|
||||
for (const QString &file : files) {
|
||||
const Utils::FileNameList files = project->files(ProjectExplorer::Project::AllFiles);
|
||||
for (const Utils::FileName &file : files) {
|
||||
if (!file.endsWith(".astylerc"))
|
||||
continue;
|
||||
const QFileInfo fi(file);
|
||||
const QFileInfo fi = file.toFileInfo();
|
||||
if (fi.isReadable())
|
||||
return file;
|
||||
return file.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -247,8 +247,7 @@ void BeautifierPlugin::autoFormatOnSave(Core::IDocument *document)
|
||||
// Check if file is contained in the current project (if wished)
|
||||
if (m_generalSettings->autoFormatOnlyCurrentProject()) {
|
||||
const ProjectExplorer::Project *pro = ProjectExplorer::ProjectTree::currentProject();
|
||||
if (!pro || !pro->files(ProjectExplorer::Project::SourceFiles).contains(
|
||||
document->filePath().toString())) {
|
||||
if (!pro || !pro->files(ProjectExplorer::Project::SourceFiles).contains(document->filePath())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -160,13 +160,13 @@ QString Uncrustify::configurationFile() const
|
||||
if (m_settings->useOtherFiles()) {
|
||||
if (const ProjectExplorer::Project *project
|
||||
= ProjectExplorer::ProjectTree::currentProject()) {
|
||||
const QStringList files = project->files(ProjectExplorer::Project::AllFiles);
|
||||
for (const QString &file : files) {
|
||||
const Utils::FileNameList files = project->files(ProjectExplorer::Project::AllFiles);
|
||||
for (const Utils::FileName &file : files) {
|
||||
if (!file.endsWith("cfg"))
|
||||
continue;
|
||||
const QFileInfo fi(file);
|
||||
const QFileInfo fi = file.toFileInfo();
|
||||
if (fi.isReadable() && fi.fileName() == "uncrustify.cfg")
|
||||
return file;
|
||||
return file.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -41,6 +41,8 @@
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QStandardItem>
|
||||
@@ -635,12 +637,12 @@ void Parser::resetData(const CPlusPlus::Snapshot &snapshot)
|
||||
d->docLocker.unlock();
|
||||
|
||||
// recalculate file list
|
||||
QStringList fileList;
|
||||
::Utils::FileNameList fileList;
|
||||
|
||||
// check all projects
|
||||
for (const Project *prj : SessionManager::projects())
|
||||
fileList += prj->files(Project::SourceFiles);
|
||||
setFileList(fileList);
|
||||
setFileList(::Utils::transform(fileList, &::Utils::FileName::toString));
|
||||
|
||||
emit resetDataDone();
|
||||
}
|
||||
@@ -722,7 +724,7 @@ QStringList Parser::addProjectTree(const ParserTreeItem::Ptr &item, const Projec
|
||||
if (cit != d->cachedPrjFileLists.constEnd()) {
|
||||
fileList = cit.value();
|
||||
} else {
|
||||
fileList = project->files(Project::SourceFiles);
|
||||
fileList = ::Utils::transform(project->files(Project::SourceFiles), &::Utils::FileName::toString);
|
||||
d->cachedPrjFileLists[projectPath] = fileList;
|
||||
}
|
||||
if (fileList.count() > 0) {
|
||||
@@ -747,7 +749,7 @@ QStringList Parser::getAllFiles(const Project *project)
|
||||
if (cit != d->cachedPrjFileLists.constEnd()) {
|
||||
fileList = cit.value();
|
||||
} else {
|
||||
fileList = project->files(Project::SourceFiles);
|
||||
fileList = ::Utils::transform(project->files(Project::SourceFiles), &::Utils::FileName::toString);
|
||||
d->cachedPrjFileLists[nodePath] = fileList;
|
||||
}
|
||||
return fileList;
|
||||
|
@@ -2044,7 +2044,7 @@ void ClearCasePlugin::updateIndex()
|
||||
return;
|
||||
m_checkInAllAction->setEnabled(false);
|
||||
m_statusMap->clear();
|
||||
QFuture<void> result = Utils::runAsync(sync, project->files(Project::SourceFiles));
|
||||
QFuture<void> result = Utils::runAsync(sync, transform(project->files(Project::SourceFiles), &FileName::toString));
|
||||
if (!m_settings.disableIndexer)
|
||||
ProgressManager::addTask(result, tr("Updating ClearCase Index"), ClearCase::Constants::TASK_INDEX);
|
||||
}
|
||||
|
@@ -728,28 +728,27 @@ void CMakeProject::createGeneratedCodeModelSupport()
|
||||
= Utils::transform<QSet>(factories, [](const ExtraCompilerFactory *f) { return f->sourceTag(); });
|
||||
|
||||
// Find all files generated by any of the extra compilers, in a rather crude way.
|
||||
const QStringList fileList = files(SourceFiles, [&fileExtensions](const Node *n) {
|
||||
const FileNameList fileList = files(SourceFiles, [&fileExtensions](const Node *n) {
|
||||
const QString fp = n->filePath().toString();
|
||||
const int pos = fp.lastIndexOf('.');
|
||||
return pos >= 0 && fileExtensions.contains(fp.mid(pos + 1));
|
||||
});
|
||||
|
||||
// Generate the necessary information:
|
||||
for (const QString &file : fileList) {
|
||||
for (const FileName &file : fileList) {
|
||||
ExtraCompilerFactory *factory = Utils::findOrDefault(factories, [&file](const ExtraCompilerFactory *f) {
|
||||
return file.endsWith('.' + f->sourceTag());
|
||||
});
|
||||
QTC_ASSERT(factory, continue);
|
||||
|
||||
QStringList generated = filesGeneratedFrom(file);
|
||||
QStringList generated = filesGeneratedFrom(file.toString());
|
||||
if (generated.isEmpty())
|
||||
continue;
|
||||
|
||||
const FileNameList fileNames
|
||||
= transform(generated,
|
||||
[](const QString &s) { return FileName::fromString(s); });
|
||||
m_extraCompilers.append(factory->create(this, FileName::fromString(file),
|
||||
fileNames));
|
||||
m_extraCompilers.append(factory->create(this, file, fileNames));
|
||||
}
|
||||
|
||||
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
|
||||
|
@@ -142,14 +142,14 @@ static QString findResourceInProject(const QString &resName)
|
||||
return QString();
|
||||
|
||||
if (auto *project = ProjectExplorer::ProjectTree::currentProject()) {
|
||||
const QStringList files = project->files(ProjectExplorer::Project::AllFiles);
|
||||
for (const QString &file : files) {
|
||||
const Utils::FileNameList files = project->files(ProjectExplorer::Project::AllFiles);
|
||||
for (const Utils::FileName &file : files) {
|
||||
if (!file.endsWith(".qrc"))
|
||||
continue;
|
||||
const QFileInfo fi(file);
|
||||
const QFileInfo fi = file.toFileInfo();
|
||||
if (!fi.isReadable())
|
||||
continue;
|
||||
const QString fileName = findResourceInFile(s, file);
|
||||
const QString fileName = findResourceInFile(s, file.toString());
|
||||
if (fileName.isEmpty())
|
||||
continue;
|
||||
|
||||
|
@@ -159,8 +159,8 @@ void CppIncludesFilter::prepareSearch(const QString &entry)
|
||||
m_needsUpdate = false;
|
||||
QSet<QString> seedPaths;
|
||||
for (Project *project : SessionManager::projects()) {
|
||||
foreach (const QString &filePath, project->files(Project::AllFiles))
|
||||
seedPaths.insert(filePath);
|
||||
foreach (const Utils::FileName &filePath, project->files(Project::AllFiles))
|
||||
seedPaths.insert(filePath.toString());
|
||||
}
|
||||
foreach (DocumentModel::Entry *entry, DocumentModel::entries()) {
|
||||
if (entry)
|
||||
|
@@ -57,6 +57,7 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/macroexpander.h>
|
||||
@@ -261,7 +262,8 @@ static QStringList findFilesInProject(const QString &name,
|
||||
|
||||
QString pattern = QString(1, QLatin1Char('/'));
|
||||
pattern += name;
|
||||
const QStringList projectFiles = project->files(ProjectExplorer::Project::AllFiles);
|
||||
const QStringList projectFiles
|
||||
= Utils::transform(project->files(ProjectExplorer::Project::AllFiles), &Utils::FileName::toString);
|
||||
const QStringList::const_iterator pcend = projectFiles.constEnd();
|
||||
QStringList candidateList;
|
||||
for (QStringList::const_iterator it = projectFiles.constBegin(); it != pcend; ++it) {
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/session.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/runextensions.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -128,7 +129,7 @@ void SymbolsFindFilter::startSearch(SearchResult *search)
|
||||
QSet<QString> projectFileNames;
|
||||
if (parameters.scope == SymbolSearcher::SearchProjectsOnly) {
|
||||
for (ProjectExplorer::Project *project : ProjectExplorer::SessionManager::projects())
|
||||
projectFileNames += project->files(ProjectExplorer::Project::AllFiles).toSet();
|
||||
projectFileNames += Utils::transform(project->files(ProjectExplorer::Project::AllFiles), &Utils::FileName::toString).toSet();
|
||||
}
|
||||
|
||||
QFutureWatcher<SearchResultItem> *watcher = new QFutureWatcher<SearchResultItem>();
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include <projectexplorer/taskhub.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/portlist.h>
|
||||
@@ -276,7 +277,7 @@ void DebuggerRunTool::setStartMode(DebuggerStartMode startMode)
|
||||
projects.insert(0, startupProject);
|
||||
}
|
||||
foreach (Project *project, projects)
|
||||
m_runParameters.projectSourceFiles.append(project->files(Project::SourceFiles));
|
||||
m_runParameters.projectSourceFiles.append(transform(project->files(Project::SourceFiles), &FileName::toString));
|
||||
if (!projects.isEmpty())
|
||||
m_runParameters.projectSourceDirectory = projects.first()->projectDirectory().toString();
|
||||
|
||||
@@ -849,7 +850,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer
|
||||
Project *project = runConfig ? runConfig->target()->project() : nullptr;
|
||||
if (project) {
|
||||
m_runParameters.projectSourceDirectory = project->projectDirectory().toString();
|
||||
m_runParameters.projectSourceFiles = project->files(Project::SourceFiles);
|
||||
m_runParameters.projectSourceFiles = transform(project->files(Project::SourceFiles), &FileName::toString);
|
||||
}
|
||||
|
||||
m_runParameters.toolChainAbi = ToolChainKitInformation::targetAbi(kit);
|
||||
|
@@ -87,8 +87,7 @@ void GenericProjectPlugin::editFiles()
|
||||
if (!genericProject)
|
||||
return;
|
||||
SelectableFilesDialogEditFiles sfd(genericProject->projectDirectory(),
|
||||
Utils::transform(genericProject->files(Project::AllFiles),
|
||||
[](const QString &f) { return Utils::FileName::fromString(f); }),
|
||||
genericProject->files(Project::AllFiles),
|
||||
ICore::mainWindow());
|
||||
if (sfd.exec() == QDialog::Accepted)
|
||||
genericProject->setFiles(Utils::transform(sfd.selectedFiles(), &Utils::FileName::toString));
|
||||
|
@@ -392,15 +392,15 @@ void ModelIndexer::scanProject(ProjectExplorer::Project *project)
|
||||
return;
|
||||
|
||||
// TODO harmonize following code with findFirstModel()?
|
||||
QStringList files = project->files(ProjectExplorer::Project::SourceFiles);
|
||||
const Utils::FileNameList files = project->files(ProjectExplorer::Project::SourceFiles);
|
||||
QQueue<QueuedFile> filesQueue;
|
||||
QSet<QueuedFile> filesSet;
|
||||
|
||||
foreach (const QString &file, files) {
|
||||
QFileInfo fileInfo(file);
|
||||
for (const Utils::FileName &file : files) {
|
||||
QFileInfo fileInfo = file.toFileInfo();
|
||||
Utils::MimeType mimeType = Utils::mimeTypeForFile(fileInfo);
|
||||
if (mimeType.name() == QLatin1String(Constants::MIME_TYPE_MODEL)) {
|
||||
QueuedFile queuedFile(file, project, fileInfo.lastModified());
|
||||
QueuedFile queuedFile(file.toString(), project, fileInfo.lastModified());
|
||||
filesQueue.append(queuedFile);
|
||||
filesSet.insert(queuedFile);
|
||||
}
|
||||
@@ -474,20 +474,21 @@ QString ModelIndexer::findFirstModel(ProjectExplorer::FolderNode *folderNode)
|
||||
|
||||
void ModelIndexer::forgetProject(ProjectExplorer::Project *project)
|
||||
{
|
||||
QStringList files = project->files(ProjectExplorer::Project::SourceFiles);
|
||||
const Utils::FileNameList files = project->files(ProjectExplorer::Project::SourceFiles);
|
||||
|
||||
QMutexLocker locker(&d->indexerMutex);
|
||||
foreach (const QString &file, files) {
|
||||
for (const Utils::FileName &file : files) {
|
||||
const QString fileString = file.toString();
|
||||
// remove file from queue
|
||||
QueuedFile queuedFile(file, project);
|
||||
QueuedFile queuedFile(fileString, project);
|
||||
if (d->queuedFilesSet.contains(queuedFile)) {
|
||||
QMT_CHECK(d->filesQueue.contains(queuedFile));
|
||||
d->filesQueue.removeOne(queuedFile);
|
||||
QMT_CHECK(!d->filesQueue.contains(queuedFile));
|
||||
d->queuedFilesSet.remove(queuedFile);
|
||||
}
|
||||
removeModelFile(file, project);
|
||||
removeDiagramReferenceFile(file, project);
|
||||
removeModelFile(fileString, project);
|
||||
removeDiagramReferenceFile(fileString, project);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -177,10 +177,7 @@ bool NimProject::supportsKit(Kit *k, QString *errorMessage) const
|
||||
|
||||
FileNameList NimProject::nimFiles() const
|
||||
{
|
||||
const QStringList nim = files(AllFiles, [](const ProjectExplorer::Node *n) {
|
||||
return n->filePath().endsWith(".nim");
|
||||
});
|
||||
return Utils::transform(nim, [](const QString &fp) { return Utils::FileName::fromString(fp); });
|
||||
return files(AllFiles, [](const ProjectExplorer::Node *n) { return n->filePath().endsWith(".nim"); });
|
||||
}
|
||||
|
||||
QVariantMap NimProject::toMap() const
|
||||
|
@@ -379,8 +379,8 @@ void AbstractProcessStep::taskAdded(const Task &task, int linkedOutputLines, int
|
||||
|
||||
QList<QFileInfo> possibleFiles;
|
||||
QString fileName = Utils::FileName::fromString(filePath).fileName();
|
||||
foreach (const QString &file, project()->files(Project::AllFiles)) {
|
||||
QFileInfo candidate(file);
|
||||
foreach (const Utils::FileName &file, project()->files(Project::AllFiles)) {
|
||||
QFileInfo candidate = file.toFileInfo();
|
||||
if (candidate.fileName() == fileName)
|
||||
possibleFiles << candidate;
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ void AllProjectsFilter::prepareSearch(const QString &entry)
|
||||
if (!fileIterator()) {
|
||||
QStringList paths;
|
||||
for (Project *project : SessionManager::projects())
|
||||
paths.append(project->files(Project::AllFiles));
|
||||
paths.append(Utils::transform(project->files(Project::AllFiles), &Utils::FileName::toString));
|
||||
Utils::sort(paths);
|
||||
setFileIterator(new BaseFileFilter::ListIterator(paths));
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@ Utils::FileIterator *AllProjectsFind::filesForProjects(const QStringList &nameFi
|
||||
QTextCodec *projectCodec = config->useGlobalSettings()
|
||||
? Core::EditorManager::defaultTextCodec()
|
||||
: config->textCodec();
|
||||
const QStringList filteredFiles = filterFiles(project->files(Project::AllFiles));
|
||||
const QStringList filteredFiles = filterFiles(Utils::transform(project->files(Project::AllFiles), &Utils::FileName::toString));
|
||||
for (const QString &fileName : filteredFiles) {
|
||||
QTextCodec *codec = openEditorEncodings.value(fileName);
|
||||
if (!codec)
|
||||
|
@@ -58,7 +58,7 @@ void CurrentProjectFilter::prepareSearch(const QString &entry)
|
||||
if (!fileIterator()) {
|
||||
QStringList paths;
|
||||
if (m_project) {
|
||||
paths = m_project->files(Project::AllFiles);
|
||||
paths = Utils::transform(m_project->files(Project::AllFiles), &Utils::FileName::toString);
|
||||
Utils::sort(paths);
|
||||
}
|
||||
setFileIterator(new BaseFileFilter::ListIterator(paths));
|
||||
|
@@ -557,17 +557,17 @@ Project::RestoreResult Project::restoreSettings(QString *errorMessage)
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList Project::files(Project::FilesMode fileMode,
|
||||
Utils::FileNameList Project::files(Project::FilesMode fileMode,
|
||||
const std::function<bool(const Node *)> &filter) const
|
||||
{
|
||||
QStringList result;
|
||||
Utils::FileNameList result;
|
||||
|
||||
if (!rootProjectNode())
|
||||
return result;
|
||||
|
||||
QSet<QString> alreadySeen;
|
||||
QSet<Utils::FileName> alreadySeen;
|
||||
rootProjectNode()->forEachGenericNode([&](const Node *n) {
|
||||
const QString path = n->filePath().toString();
|
||||
const Utils::FileName path = n->filePath();
|
||||
const int count = alreadySeen.count();
|
||||
alreadySeen.insert(path);
|
||||
if (count == alreadySeen.count())
|
||||
|
@@ -135,8 +135,8 @@ public:
|
||||
GeneratedFiles = 0x2,
|
||||
AllFiles = SourceFiles | GeneratedFiles
|
||||
};
|
||||
QStringList files(FilesMode fileMode,
|
||||
const std::function<bool(const Node *)> &filter = {}) const;
|
||||
Utils::FileNameList files(FilesMode fileMode,
|
||||
const std::function<bool(const Node *)> &filter = {}) const;
|
||||
virtual QStringList filesGeneratedFrom(const QString &sourceFile) const;
|
||||
|
||||
static QString makeUnique(const QString &preferredName, const QStringList &usedNames);
|
||||
|
@@ -690,7 +690,7 @@ Project *SessionManager::projectForFile(const Utils::FileName &fileName)
|
||||
bool SessionManager::projectContainsFile(Project *p, const Utils::FileName &fileName)
|
||||
{
|
||||
if (!d->m_projectFileCache.contains(p))
|
||||
d->m_projectFileCache.insert(p, p->files(Project::AllFiles));
|
||||
d->m_projectFileCache.insert(p, Utils::transform(p->files(Project::AllFiles), &Utils::FileName::toString));
|
||||
|
||||
return d->m_projectFileCache.value(p).contains(fileName.toString());
|
||||
}
|
||||
|
@@ -283,7 +283,7 @@ public:
|
||||
Q_UNUSED(mode);
|
||||
//return { Core::Id(PythonExecutableId) };
|
||||
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
||||
return project->files(ProjectExplorer::Project::AllFiles);
|
||||
return Utils::transform(project->files(ProjectExplorer::Project::AllFiles), &Utils::FileName::toString);
|
||||
}
|
||||
|
||||
bool canCreateHelper(Target *parent, const QString &buildTarget) const override
|
||||
@@ -292,7 +292,7 @@ public:
|
||||
const QString script = buildTarget;
|
||||
if (script.endsWith(".pyqtc"))
|
||||
return false;
|
||||
return project->files(ProjectExplorer::Project::AllFiles).contains(script);
|
||||
return project->files(ProjectExplorer::Project::AllFiles).contains(FileName::fromString(script));
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -849,7 +849,7 @@ static void notifyChangedHelper(const FileName &fileName, QmakeProFile *file)
|
||||
void QmakeProject::notifyChanged(const FileName &name)
|
||||
{
|
||||
for (QmakeProject *project : s_projects) {
|
||||
if (project->files(QmakeProject::SourceFiles).contains(name.toString()))
|
||||
if (project->files(QmakeProject::SourceFiles).contains(name))
|
||||
notifyChangedHelper(name, project->rootProFile());
|
||||
}
|
||||
}
|
||||
|
@@ -38,9 +38,9 @@ static QString styleConfigFileName(const QString &qmlFileName)
|
||||
ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(Utils::FileName::fromString(qmlFileName));
|
||||
|
||||
if (currentProject)
|
||||
foreach (const QString &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles))
|
||||
foreach (const Utils::FileName &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles))
|
||||
if (fileName.endsWith("qtquickcontrols2.conf"))
|
||||
return fileName;
|
||||
return fileName.toString();
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
@@ -288,9 +288,9 @@ void DesignDocument::updateQrcFiles()
|
||||
ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(fileName());
|
||||
|
||||
if (currentProject) {
|
||||
foreach (const QString &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles)) {
|
||||
for (const Utils::FileName &fileName : currentProject->files(ProjectExplorer::Project::SourceFiles)) {
|
||||
if (fileName.endsWith(".qrc"))
|
||||
QmlJS::ModelManagerInterface::instance()->updateQrcFile(fileName);
|
||||
QmlJS::ModelManagerInterface::instance()->updateQrcFile(fileName.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -150,10 +150,9 @@ QString PuppetCreator::getStyleConfigFileName() const
|
||||
{
|
||||
#ifndef QMLDESIGNER_TEST
|
||||
if (m_currentProject) {
|
||||
for (const QString &fileName : m_currentProject->files(ProjectExplorer::Project::SourceFiles)) {
|
||||
QFileInfo fileInfo(fileName);
|
||||
if (fileInfo.fileName() == "qtquickcontrols2.conf")
|
||||
return fileName;
|
||||
for (const Utils::FileName &fileName : m_currentProject->files(ProjectExplorer::Project::SourceFiles)) {
|
||||
if (fileName.fileName() == "qtquickcontrols2.conf")
|
||||
return fileName.toString();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -213,9 +213,9 @@ static QStringList allUiQmlFilesforCurrentProject(const Utils::FileName &fileNam
|
||||
ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(fileName);
|
||||
|
||||
if (currentProject) {
|
||||
foreach (const QString &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles)) {
|
||||
foreach (const Utils::FileName &fileName, currentProject->files(ProjectExplorer::Project::SourceFiles)) {
|
||||
if (fileName.endsWith(".ui.qml"))
|
||||
list.append(fileName);
|
||||
list.append(fileName.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -349,10 +349,8 @@ void QmlJSEditorPlugin::autoFormatOnSave(Core::IDocument *document)
|
||||
// Check if file is contained in the current project (if wished)
|
||||
if (QmlJsEditingSettings::get().autoFormatOnlyCurrentProject()) {
|
||||
const ProjectExplorer::Project *pro = ProjectExplorer::ProjectTree::currentProject();
|
||||
if (!pro || !pro->files(ProjectExplorer::Project::SourceFiles).contains(
|
||||
document->filePath().toString())) {
|
||||
if (!pro || !pro->files(ProjectExplorer::Project::SourceFiles).contains(document->filePath()))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
reformatFile();
|
||||
|
@@ -49,6 +49,8 @@
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
|
||||
@@ -84,15 +86,15 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
|
||||
Constants::QMLPROJECT_MIMETYPE,
|
||||
Constants::QMLTYPES_MIMETYPE,
|
||||
Constants::QMLUI_MIMETYPE };
|
||||
projectInfo.sourceFiles = project->files(Project::SourceFiles,
|
||||
[&qmlTypeNames](const Node *n) {
|
||||
projectInfo.sourceFiles = Utils::transform(project->files(Project::SourceFiles,
|
||||
[&qmlTypeNames](const Node *n) {
|
||||
if (const FileNode *fn = n->asFileNode()) {
|
||||
return fn->fileType() == FileType::QML
|
||||
&& qmlTypeNames.contains(Utils::mimeTypeForFile(fn->filePath().toString(),
|
||||
MimeMatchMode::MatchExtension).name());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}), &FileName::toString);
|
||||
activeTarget = project->activeTarget();
|
||||
}
|
||||
Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit();
|
||||
|
@@ -261,15 +261,15 @@ void QmlProjectRunConfiguration::updateEnabledState()
|
||||
|| mainScriptMimeType.matchesName(QLatin1String(QmlJSTools::Constants::QMLPROJECT_MIMETYPE))) {
|
||||
// find a qml file with lowercase filename. This is slow, but only done
|
||||
// in initialization/other border cases.
|
||||
foreach (const QString &filename, target()->project()->files(Project::AllFiles)) {
|
||||
const QFileInfo fi(filename);
|
||||
foreach (const Utils::FileName &filename, target()->project()->files(Project::AllFiles)) {
|
||||
const QFileInfo fi = filename.toFileInfo();
|
||||
|
||||
if (!filename.isEmpty() && fi.baseName()[0].isLower()) {
|
||||
Utils::MimeType type = Utils::mimeTypeForFile(fi);
|
||||
if (type.matchesName(QLatin1String(ProjectExplorer::Constants::QML_MIMETYPE))
|
||||
|| type.matchesName(
|
||||
QLatin1String(ProjectExplorer::Constants::QMLUI_MIMETYPE))) {
|
||||
m_currentFileFilename = filename;
|
||||
m_currentFileFilename = filename.toString();
|
||||
qmlFileFound = true;
|
||||
break;
|
||||
}
|
||||
|
@@ -30,6 +30,8 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/detailswidget.h>
|
||||
|
||||
#include <QLineEdit>
|
||||
@@ -38,7 +40,6 @@
|
||||
#include <QLabel>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using Core::ICore;
|
||||
using ProjectExplorer::ProjectExplorerPlugin;
|
||||
@@ -114,7 +115,8 @@ void QmlProjectRunConfigurationWidget::updateFileComboBox()
|
||||
m_fileListModel->appendRow(new QStandardItem(QLatin1String(CURRENT_FILE)));
|
||||
QModelIndex currentIndex;
|
||||
|
||||
QStringList sortedFiles = project->files(ProjectExplorer::Project::AllFiles);
|
||||
QStringList sortedFiles = Utils::transform(project->files(ProjectExplorer::Project::AllFiles),
|
||||
&Utils::FileName::toString);
|
||||
|
||||
// make paths relative to project directory
|
||||
QStringList relativeFiles;
|
||||
|
@@ -1348,13 +1348,15 @@ void BaseQtVersion::populateQmlFileFinder(FileInProjectFinder *finder, const Tar
|
||||
// Sort files from startupProject to the front of the list ...
|
||||
if (startupProject) {
|
||||
projectDirectory = startupProject->projectDirectory().toString();
|
||||
sourceFiles.append(startupProject->files(ProjectExplorer::Project::SourceFiles));
|
||||
sourceFiles.append(Utils::transform(startupProject->files(ProjectExplorer::Project::SourceFiles),
|
||||
&Utils::FileName::toString));
|
||||
}
|
||||
|
||||
// ... then add all the other projects' files.
|
||||
for (const ProjectExplorer::Project *project : projects) {
|
||||
if (project != startupProject)
|
||||
sourceFiles.append(project->files(ProjectExplorer::Project::SourceFiles));
|
||||
sourceFiles.append(Utils::transform(project->files(ProjectExplorer::Project::SourceFiles),
|
||||
&Utils::FileName::toString));
|
||||
}
|
||||
|
||||
// If no target was given, but we've found a startupProject, then try to deduce a
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/ansiescapecodehandler.h>
|
||||
#include <utils/fileinprojectfinder.h>
|
||||
#include <utils/theme/theme.h>
|
||||
@@ -85,7 +87,7 @@ QtOutputFormatter::QtOutputFormatter(Project *project)
|
||||
: d(new Internal::QtOutputFormatterPrivate(project))
|
||||
{
|
||||
if (project) {
|
||||
d->projectFinder.setProjectFiles(project->files(Project::SourceFiles));
|
||||
d->projectFinder.setProjectFiles(Utils::transform(project->files(Project::SourceFiles), &Utils::FileName::toString));
|
||||
d->projectFinder.setProjectDirectory(project->projectDirectory().toString());
|
||||
|
||||
connect(project, &Project::fileListChanged,
|
||||
@@ -279,7 +281,7 @@ void QtOutputFormatter::openEditor(const QString &fileName, int line, int column
|
||||
void QtOutputFormatter::updateProjectFileList()
|
||||
{
|
||||
if (d->project)
|
||||
d->projectFinder.setProjectFiles(d->project.data()->files(Project::SourceFiles));
|
||||
d->projectFinder.setProjectFiles(transform(d->project->files(Project::SourceFiles), &FileName::toString));
|
||||
}
|
||||
|
||||
} // namespace QtSupport
|
||||
|
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <cplusplus/TranslationUnit.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <cctype>
|
||||
|
||||
namespace Todo {
|
||||
@@ -57,7 +59,8 @@ void CppTodoItemsScanner::scannerParamsChanged()
|
||||
|
||||
QSet<QString> filesToBeUpdated;
|
||||
foreach (const CppTools::ProjectInfo &info, modelManager->projectInfos())
|
||||
filesToBeUpdated.unite(info.project().data()->files(ProjectExplorer::Project::SourceFiles).toSet());
|
||||
filesToBeUpdated.unite(Utils::transform(info.project().data()->files(ProjectExplorer::Project::SourceFiles),
|
||||
&Utils::FileName::toString).toSet());
|
||||
|
||||
modelManager->updateSourceFiles(filesToBeUpdated);
|
||||
}
|
||||
|
@@ -39,6 +39,8 @@
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/session.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QTimer>
|
||||
|
||||
@@ -120,7 +122,9 @@ void TodoItemsProvider::createScanners()
|
||||
void TodoItemsProvider::setItemsListWithinStartupProject()
|
||||
{
|
||||
QHashIterator<QString, QList<TodoItem> > it(m_itemsHash);
|
||||
QSet<QString> fileNames = QSet<QString>::fromList(m_startupProject->files(Project::SourceFiles));
|
||||
const QSet<QString> fileNames
|
||||
= QSet<QString>::fromList(Utils::transform(m_startupProject->files(Project::SourceFiles),
|
||||
&Utils::FileName::toString));
|
||||
|
||||
QVariantMap settings = m_startupProject->namedSettings(Constants::SETTINGS_NAME_KEY).toMap();
|
||||
|
||||
@@ -156,8 +160,9 @@ void TodoItemsProvider::setItemsListWithinSubproject()
|
||||
});
|
||||
|
||||
// files must be both in the current subproject and the startup-project.
|
||||
QSet<QString> fileNames = QSet<QString>::fromList(
|
||||
m_startupProject->files(ProjectExplorer::Project::SourceFiles));
|
||||
const QSet<QString> fileNames
|
||||
= QSet<QString>::fromList(Utils::transform(m_startupProject->files(Project::SourceFiles),
|
||||
&Utils::FileName::toString));
|
||||
QHashIterator<QString, QList<TodoItem> > it(m_itemsHash);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
|
@@ -714,7 +714,8 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
|
||||
|
||||
RunWorker *MemcheckTool::createRunWorker(RunControl *runControl)
|
||||
{
|
||||
m_errorModel.setRelevantFrameFinder(makeFrameFinder(runControl->project()->files(Project::AllFiles)));
|
||||
m_errorModel.setRelevantFrameFinder(makeFrameFinder(transform(runControl->project()->files(Project::AllFiles),
|
||||
&FileName::toString)));
|
||||
|
||||
auto runTool = new MemcheckToolRunner(runControl, runControl->runMode() == MEMCHECK_WITH_GDB_RUN_MODE);
|
||||
|
||||
|
Reference in New Issue
Block a user