File indexing completed on 2024-05-19 04:41:58

0001 /*
0002     SPDX-FileCopyrightText: 2012 Aleix Pol <aleixpol@kde.org>
0003     SPDX-FileCopyrightText: 2012 Milian Wolff <mail@milianw.de>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef CONTEXTBUILDER_H
0009 #define CONTEXTBUILDER_H
0010 
0011 #include <language/duchain/builders/abstractcontextbuilder.h>
0012 #include <language/duchain/types/abstracttype.h>
0013 #include <language/duchain/declaration.h>
0014 
0015 #include <qmljs/parser/qmljsast_p.h>
0016 #include <qmljs/qmljsdocument.h>
0017 
0018 #include "duchainexport.h"
0019 
0020 class ParseSession;
0021 
0022 using ContextBuilderBase = KDevelop::AbstractContextBuilder<QmlJS::AST::Node, QmlJS::AST::IdentifierPropertyName>;
0023 
0024 class KDEVQMLJSDUCHAIN_EXPORT ContextBuilder : public ContextBuilderBase, public QmlJS::AST::Visitor
0025 {
0026 public:
0027     struct ExpressionType
0028     {
0029         KDevelop::AbstractType::Ptr type;
0030         KDevelop::DeclarationPointer declaration;
0031         bool isPrototype;
0032     };
0033 
0034 public:
0035     ContextBuilder();
0036 
0037     void startVisiting(QmlJS::AST::Node* node) override;
0038     KDevelop::RangeInRevision editorFindRange(QmlJS::AST::Node* fromNode, QmlJS::AST::Node* toNode) override;
0039     KDevelop::QualifiedIdentifier identifierForNode(QmlJS::AST::IdentifierPropertyName* node) override;
0040 
0041     void setContextOnNode(QmlJS::AST::Node* node, KDevelop::DUContext* context) override;
0042     KDevelop::DUContext* contextFromNode(QmlJS::AST::Node* node) override;
0043 
0044     KDevelop::TopDUContext* newTopContext(const KDevelop::RangeInRevision& range,
0045                                           KDevelop::ParsingEnvironmentFile* file = nullptr) override;
0046     KDevelop::DUContext* newContext(const KDevelop::RangeInRevision& range) override;
0047 
0048     ExpressionType findType(QmlJS::AST::Node* node);
0049     void setParseSession(ParseSession* session);
0050 
0051 protected:
0052     ParseSession* m_session;
0053 
0054 };
0055 
0056 #endif // CONTEXTBUILDER_H