forked from qt-creator/qt-creator
ProjectExplorer: Add ProjectManager::projectsForFile
Change-Id: I4a91e2e3d5b94d27cc7cb0e772ec1dd45531dc0a Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -521,6 +521,13 @@ Project *ProjectManager::projectForFile(const FilePath &fileName)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Project *> ProjectManager::projectsForFile(const Utils::FilePath &fileName)
|
||||||
|
{
|
||||||
|
return Utils::filtered(ProjectManager::projects(), [&fileName](Project *p) {
|
||||||
|
return p->isKnownFile(fileName) || isInProjectSourceDir(fileName, *p);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bool ProjectManager::isInProjectSourceDir(const Utils::FilePath &filePath, const Project &project)
|
bool ProjectManager::isInProjectSourceDir(const Utils::FilePath &filePath, const Project &project)
|
||||||
{
|
{
|
||||||
for (const Target * const target : project.targets()) {
|
for (const Target * const target : project.targets()) {
|
||||||
|
@@ -80,6 +80,7 @@ public:
|
|||||||
static QList<Project *> projectOrder(const Project *project = nullptr);
|
static QList<Project *> projectOrder(const Project *project = nullptr);
|
||||||
|
|
||||||
static Project *projectForFile(const Utils::FilePath &fileName);
|
static Project *projectForFile(const Utils::FilePath &fileName);
|
||||||
|
static QList<Project *> projectsForFile(const Utils::FilePath &fileName);
|
||||||
static bool isInProjectSourceDir(const Utils::FilePath &filePath, const Project &project);
|
static bool isInProjectSourceDir(const Utils::FilePath &filePath, const Project &project);
|
||||||
static Project *projectWithProjectFilePath(const Utils::FilePath &filePath);
|
static Project *projectWithProjectFilePath(const Utils::FilePath &filePath);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user