Warning, file /kdevelop/kdev-php/duchain/tests/duchaintestbase.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org> 0003 SPDX-FileCopyrightText: 2008 Niko Sams <niko.sams@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef DUCHAINTESTBASE_H 0009 #define DUCHAINTESTBASE_H 0010 0011 #include <QObject> 0012 #include <QByteArray> 0013 #include <QTest> 0014 0015 #include <language/duchain/duchain.h> 0016 #include <language/duchain/duchainlock.h> 0017 0018 #include <tests/testhelpers.h> 0019 0020 #include "../completion/item.h" 0021 0022 namespace KDevelop 0023 { 0024 class TopDUContext; 0025 } 0026 0027 namespace Php 0028 { 0029 /** 0030 * Manage pointer to TopDUContexts and release them properly, even if a test fails 0031 */ 0032 struct DUChainReleaser { 0033 DUChainReleaser(KDevelop::TopDUContext* top) : m_top(top) {} 0034 ~DUChainReleaser() { 0035 KDevelop::DUChainWriteLocker lock(KDevelop::DUChain::lock()); 0036 KDevelop::DUChain::self()->removeDocumentChain(m_top); 0037 } 0038 KDevelop::TopDUContext* m_top; 0039 }; 0040 0041 class DUChainTestBase : public QObject 0042 { 0043 Q_OBJECT 0044 0045 public: 0046 enum DumpArea { 0047 DumpNone = 0, 0048 DumpAST = 1, 0049 DumpDUChain = 2, 0050 DumpType = 4, 0051 DumpAll = 7 0052 }; 0053 Q_DECLARE_FLAGS(DumpAreas, DumpArea) 0054 0055 public slots: 0056 void initTestCase(); 0057 void cleanupTestCase(); 0058 0059 protected: 0060 KDevelop::TopDUContext* parse(const QByteArray& unit, 0061 DUChainTestBase::DumpAreas dump = DumpAreas(DumpAll), 0062 QUrl url = {}, KDevelop::TopDUContext* update = nullptr); 0063 0064 KDevelop::TopDUContext* parseAdditionalFile(const KDevelop::IndexedString& fileName, const QByteArray& contents); 0065 0066 KDevelop::CompletionTreeItemPointer searchDeclaration(QList<KDevelop::CompletionTreeItemPointer> items, KDevelop::Declaration* declaration); 0067 bool hasImportedParentContext(KDevelop::TopDUContext* top, KDevelop::DUContext* lookingFor); 0068 }; 0069 0070 Q_DECLARE_OPERATORS_FOR_FLAGS(DUChainTestBase::DumpAreas) 0071 } 0072 0073 #endif