Open type hierarchy from Type Hierarchy editor

Make it possible to open type hierarchy for different
class selected from Type Hierarchy editor.
Make it available under context menu or on double click
on class name (single click opens the class in cpp editor window
as before). Double click doesn't expand / collapse items anymore
(expanding available when pressing the visual arrow).
Make navigation to editor more up to date - e.g. when linked location
changed in meantime (source file was edited), it tries to find
linked symbol quickly again (we introduce a small delay, up to
100-200 ms, depending on source file).

Change-Id: Ifb4fd58e853589a17cd14be465b3a7695fa48193
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2020-12-18 14:40:18 +01:00
parent c427a0d281
commit 72f850df3a
4 changed files with 196 additions and 28 deletions

View File

@@ -56,25 +56,41 @@ public:
void setTextCursor(const QTextCursor &tc);
void setLookupBaseClasses(const bool lookup);
void setLookupDerivedClasses(const bool lookup);
void setExpression(const QString &expression, const QString &fileName);
void execute();
QFuture<QSharedPointer<CppElement>> asyncExecute();
QFuture<QSharedPointer<CppElement>> asyncExpressionExecute();
bool identifiedCppElement() const;
const QSharedPointer<CppElement> &cppElement() const;
bool hasDiagnosis() const;
const QString &diagnosis() const;
static Utils::Link linkFromExpression(const QString &expression, const QString &fileName);
private:
void clear();
using ExecFunction = QFuture<QSharedPointer<CppElement>>(CppElementEvaluator::*)
(const CPlusPlus::Snapshot &, const CPlusPlus::LookupItem &,
const CPlusPlus::LookupContext &);
using SourceFunction = bool(CppElementEvaluator::*)
(const CPlusPlus::Snapshot &, CPlusPlus::Document::Ptr &,
CPlusPlus::Scope **, QString &);
QFuture<QSharedPointer<CppElement>> execute(ExecFunction execFuntion);
QFuture<QSharedPointer<CppElement>> execute(SourceFunction sourceFunction,
ExecFunction execFuntion);
QFuture<QSharedPointer<CppElement>> syncExec(const CPlusPlus::Snapshot &,
const CPlusPlus::LookupItem &, const CPlusPlus::LookupContext &);
QFuture<QSharedPointer<CppElement>> asyncExec(const CPlusPlus::Snapshot &,
const CPlusPlus::LookupItem &, const CPlusPlus::LookupContext &);
bool sourceDataFromGui(const CPlusPlus::Snapshot &snapshot,
CPlusPlus::Document::Ptr &doc,
CPlusPlus::Scope **scope,
QString &expression);
bool sourceDataFromExpression(const CPlusPlus::Snapshot &snapshot,
CPlusPlus::Document::Ptr &doc,
CPlusPlus::Scope **scope,
QString &expression);
void checkDiagnosticMessage(int pos);
bool matchIncludeFile(const CPlusPlus::Document::Ptr &document, int line);
bool matchMacroInUse(const CPlusPlus::Document::Ptr &document, int pos);
@@ -82,6 +98,8 @@ private:
TextEditor::TextEditorWidget *m_editor;
CppTools::CppModelManager *m_modelManager;
QTextCursor m_tc;
QString m_expression;
QString m_fileName;
bool m_lookupBaseClasses;
bool m_lookupDerivedClasses;
QSharedPointer<CppElement> m_element;