forked from qt-creator/qt-creator
Project: Remove Project::document() method
The document is used to do file watching, which may or may not be ideal. So make sure we do not leak the information how we watch files into the API and its users. The method is not used sensibly anywhere in creator, so it seems safe to remove it entirely. Change-Id: Ieed755bd5c852875378e4e96665dc906499975b0 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -285,9 +285,7 @@ ParserTreeItem::ConstPtr Parser::parse()
|
||||
for (const Project *prj : SessionManager::projects()) {
|
||||
ParserTreeItem::Ptr item;
|
||||
QString prjName(prj->displayName());
|
||||
QString prjType(prjName);
|
||||
if (prj->document())
|
||||
prjType = prj->projectFilePath().toString();
|
||||
QString prjType = prj->projectFilePath().toString();
|
||||
SymbolInformation inf(prjName, prjType);
|
||||
item = ParserTreeItem::Ptr(new ParserTreeItem());
|
||||
|
||||
|
@@ -72,7 +72,7 @@ bool CurrentProjectFind::isEnabled() const
|
||||
QVariant CurrentProjectFind::additionalParameters() const
|
||||
{
|
||||
Project *project = ProjectTree::currentProject();
|
||||
if (project && project->document())
|
||||
if (project)
|
||||
return QVariant::fromValue(project->projectFilePath().toString());
|
||||
return QVariant();
|
||||
}
|
||||
@@ -85,7 +85,7 @@ Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters,
|
||||
return new Utils::FileListIterator(QStringList(), QList<QTextCodec *>()));
|
||||
QString projectFile = additionalParameters.toString();
|
||||
for (Project *project : SessionManager::projects()) {
|
||||
if (project->document() && projectFile == project->projectFilePath().toString())
|
||||
if (project && projectFile == project->projectFilePath().toString())
|
||||
return filesForProjects(nameFilters, exclusionFilters, {project});
|
||||
}
|
||||
return new Utils::FileListIterator(QStringList(), QList<QTextCodec *>());
|
||||
|
@@ -243,7 +243,7 @@ Core::Id Project::id() const
|
||||
|
||||
QString Project::mimeType() const
|
||||
{
|
||||
return document()->mimeType();
|
||||
return d->m_document->mimeType();
|
||||
}
|
||||
|
||||
bool Project::canBuildProducts() const
|
||||
@@ -251,16 +251,10 @@ bool Project::canBuildProducts() const
|
||||
return d->m_canBuildProducts;
|
||||
}
|
||||
|
||||
Core::IDocument *Project::document() const
|
||||
{
|
||||
QTC_CHECK(d->m_document);
|
||||
return d->m_document.get();
|
||||
}
|
||||
|
||||
Utils::FilePath Project::projectFilePath() const
|
||||
{
|
||||
QTC_ASSERT(document(), return Utils::FilePath());
|
||||
return document()->filePath();
|
||||
QTC_ASSERT(d->m_document, return Utils::FilePath());
|
||||
return d->m_document->filePath();
|
||||
}
|
||||
|
||||
void Project::addTarget(std::unique_ptr<Target> &&t)
|
||||
@@ -1074,10 +1068,6 @@ void ProjectExplorerPlugin::testProject_setup()
|
||||
|
||||
QVERIFY(project.macroExpander());
|
||||
|
||||
QVERIFY(project.document());
|
||||
QCOMPARE(project.document()->filePath(), TEST_PROJECT_PATH);
|
||||
QCOMPARE(project.document()->mimeType(), TEST_PROJECT_MIMETYPE);
|
||||
|
||||
QCOMPARE(project.mimeType(), TEST_PROJECT_MIMETYPE);
|
||||
QCOMPARE(project.projectFilePath(), TEST_PROJECT_PATH);
|
||||
QCOMPARE(project.projectDirectory(), TEST_PROJECT_PATH.parentDir());
|
||||
|
@@ -85,7 +85,6 @@ public:
|
||||
QString mimeType() const;
|
||||
bool canBuildProducts() const;
|
||||
|
||||
Core::IDocument *document() const;
|
||||
Utils::FilePath projectFilePath() const;
|
||||
Utils::FilePath projectDirectory() const;
|
||||
static Utils::FilePath projectDirectory(const Utils::FilePath &top);
|
||||
|
@@ -1773,18 +1773,10 @@ void ProjectExplorerPlugin::unloadProject(Project *project)
|
||||
BuildManager::cancel();
|
||||
}
|
||||
|
||||
IDocument *document = project->document();
|
||||
|
||||
if (!document || document->filePath().isEmpty()) //nothing to save?
|
||||
return;
|
||||
|
||||
if (!DocumentManager::saveModifiedDocumentSilently(document))
|
||||
return;
|
||||
|
||||
if (projectExplorerSettings().closeSourceFilesWithProject && !dd->closeAllFilesInProject(project))
|
||||
return;
|
||||
|
||||
dd->addToRecentProjects(document->filePath().toString(), project->displayName());
|
||||
dd->addToRecentProjects(project->projectFilePath().toString(), project->displayName());
|
||||
|
||||
SessionManager::removeProject(project);
|
||||
dd->updateActions();
|
||||
|
@@ -84,7 +84,7 @@ bool QmlProjectNode::renameFile(const QString & filePath, const QString & newFil
|
||||
m_project->setMainFile(newFilePath);
|
||||
|
||||
// make sure to change it also in the qmlproject file
|
||||
const QString qmlProjectFilePath = m_project->document()->filePath().toString();
|
||||
const QString qmlProjectFilePath = m_project->projectFilePath().toString();
|
||||
Core::FileChangeBlocker fileChangeBlocker(qmlProjectFilePath);
|
||||
const QList<Core::IEditor *> editors = Core::DocumentModel::editorsForFilePath(qmlProjectFilePath);
|
||||
TextEditor::TextDocument *document = nullptr;
|
||||
|
@@ -1246,19 +1246,13 @@ static QTextCodec *findFileCodec(const QString &source)
|
||||
// Find the codec by checking the projects (root dir of project file)
|
||||
static QTextCodec *findProjectCodec(const QString &dir)
|
||||
{
|
||||
const FilePath dirPath = FilePath::fromString(dir);
|
||||
typedef QList<ProjectExplorer::Project*> ProjectList;
|
||||
// Try to find a project under which file tree the file is.
|
||||
const ProjectList projects = ProjectExplorer::SessionManager::projects();
|
||||
if (!projects.empty()) {
|
||||
const ProjectList::const_iterator pcend = projects.constEnd();
|
||||
for (ProjectList::const_iterator it = projects.constBegin(); it != pcend; ++it)
|
||||
if (const Core::IDocument *document = (*it)->document())
|
||||
if (document->filePath().toString().startsWith(dir)) {
|
||||
QTextCodec *codec = (*it)->editorConfiguration()->textCodec();
|
||||
return codec;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
const ProjectExplorer::Project *p
|
||||
= findOrDefault(projects, equal(&ProjectExplorer::Project::projectDirectory, dirPath));
|
||||
return p ? p->editorConfiguration()->textCodec() : nullptr;
|
||||
}
|
||||
|
||||
QTextCodec *VcsBaseEditor::getCodec(const QString &source)
|
||||
|
Reference in New Issue
Block a user