File indexing completed on 2024-04-21 04:34:26

0001 /***************************************************************************
0002  *   This file is part of KDevelop                                         *
0003  *   Copyright 2010 Niko Sams <niko.sams@gmail.com>                        *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU Library General Public License as       *
0007  *   published by the Free Software Foundation; either version 2 of the    *
0008  *   License, or (at your option) any later version.                       *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU Library General Public     *
0016  *   License along with this program; if not, write to the                 *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0019  ***************************************************************************/
0020 
0021 #ifndef CONTEXTBUILDER_H
0022 #define CONTEXTBUILDER_H
0023 
0024 #include "cssdefaultvisitor.h"
0025 #include <language/duchain/builders/abstractcontextbuilder.h>
0026 
0027 // #include "cssduchainexport.h"
0028 // #include "helper.h"
0029 
0030 
0031 namespace Css
0032 {
0033 class EditorIntegrator;
0034 class ParseSession;
0035 
0036 typedef KDevelop::AbstractContextBuilder<AstNode, SpecifierAst> ContextBuilderBase;
0037 
0038 class ContextBuilder: public ContextBuilderBase, public DefaultVisitor
0039 {
0040 
0041 public:
0042     ContextBuilder();
0043     ~ContextBuilder() override;
0044 
0045     KDevelop::ReferencedTopDUContext build(const KDevelop::IndexedString& url, AstNode* node,
0046             const KDevelop::ReferencedTopDUContext& updateContext = KDevelop::ReferencedTopDUContext()) override;
0047 
0048     void setEditor(EditorIntegrator* editor);
0049 protected:
0050     EditorIntegrator* editor() const;
0051 
0052     KDevelop::TopDUContext* newTopContext(const KDevelop::RangeInRevision& range,
0053                                           KDevelop::ParsingEnvironmentFile* file = nullptr) override;
0054 
0055     void startVisiting(AstNode* node) override;
0056     void setContextOnNode(AstNode* node, KDevelop::DUContext* ctx) override;
0057     KDevelop::DUContext* contextFromNode(AstNode* node) override;
0058     KDevelop::RangeInRevision editorFindRange(AstNode* fromRange, AstNode* toRange) override;
0059     /// Find Cursor for start of a node, useful to limit findLocalDeclarations() searches.
0060     KDevelop::CursorInRevision startPos(AstNode* node);
0061 
0062     KDevelop::QualifiedIdentifier identifierForNode(SpecifierAst* id) override;
0063 
0064     void visitRuleset(RulesetAst* node) override;
0065 
0066     /// Whether semantic problems should get reported
0067     bool m_reportErrors;
0068 
0069 private:
0070     EditorIntegrator* m_editor;
0071 };
0072 
0073 }
0074 
0075 #endif