File indexing completed on 2024-05-05 16:41:07
0001 /* 0002 SPDX-FileCopyrightText: 2008 Milian Wolff <mail@milianw.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef PREDECLARATIONBUILDER_H 0008 #define PREDECLARATIONBUILDER_H 0009 0010 #include "contextbuilder.h" 0011 #include "helper.h" 0012 #include <language/duchain/builders/abstractdeclarationbuilder.h> 0013 0014 namespace KDvelop 0015 { 0016 class Declaration; 0017 } 0018 namespace Php 0019 { 0020 class ParseSession; 0021 class EditorIntegrator; 0022 class FunctionDeclaration; 0023 class ClassDeclaration; 0024 class NamespaceDeclaration; 0025 0026 typedef KDevelop::AbstractDeclarationBuilder<AstNode, IdentifierAst, ContextBuilder> PreDeclarationBuilderBase; 0027 0028 /** 0029 * The PreDeclarationBuilder builds usable declarations for classes, interfaces and functions. 0030 * 0031 * \todo constants should probably be handled here as well 0032 */ 0033 class KDEVPHPDUCHAIN_EXPORT PreDeclarationBuilder : public PreDeclarationBuilderBase 0034 { 0035 public: 0036 PreDeclarationBuilder(QHash<qint64, ClassDeclaration*>* types, 0037 QHash<qint64, FunctionDeclaration*>* functions, 0038 QHash<qint64, NamespaceDeclaration*>* namespaces, 0039 QVector<KDevelop::QualifiedIdentifier>* upcomingClassVariables, 0040 EditorIntegrator* editor ) 0041 : m_types(types), m_functions(functions), m_namespaces(namespaces), 0042 m_upcomingClassVariables(upcomingClassVariables) 0043 { 0044 m_editor = editor; 0045 } 0046 0047 ~PreDeclarationBuilder() override; 0048 0049 /// make it accessible to the declaration builder 0050 bool didRecompile() { return recompiling(); } 0051 0052 protected: 0053 // virtual void visitNode(AstNode* node); 0054 void visitClassDeclarationStatement(ClassDeclarationStatementAst *node) override; 0055 void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst *node) override; 0056 void visitTraitDeclarationStatement(TraitDeclarationStatementAst *node) override; 0057 void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst *node) override; 0058 void visitClassVariable(ClassVariableAst* node) override; 0059 void openNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier, const KDevelop::RangeInRevision& range) override; 0060 void closeNamespace(NamespaceDeclarationStatementAst* parent, IdentifierAst* node, const IdentifierPair& identifier) override; 0061 0062 void closeDeclaration() override; 0063 void closeContext() override; 0064 private: 0065 QHash<qint64, ClassDeclaration*>* m_types; 0066 QHash<qint64, FunctionDeclaration*>* m_functions; 0067 QHash<qint64, NamespaceDeclaration*>* m_namespaces; 0068 QVector<KDevelop::QualifiedIdentifier>* m_upcomingClassVariables; 0069 }; 0070 0071 } 0072 0073 #endif // PREDECLARATIONBUILDER_H 0074