ClassView: Minimize the mutating API of ParserTreeItem

Make the API of ParserTreeItem const only.
Reorganize the code a bit:

Transform ParserTreeItem::add() method into private
mergeWith() and add a static method
ParserTreeItem::mergeTrees().

Remove ParserTreeItem::copy(), as in case of adding
projects we may use directly the instance from cache.
Remove now unneeded Parser::addProject() and use
directly getCachedOrParseProjectTree().

Transform ParserTreeItem::copyTree() into private
cloneTree() and make it a const method.

Move document symbols parsing code from Parser into
ParserTreeItem and add a static method
ParserTreeItem::parseDocument().

Remove ParserTreeItem::addChild() and provide instead
an overloaded constructor.

Allocate QElapedTimer object only when debug is on.

Fix some const correctness.

Remove some ugly usings.

Added some TODOs.

Task-number: QTCREATORBUG-25317
Change-Id: I6e7c48bb118b0d826fbb463cae94d59bf43a6938
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2021-02-15 17:11:11 +01:00
parent 9c896aa291
commit 06f305265b
4 changed files with 208 additions and 291 deletions

View File

@@ -29,7 +29,6 @@
#include "classviewparsertreeitem.h"
#include <cplusplus/CPlusPlusForwardDeclarations.h>
#include <cplusplus/CppDocument.h>
// might be changed to forward declaration - is not done to be less dependent
@@ -70,10 +69,6 @@ signals:
private:
void setFileList(const QStringList &fileList);
void resetData(const CPlusPlus::Snapshot &snapshot);
void addProject(const ParserTreeItem::Ptr &item, const QStringList &fileList,
const QString &projectId = QString());
void addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol *symbol);
ParserTreeItem::ConstPtr getParseDocumentTree(const CPlusPlus::Document::Ptr &doc);
ParserTreeItem::ConstPtr getCachedOrParseDocumentTree(const CPlusPlus::Document::Ptr &doc);
@@ -84,7 +79,7 @@ private:
ParserTreeItem::ConstPtr findItemByRoot(const QStandardItem *item, bool skipRoot = false) const;
QStringList getAllFiles(const ProjectExplorer::Project *project);
void addFlatTree(const ParserTreeItem::Ptr &item, const ProjectExplorer::Project *project);
ParserTreeItem::Ptr addFlatTree(const ProjectExplorer::Project *project);
//! Private class data pointer
ParserPrivate *d;