forked from qt-creator/qt-creator
QMake/ProjectManager: Simplify QmakeProFileNode::applyEvaluate
... and remove ProjectNode::removeProjectNode, as this was the only remaining user. Change-Id: I2c53392a8e9dacf956270d652525b62ba4c9e0a4 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -726,18 +726,9 @@ void ProjectNode::addProjectNode(ProjectNode *subProject)
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Remove the project node specified by \a subProject from the node hierarchy.
|
Removes all child nodes from the node hierarchy and deletes them.
|
||||||
|
|
||||||
All objects in the \a subProjects list are deleted.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ProjectNode::removeProjectNode(ProjectNode *subProject)
|
|
||||||
{
|
|
||||||
m_projectNodes.removeOne(subProject);
|
|
||||||
m_folderNodes.removeOne(subProject);
|
|
||||||
delete subProject;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectNode::makeEmpty()
|
void ProjectNode::makeEmpty()
|
||||||
{
|
{
|
||||||
foreach (ProjectNode *subProject, m_projectNodes)
|
foreach (ProjectNode *subProject, m_projectNodes)
|
||||||
|
@@ -112,20 +112,6 @@ static const FileTypeDataStorage fileTypeDataStorage[] = {
|
|||||||
ProjectExplorer::Constants::FILEOVERLAY_UNKNOWN, "*;" }
|
ProjectExplorer::Constants::FILEOVERLAY_UNKNOWN, "*;" }
|
||||||
};
|
};
|
||||||
|
|
||||||
class SortByPath
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool operator()(Node *a, Node *b)
|
|
||||||
{ return operator()(a->filePath(), b->filePath()); }
|
|
||||||
bool operator()(Node *a, const FileName &b)
|
|
||||||
{ return operator()(a->filePath(), b); }
|
|
||||||
bool operator()(const FileName &a, Node *b)
|
|
||||||
{ return operator()(a, b->filePath()); }
|
|
||||||
// Compare as strings to correctly detect case-only file rename
|
|
||||||
bool operator()(const FileName &a, const FileName &b)
|
|
||||||
{ return a.toString() < b.toString(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
class QmakeNodeStaticData {
|
class QmakeNodeStaticData {
|
||||||
public:
|
public:
|
||||||
class FileTypeData {
|
class FileTypeData {
|
||||||
@@ -1968,104 +1954,48 @@ void QmakeProFileNode::applyEvaluate(EvalResult *evalResult)
|
|||||||
//
|
//
|
||||||
|
|
||||||
QString buildDirectory = buildDir();
|
QString buildDirectory = buildDir();
|
||||||
SortByPath sortByPath;
|
|
||||||
|
|
||||||
QList<QPair<QmakePriFileNode *, IncludedPriFile *>> toCompare;
|
QList<QPair<QmakePriFileNode *, IncludedPriFile *>> toCompare;
|
||||||
|
|
||||||
toCompare.append(qMakePair(this, &result->includedFiles));
|
toCompare.append(qMakePair(this, &result->includedFiles));
|
||||||
|
|
||||||
|
makeEmpty();
|
||||||
|
|
||||||
while (!toCompare.isEmpty()) {
|
while (!toCompare.isEmpty()) {
|
||||||
QmakePriFileNode *pn = toCompare.first().first;
|
QmakePriFileNode *pn = toCompare.first().first;
|
||||||
IncludedPriFile *tree = toCompare.first().second;
|
IncludedPriFile *tree = toCompare.first().second;
|
||||||
toCompare.pop_front();
|
toCompare.pop_front();
|
||||||
|
|
||||||
QList<ProjectNode*> existingProjectNodes = pn->projectNodes();
|
for (IncludedPriFile *priFile : tree->children) {
|
||||||
Utils::sort(existingProjectNodes, sortByPath);
|
// Loop preventation, make sure that exact same node is not in our parent chain
|
||||||
// result is already sorted
|
bool loop = false;
|
||||||
|
Node *n = pn;
|
||||||
QList<ProjectNode*> toRemove;
|
while ((n = n->parentFolderNode())) {
|
||||||
|
if (dynamic_cast<QmakePriFileNode *>(n) && n->filePath() == priFile->name) {
|
||||||
QList<ProjectNode*>::const_iterator existingIt = existingProjectNodes.constBegin();
|
loop = true;
|
||||||
auto newIt = tree->children.constBegin();
|
break;
|
||||||
|
|
||||||
forever {
|
|
||||||
bool existingAtEnd = (existingIt == existingProjectNodes.constEnd());
|
|
||||||
bool newAtEnd = (newIt == tree->children.constEnd());
|
|
||||||
|
|
||||||
if (existingAtEnd && newAtEnd)
|
|
||||||
break; // we are done, hurray!
|
|
||||||
|
|
||||||
if (! existingAtEnd
|
|
||||||
&& (newAtEnd || (*existingIt)->filePath() < (*newIt)->name)) {
|
|
||||||
// Remove case
|
|
||||||
toRemove << *existingIt;
|
|
||||||
++existingIt;
|
|
||||||
} else if (! newAtEnd
|
|
||||||
&& (existingAtEnd || (*newIt)->name < (*existingIt)->filePath())) {
|
|
||||||
// Adding a node
|
|
||||||
IncludedPriFile *nodeToAdd = *newIt;
|
|
||||||
++newIt;
|
|
||||||
|
|
||||||
// Loop preventation, make sure that exact same node is not in our parent chain
|
|
||||||
bool loop = false;
|
|
||||||
Node *n = pn;
|
|
||||||
while ((n = n->parentFolderNode())) {
|
|
||||||
if (dynamic_cast<QmakePriFileNode *>(n) && n->filePath() == nodeToAdd->name) {
|
|
||||||
loop = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (loop) {
|
if (loop)
|
||||||
// Do nothing
|
continue; // Do nothing
|
||||||
} else {
|
|
||||||
if (nodeToAdd->proFile) {
|
if (priFile->proFile) {
|
||||||
QmakePriFileNode *qmakePriFileNode = new QmakePriFileNode(m_project, this, nodeToAdd->name);
|
QmakePriFileNode *qmakePriFileNode = new QmakePriFileNode(m_project, this, priFile->name);
|
||||||
pn->addProjectNode(qmakePriFileNode);
|
pn->addProjectNode(qmakePriFileNode);
|
||||||
qmakePriFileNode->setIncludedInExactParse(
|
qmakePriFileNode->setIncludedInExactParse(
|
||||||
(result->state == EvalResult::EvalOk) && pn->includedInExactParse());
|
(result->state == EvalResult::EvalOk) && pn->includedInExactParse());
|
||||||
qmakePriFileNode->update(nodeToAdd->result);
|
qmakePriFileNode->update(priFile->result);
|
||||||
toCompare.append(qMakePair(qmakePriFileNode, nodeToAdd));
|
toCompare.append(qMakePair(qmakePriFileNode, priFile));
|
||||||
} else {
|
|
||||||
QmakeProFileNode *qmakeProFileNode = new QmakeProFileNode(m_project, nodeToAdd->name);
|
|
||||||
pn->addProjectNode(qmakeProFileNode);
|
|
||||||
qmakeProFileNode->setIncludedInExactParse(
|
|
||||||
result->exactSubdirs.contains(qmakeProFileNode->filePath())
|
|
||||||
&& pn->includedInExactParse());
|
|
||||||
qmakeProFileNode->setParseInProgress(true);
|
|
||||||
qmakeProFileNode->asyncUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Update existingNodeIte
|
QmakeProFileNode *qmakeProFileNode = new QmakeProFileNode(m_project, priFile->name);
|
||||||
if ((*newIt)->proFile) {
|
pn->addProjectNode(qmakeProFileNode);
|
||||||
QmakePriFileNode *priFileNode = static_cast<QmakePriFileNode *>(*existingIt);
|
qmakeProFileNode->setIncludedInExactParse(
|
||||||
priFileNode->update((*newIt)->result);
|
result->exactSubdirs.contains(qmakeProFileNode->filePath())
|
||||||
priFileNode->setIncludedInExactParse(
|
&& pn->includedInExactParse());
|
||||||
(result->state == EvalResult::EvalOk) && pn->includedInExactParse());
|
qmakeProFileNode->setParseInProgress(true);
|
||||||
toCompare.append(qMakePair(priFileNode, *newIt));
|
qmakeProFileNode->asyncUpdate();
|
||||||
} else {
|
|
||||||
// We always parse exactly, because we later when async parsing don't know whether
|
|
||||||
// the .pro file is included in this .pro file
|
|
||||||
// So to compare that later parse with the sync one
|
|
||||||
QmakeProFileNode *proFileNode = static_cast<QmakeProFileNode *>(*existingIt);
|
|
||||||
proFileNode->setIncludedInExactParse(result->exactSubdirs.contains(proFileNode->filePath())
|
|
||||||
&& pn->includedInExactParse());
|
|
||||||
proFileNode->asyncUpdate();
|
|
||||||
}
|
|
||||||
++newIt;
|
|
||||||
++existingIt;
|
|
||||||
// newCumalativeIt and newExactIt are already incremented
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} // for
|
|
||||||
|
|
||||||
foreach (ProjectNode *node, toRemove) {
|
|
||||||
if (QmakeProFileNode *qmakeProFileNode = dynamic_cast<QmakeProFileNode *>(node)) {
|
|
||||||
qmakeProFileNode->setValidParseRecursive(false);
|
|
||||||
qmakeProFileNode->setParseInProgressRecursive(false);
|
|
||||||
}
|
|
||||||
pn->removeProjectNode(node);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user