forked from qt-creator/qt-creator
Project: Avoid copying the entire files(...) list
Avoid copying the entire list of files known to a project just to filter out a couple of files from it. Change-Id: I58b2e323f9678058ba482353eb777a55189fe05d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -41,8 +41,9 @@
|
|||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
#include <cppeditor/cppeditorconstants.h>
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
#include <projectexplorer/projecttree.h>
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectnodes.h>
|
||||||
|
#include <projectexplorer/projecttree.h>
|
||||||
#include <texteditor/formattexteditor.h>
|
#include <texteditor/formattexteditor.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
@@ -103,10 +104,9 @@ QString ArtisticStyle::configurationFile() const
|
|||||||
if (m_settings.useOtherFiles()) {
|
if (m_settings.useOtherFiles()) {
|
||||||
if (const ProjectExplorer::Project *project
|
if (const ProjectExplorer::Project *project
|
||||||
= ProjectExplorer::ProjectTree::currentProject()) {
|
= ProjectExplorer::ProjectTree::currentProject()) {
|
||||||
const Utils::FilePathList files = project->files(ProjectExplorer::Project::AllFiles);
|
const Utils::FilePathList astyleRcfiles = project->files(
|
||||||
for (const Utils::FilePath &file : files) {
|
[](const ProjectExplorer::Node *n) { return n->filePath().endsWith(".astylerc"); });
|
||||||
if (!file.endsWith(".astylerc"))
|
for (const Utils::FilePath &file : astyleRcfiles) {
|
||||||
continue;
|
|
||||||
const QFileInfo fi = file.toFileInfo();
|
const QFileInfo fi = file.toFileInfo();
|
||||||
if (fi.isReadable())
|
if (fi.isReadable())
|
||||||
return file.toString();
|
return file.toString();
|
||||||
|
@@ -161,7 +161,7 @@ void BeautifierPluginPrivate::autoFormatOnSave(Core::IDocument *document)
|
|||||||
// Check if file is contained in the current project (if wished)
|
// Check if file is contained in the current project (if wished)
|
||||||
if (m_generalSettings->autoFormatOnlyCurrentProject()) {
|
if (m_generalSettings->autoFormatOnlyCurrentProject()) {
|
||||||
const ProjectExplorer::Project *pro = ProjectExplorer::ProjectTree::currentProject();
|
const ProjectExplorer::Project *pro = ProjectExplorer::ProjectTree::currentProject();
|
||||||
if (!pro || !pro->files(ProjectExplorer::Project::SourceFiles).contains(document->filePath())) {
|
if (!pro || !pro->isKnownFile(document->filePath())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,8 +41,9 @@
|
|||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
#include <cppeditor/cppeditorconstants.h>
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
#include <projectexplorer/projecttree.h>
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectnodes.h>
|
||||||
|
#include <projectexplorer/projecttree.h>
|
||||||
#include <texteditor/formattexteditor.h>
|
#include <texteditor/formattexteditor.h>
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
@@ -144,10 +145,9 @@ QString Uncrustify::configurationFile() const
|
|||||||
if (m_settings.useOtherFiles()) {
|
if (m_settings.useOtherFiles()) {
|
||||||
if (const ProjectExplorer::Project *project
|
if (const ProjectExplorer::Project *project
|
||||||
= ProjectExplorer::ProjectTree::currentProject()) {
|
= ProjectExplorer::ProjectTree::currentProject()) {
|
||||||
const Utils::FilePathList files = project->files(ProjectExplorer::Project::AllFiles);
|
const Utils::FilePathList files = project->files(
|
||||||
|
[](const ProjectExplorer::Node *n) { return n->filePath().endsWith("cfg"); });
|
||||||
for (const Utils::FilePath &file : files) {
|
for (const Utils::FilePath &file : files) {
|
||||||
if (!file.endsWith("cfg"))
|
|
||||||
continue;
|
|
||||||
const QFileInfo fi = file.toFileInfo();
|
const QFileInfo fi = file.toFileInfo();
|
||||||
if (fi.isReadable() && fi.fileName() == "uncrustify.cfg")
|
if (fi.isReadable() && fi.fileName() == "uncrustify.cfg")
|
||||||
return file.toString();
|
return file.toString();
|
||||||
|
@@ -634,9 +634,12 @@ QStringList CMakeProject::filesGeneratedFrom(const QString &sourceFile) const
|
|||||||
|
|
||||||
ProjectExplorer::DeploymentKnowledge CMakeProject::deploymentKnowledge() const
|
ProjectExplorer::DeploymentKnowledge CMakeProject::deploymentKnowledge() const
|
||||||
{
|
{
|
||||||
return contains(files(AllFiles), [](const FilePath &f) {
|
return !files([](const ProjectExplorer::Node *n) {
|
||||||
return f.fileName() == "QtCreatorDeployment.txt";
|
return n->filePath().fileName() == "QtCreatorDeployment.txt";
|
||||||
}) ? DeploymentKnowledge::Approximative : DeploymentKnowledge::Bad;
|
})
|
||||||
|
.isEmpty()
|
||||||
|
? DeploymentKnowledge::Approximative
|
||||||
|
: DeploymentKnowledge::Bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target,
|
MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target,
|
||||||
|
@@ -26,14 +26,15 @@
|
|||||||
#include "resourcepreviewhoverhandler.h"
|
#include "resourcepreviewhoverhandler.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/tooltip/tooltip.h>
|
|
||||||
#include <utils/fileutils.h>
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
#include <utils/mimetypes/mimedatabase.h>
|
|
||||||
#include <projectexplorer/projecttree.h>
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectnodes.h>
|
||||||
|
#include <projectexplorer/projecttree.h>
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
#include <utils/executeondestruction.h>
|
#include <utils/executeondestruction.h>
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
#include <utils/mimetypes/mimedatabase.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/tooltip/tooltip.h>
|
||||||
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
@@ -143,10 +144,9 @@ static QString findResourceInProject(const QString &resName)
|
|||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
if (auto *project = ProjectExplorer::ProjectTree::currentProject()) {
|
if (auto *project = ProjectExplorer::ProjectTree::currentProject()) {
|
||||||
const Utils::FilePathList files = project->files(ProjectExplorer::Project::AllFiles);
|
const Utils::FilePathList files = project->files(
|
||||||
|
[](const ProjectExplorer::Node *n) { return n->filePath().endsWith(".qrc"); });
|
||||||
for (const Utils::FilePath &file : files) {
|
for (const Utils::FilePath &file : files) {
|
||||||
if (!file.endsWith(".qrc"))
|
|
||||||
continue;
|
|
||||||
const QFileInfo fi = file.toFileInfo();
|
const QFileInfo fi = file.toFileInfo();
|
||||||
if (!fi.isReadable())
|
if (!fi.isReadable())
|
||||||
continue;
|
continue;
|
||||||
|
@@ -764,7 +764,11 @@ static void notifyChangedHelper(const FilePath &fileName, QmakeProFile *file)
|
|||||||
void QmakeProject::notifyChanged(const FilePath &name)
|
void QmakeProject::notifyChanged(const FilePath &name)
|
||||||
{
|
{
|
||||||
for (QmakeProject *project : s_projects) {
|
for (QmakeProject *project : s_projects) {
|
||||||
if (project->files(QmakeProject::SourceFiles).contains(name))
|
if (!project
|
||||||
|
->files([&name](const ProjectExplorer::Node *n) {
|
||||||
|
return Project::SourceFiles(n) && n->filePath() == name;
|
||||||
|
})
|
||||||
|
.isEmpty())
|
||||||
notifyChangedHelper(name, project->rootProFile());
|
notifyChangedHelper(name, project->rootProFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user