File indexing completed on 2024-04-28 04:34:22
0001 /*************************************************************************** 0002 * Copyright 2009 Sandro Andrade <sandroandrade@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU Library General Public License as * 0006 * published by the Free Software Foundation; either version 2 of the * 0007 * License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU Library General Public * 0015 * License along with this program; if not, write to the * 0016 * Free Software Foundation, Inc., * 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0018 ***************************************************************************/ 0019 0020 #ifndef DUCHAINCONTROLFLOW_H 0021 #define DUCHAINCONTROLFLOW_H 0022 0023 #include <QSet> 0024 #include <QHash> 0025 #include <QPair> 0026 #include <QPointer> 0027 0028 #include <KUrl> 0029 0030 #include <language/duchain/ducontext.h> 0031 #include <util/path.h> 0032 0033 class QPoint; 0034 0035 namespace KTextEditor { 0036 class View; 0037 class Cursor; 0038 } 0039 namespace KDevelop { 0040 class Use; 0041 class IndexedString; 0042 class DUContext; 0043 class Declaration; 0044 class TopDUContext; 0045 class IProject; 0046 } 0047 0048 class KJob; 0049 0050 class DotControlFlowGraph; 0051 class ControlFlowGraphUsesCollector; 0052 0053 using namespace KDevelop; 0054 0055 class DUChainControlFlow : public QObject 0056 { 0057 Q_OBJECT 0058 public: 0059 DUChainControlFlow(DotControlFlowGraph *dotControlFlowGraph); 0060 virtual ~DUChainControlFlow(); 0061 0062 enum ControlFlowMode { ControlFlowFunction, ControlFlowClass, ControlFlowNamespace }; 0063 void setControlFlowMode(ControlFlowMode controlFlowMode); 0064 0065 enum ClusteringMode 0066 { 0067 ClusteringNone = 0x0, 0068 ClusteringClass = 0x1, 0069 ClusteringNamespace = 0x2, 0070 ClusteringProject = 0x4 0071 }; 0072 Q_DECLARE_FLAGS(ClusteringModes, ClusteringMode) 0073 void setClusteringModes(ClusteringModes clusteringModes); 0074 ClusteringModes clusteringModes() const; 0075 0076 void generateControlFlowForDeclaration(IndexedDeclaration idefinition, IndexedTopDUContext itopContext, IndexedDUContext iuppermostExecutableContext); 0077 bool isLocked(); 0078 void run(); 0079 0080 public Q_SLOTS: 0081 void cursorPositionChanged(KTextEditor::View *view, const KTextEditor::Cursor &cursor); 0082 void processFunctionCall(Declaration *source, Declaration *target, const Use &use); 0083 0084 void slotGraphElementSelected(const QList<QString> list, const QPoint& point); 0085 void slotEdgeHover(QString label); 0086 0087 void setLocked(bool locked); 0088 void setUseFolderName(bool useFolderName); 0089 void setUseShortNames(bool useFolderName); 0090 void setDrawIncomingArcs(bool drawIncomingArcs); 0091 void setMaxLevel(int maxLevel); 0092 void setShowUsesOnEdgeHover(bool checked); 0093 0094 void refreshGraph(); 0095 void newGraph(); 0096 0097 private Q_SLOTS: 0098 void jobDone (KJob* job); 0099 0100 Q_SIGNALS: 0101 void startingJob(); 0102 void jobDone(); 0103 0104 private: 0105 void useDeclarationsFromDefinition(Declaration *definition, TopDUContext *topContext, DUContext *context); 0106 Declaration *declarationFromControlFlowMode(Declaration *definitionDeclaration); 0107 void prepareContainers(QStringList &containers, Declaration* definition); 0108 QString globalNamespaceOrFolderNames(Declaration *declaration); 0109 QString prependFolderNames(Declaration *declaration); 0110 QString shortNameFromContainers(const QList<QString> &containers, const QString &qualifiedIdentifier); 0111 void updateToolTip(const QString &edge, const QPoint& point, QWidget *partWidget); 0112 0113 QPointer<DotControlFlowGraph> m_dotControlFlowGraph; 0114 IndexedDUContext m_previousUppermostExecutableContext; 0115 0116 KTextEditor::View *m_currentView; 0117 IndexedDUContext m_currentContext; 0118 0119 IndexedDeclaration m_definition; 0120 IndexedTopDUContext m_topContext; 0121 IndexedDUContext m_uppermostExecutableContext; 0122 0123 QSet<IndexedDeclaration> m_visitedFunctions; 0124 QHash<QString, IndexedDeclaration> m_identifierDeclarationMap; 0125 QMultiHash<QString, QPair<RangeInRevision, IndexedString> > m_arcUsesMap; 0126 QPointer<KDevelop::IProject> m_currentProject; 0127 0128 int m_currentLevel; 0129 int m_maxLevel; 0130 bool m_locked; 0131 bool m_drawIncomingArcs; 0132 bool m_useFolderName; 0133 bool m_useShortNames; 0134 bool m_ShowUsesOnEdgeHover; 0135 0136 ControlFlowMode m_controlFlowMode; 0137 ClusteringModes m_clusteringModes; 0138 0139 bool m_graphThreadRunning; 0140 bool m_abort; 0141 0142 QPointer<ControlFlowGraphUsesCollector> m_collector; 0143 KDevelop::Path::List m_includeDirectories; 0144 }; 0145 0146 Q_DECLARE_OPERATORS_FOR_FLAGS(DUChainControlFlow::ClusteringModes) 0147 0148 #endif