~ubuntu-branches/ubuntu/utopic/kdevelop-php/utopic

« back to all changes in this revision

Viewing changes to duchain/contextbuilder.h

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2010-01-17 17:10:22 UTC
  • Revision ID: james.westby@ubuntu.com-20100117171022-q2xlgd9ekewo2ijx
Tags: upstream-1.0.0~beta2
ImportĀ upstreamĀ versionĀ 1.0.0~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   This file is part of KDevelop                                         *
 
3
 *   Copyright 2008 Niko Sams <niko.sams@gmail.com>                        *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU Library General Public License as       *
 
7
 *   published by the Free Software Foundation; either version 2 of the    *
 
8
 *   License, or (at your option) any later version.                       *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU Library General Public     *
 
16
 *   License along with this program; if not, write to the                 *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 
19
 ***************************************************************************/
 
20
 
 
21
#ifndef CONTEXTBUILDER_H
 
22
#define CONTEXTBUILDER_H
 
23
 
 
24
#include "phpdefaultvisitor.h"
 
25
#include <language/duchain/builders/abstractcontextbuilder.h>
 
26
 
 
27
#include "phpduchainexport.h"
 
28
#include "editorintegrator.h"
 
29
#include "helper.h"
 
30
 
 
31
 
 
32
namespace Php
 
33
{
 
34
class EditorIntegrator;
 
35
class ParseSession;
 
36
 
 
37
typedef KDevelop::AbstractContextBuilder<AstNode, IdentifierAst> ContextBuilderBase;
 
38
 
 
39
/// first is the "pretty" identifier used for printing
 
40
/// second comes the all-lowercase identifier used for storage
 
41
typedef QPair<QString, KDevelop::QualifiedIdentifier> IdentifierPair;
 
42
 
 
43
class KDEVPHPDUCHAIN_EXPORT ContextBuilder: public ContextBuilderBase, public DefaultVisitor
 
44
{
 
45
 
 
46
public:
 
47
    ContextBuilder();
 
48
    virtual ~ContextBuilder();
 
49
 
 
50
    void setEditor(EditorIntegrator* editor);
 
51
    void setEditor(ParseSession* session);
 
52
    virtual KDevelop::ReferencedTopDUContext build(const KDevelop::IndexedString& url, AstNode* node,
 
53
            KDevelop::ReferencedTopDUContext updateContext
 
54
            = KDevelop::ReferencedTopDUContext(), bool useSmart = true);
 
55
protected:
 
56
    EditorIntegrator* editor() const;
 
57
 
 
58
    virtual KDevelop::DUContext* newContext(const KDevelop::SimpleRange& range);
 
59
    virtual KDevelop::TopDUContext* newTopContext(const KDevelop::SimpleRange& range, KDevelop::ParsingEnvironmentFile* file = 0);
 
60
 
 
61
    virtual void startVisiting(AstNode* node);
 
62
    virtual void setContextOnNode(AstNode* node, KDevelop::DUContext* ctx);
 
63
    virtual KDevelop::DUContext* contextFromNode(AstNode* node);
 
64
    virtual KTextEditor::Range editorFindRange(AstNode* fromRange, AstNode* toRange);
 
65
 
 
66
    virtual KDevelop::QualifiedIdentifier identifierForNode(IdentifierAst* id);
 
67
    KDevelop::QualifiedIdentifier identifierForNode(VariableIdentifierAst* id);
 
68
    IdentifierPair identifierPairForNode(IdentifierAst* id);
 
69
    QString stringForNode(IdentifierAst* node) const;
 
70
    QString stringForNode(VariableIdentifierAst* node) const;
 
71
 
 
72
    virtual void visitClassDeclarationStatement(ClassDeclarationStatementAst*);
 
73
    virtual void visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst* node);
 
74
    virtual void visitClassStatement(ClassStatementAst *node);
 
75
    virtual void visitFunctionDeclarationStatement(FunctionDeclarationStatementAst* node);
 
76
    virtual void visitUnaryExpression(UnaryExpressionAst* node);
 
77
 
 
78
    virtual void addBaseType(IdentifierAst * identifier);
 
79
 
 
80
    virtual void classContextOpened(KDevelop::DUContext* context);
 
81
 
 
82
    /// Report @p errorMsg with the range of @p node
 
83
    /// @see void reportError(const QString& errorMsg, KTextEditor::Range range);
 
84
    void reportError(const QString& errorMsg, AstNode* node,
 
85
                        KDevelop::ProblemData::Severity severity = KDevelop::ProblemData::Error);
 
86
    /// Report @p errorMsg with the range encompassing all nodes in @p nodes
 
87
    /// @see void reportError(const QString& errorMsg, KTextEditor::Range range);
 
88
    void reportError(const QString& errorMsg, QList<AstNode*> nodes,
 
89
                        KDevelop::ProblemData::Severity severity = KDevelop::ProblemData::Error);
 
90
    /// Report @p errorMsg with range @p range
 
91
    void reportError(const QString& errorMsg, KTextEditor::Range range,
 
92
                        KDevelop::ProblemData::Severity severity = KDevelop::ProblemData::Error);
 
93
 
 
94
    KDevelop::Declaration* findDeclarationImport(DeclarationType declarationType, IdentifierAst* node);
 
95
    KDevelop::Declaration* findDeclarationImport(DeclarationType declarationType, VariableIdentifierAst* node);
 
96
    KDevelop::Declaration* findDeclarationImport(DeclarationType declarationType, const KDevelop::QualifiedIdentifier &identifier, AstNode* node);
 
97
 
 
98
    /// InternalFunctions.php should not be checked for errors and can get some optimizations
 
99
    bool m_isInternalFunctions;
 
100
    /// Whether semantic problems should get reported
 
101
    bool m_reportErrors;
 
102
    ///TODO: push this into kdevplatform
 
103
    bool m_mapAst;
 
104
};
 
105
 
 
106
}
 
107
 
 
108
#endif