Commit 2fde3fff authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Make all projects generate a fresh project tree



Do not update the existing project tree anymore: Start a fresh one
and throw the old one away.

Change-Id: Ifabe293b6ca668b0672516a6d81acd5346d98fe5
Reviewed-by: default avatarhjk <hjk@qt.io>
parent 71a5aee3
......@@ -227,8 +227,10 @@ void AutotoolsProject::makefileParsingFinished()
f == QLatin1String("configure.ac")) ? FileType::Project : FileType::Resource,
false);
});
rootProjectNode()->makeEmpty();
rootProjectNode()->buildTree(fileNodes);
auto newRoot = new AutotoolsProjectNode(projectDirectory());
newRoot->buildTree(fileNodes);
setRootProjectNode(newRoot);
updateCppCodeModel();
......
......@@ -215,13 +215,15 @@ QList<CMakeBuildTarget> CMakeBuildConfiguration::buildTargets() const
return m_buildDirManager->buildTargets();
}
void CMakeBuildConfiguration::generateProjectTree(CMakeListsNode *root,
const QList<const FileNode*> &allFiles) const
CMakeListsNode *
CMakeBuildConfiguration::generateProjectTree(const QList<const FileNode*> &allFiles) const
{
auto root = new CMakeListsNode(target()->project()->projectFilePath());
if (!m_buildDirManager || m_buildDirManager->isParsing())
return;
return nullptr;
m_buildDirManager->generateProjectTree(root, allFiles);
return root;
}
void CMakeBuildConfiguration::updateCodeModel(CppTools::RawProjectParts &rpps)
......
......@@ -86,7 +86,7 @@ public:
void clearCache();
QList<CMakeBuildTarget> buildTargets() const;
void generateProjectTree(CMakeListsNode *root, const QList<const ProjectExplorer::FileNode *> &allFiles) const;
CMakeListsNode *generateProjectTree(const QList<const ProjectExplorer::FileNode *> &allFiles) const;
void updateCodeModel(CppTools::RawProjectParts &rpps);
static Utils::FileName
......
......@@ -151,7 +151,9 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
Kit *k = t->kit();
bc->generateProjectTree(static_cast<CMakeListsNode *>(rootProjectNode()), m_allFiles);
auto newRoot = bc->generateProjectTree(m_allFiles);
if (newRoot)
setRootProjectNode(newRoot);
updateApplicationAndDeploymentTargets();
updateTargetRunConfigurations(t);
......
......@@ -278,8 +278,10 @@ void GenericProject::refresh(RefreshOptions options)
FileType::Project,
/* generated = */ false);
fileNodes << projectFilesNode << projectIncludesNode << projectConfigNode;
rootProjectNode()->makeEmpty();
rootProjectNode()->buildTree(fileNodes);
auto newRoot = new GenericProjectNode(this);
newRoot->buildTree(fileNodes);
setRootProjectNode(newRoot);
}
refreshCppCodeModel();
......
......@@ -157,8 +157,10 @@ void NimProject::updateProject()
if (oldFiles == m_files)
return;
rootProjectNode()->makeEmpty();
rootProjectNode()->buildTree(fileNodes);
auto newRoot = new NimProjectNode(*this, projectDirectory());
newRoot->setDisplayName(displayName());
newRoot->buildTree(fileNodes);
setRootProjectNode(newRoot);
emit fileListChanged();
......
......@@ -573,8 +573,9 @@ void PythonProject::refresh()
const QString displayName = baseDir.relativeFilePath(f);
return new PythonFileNode(FileName::fromString(f), displayName);
});
rootProjectNode()->makeEmpty();
rootProjectNode()->buildTree(fileNodes);
auto newRoot = new PythonProjectNode(this);
newRoot->buildTree(fileNodes);
setRootProjectNode(newRoot);
emit parsingFinished();
}
......
......@@ -180,13 +180,11 @@ QStringList unreferencedBuildSystemFiles(const qbs::Project &p)
namespace QbsProjectManager {
namespace Internal {
void QbsNodeTreeBuilder::buildTree(QbsProject *project)
QbsRootProjectNode *QbsNodeTreeBuilder::buildTree(QbsProject *project)
{
QbsRootProjectNode *root = project->rootProjectNode();
QTC_ASSERT(root, return);
root->makeEmpty();
root->addNode(new ProjectExplorer::FileNode(project->projectFilePath(), ProjectExplorer::FileType::Project, false));
auto root = new QbsRootProjectNode(project);
root->addNode(new ProjectExplorer::FileNode(project->projectFilePath(),
ProjectExplorer::FileType::Project, false));
auto buildSystemFiles
= new ProjectExplorer::FolderNode(project->projectDirectory(),
......@@ -205,8 +203,7 @@ void QbsNodeTreeBuilder::buildTree(QbsProject *project)
root->addNode(buildSystemFiles);
setupProjectNode(root, project->qbsProjectData(), project->qbsProject());
root->emitNodeUpdated();
root->emitTreeChanged();
return root;
}
} // namespace Internal
......
......@@ -39,7 +39,7 @@ namespace Internal {
class QbsNodeTreeBuilder
{
public:
static void buildTree(QbsProject *project);
static QbsRootProjectNode *buildTree(QbsProject *project);
};
} // namespace Internal
......
......@@ -131,8 +131,9 @@ QbsProject::QbsProject(const FileName &fileName) :
setId(Constants::PROJECT_ID);
setDocument(new QbsProjectFile(this, fileName));
DocumentManager::addDocument(document());
setRootProjectNode(new QbsRootProjectNode(this));
auto newRoot = new QbsRootProjectNode(this);
Internal::QbsNodeTreeBuilder::buildTree(this); // Populate with initial data
setRootProjectNode(newRoot);
setProjectContext(Context(Constants::PROJECT_ID));
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
......@@ -314,7 +315,7 @@ bool QbsProject::addFilesToProduct(const QStringList &filePaths,
}
if (notAdded->count() != filePaths.count()) {
m_projectData = m_qbsProject.projectData();
Internal::QbsNodeTreeBuilder::buildTree(this);
setRootProjectNode(Internal::QbsNodeTreeBuilder::buildTree(this));
emit fileListChanged();
}
return notAdded->isEmpty();
......@@ -342,7 +343,7 @@ bool QbsProject::removeFilesFromProduct(const QStringList &filePaths,
}
if (notRemoved->count() != filePaths.count()) {
m_projectData = m_qbsProject.projectData();
Internal::QbsNodeTreeBuilder::buildTree(this);
setRootProjectNode(Internal::QbsNodeTreeBuilder::buildTree(this));
emit fileListChanged();
}
return notRemoved->isEmpty();
......@@ -484,7 +485,7 @@ void QbsProject::updateAfterParse()
void QbsProject::updateProjectNodes()
{
OpTimer opTimer("updateProjectNodes");
Internal::QbsNodeTreeBuilder::buildTree(this);
setRootProjectNode(Internal::QbsNodeTreeBuilder::buildTree(this));
}
void QbsProject::handleQbsParsingDone(bool success)
......
......@@ -196,16 +196,12 @@ static void createTree(const QmakePriFile *pri, QmakePriFileNode *node)
}
}
QmakeProFileNode *QmakeNodeTreeBuilder::buildTree(const QmakeProFile *rootProFile, QmakeProFileNode *rootNode)
QmakeProFileNode *QmakeNodeTreeBuilder::buildTree(QmakeProject *project)
{
rootNode->makeEmpty();
auto root = new QmakeProFileNode(project, project->projectFilePath());
createTree(project->rootProFile(), root);
createTree(rootProFile, rootNode);
rootNode->emitTreeChanged();
rootNode->emitNodeUpdated();
return rootNode;
return root;
}
} // namespace QmakeProjectManager
......@@ -37,7 +37,7 @@ namespace QmakeProjectManager {
class QmakeNodeTreeBuilder
{
public:
static QmakeProFileNode *buildTree(const QmakeProFile *rootProFile, QmakeProFileNode *rootNode);
static QmakeProFileNode *buildTree(QmakeProject *project);
};
} // namespace QmakeProjectManager
......@@ -559,7 +559,7 @@ void QmakeProject::decrementPendingEvaluateFutures()
m_asyncUpdateFutureInterface->setProgressValue(m_asyncUpdateFutureInterface->progressValue() + 1);
if (m_pendingEvaluateFuturesCount == 0) {
// We are done!
QmakeNodeTreeBuilder::buildTree(rootProFile(), rootProjectNode());
setRootProjectNode(QmakeNodeTreeBuilder::buildTree(this));
m_asyncUpdateFutureInterface->reportFinished();
delete m_asyncUpdateFutureInterface;
......
......@@ -396,8 +396,9 @@ void QmlProject::generateProjectTree()
return new FileNode(Utils::FileName::fromString(f), fileType, false);
});
rootProjectNode()->makeEmpty();
rootProjectNode()->buildTree(fileNodes);
auto newRoot = new Internal::QmlProjectNode(this);
newRoot->buildTree(fileNodes);
setRootProjectNode(newRoot);
}
} // namespace QmlProjectManager
......
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