1 /*
2     This file is part of KDevelop
3     SPDX-FileCopyrightText: 2007 David Nolden <david.nolden.kdevelop@art-master.de>
4     SPDX-FileCopyrightText: 2008 Niko Sams <niko.sams@gmail.com>
5 
6     SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 #ifndef EXPRESSIONPARSER_H
9 #define EXPRESSIONPARSER_H
10 
11 #include <language/duchain/duchainpointer.h>
12 
13 #include "phpduchainexport.h"
14 #include "expressionevaluationresult.h"
15 
16 namespace Php
17 {
18 struct AstNode;
19 class EditorIntegrator;
20 
21 class KDEVPHPDUCHAIN_EXPORT ExpressionParser
22 {
23 public:
24     /**
25      * @param debug Enables additional output
26      */
27     explicit ExpressionParser(bool debug = false);
28 
29     /**
30      * By default, no problems are created at the top-ducontext.
31      */
32     void setCreateProblems(bool v);
33 
34     /**
35      * Evaluate the @p expression and find it's type and last-used declaration.
36      *
37      * @param offset Set this to the front-edge of the expression.
38      *               Used in the ExpressionVisitor to find visible declarations.
39      *
40      * @see ExpressionVisitor
41      */
42     ExpressionEvaluationResult evaluateType(const QByteArray& expression, KDevelop::DUContextPointer context,
43                                             const KDevelop::CursorInRevision &offset);
44     /**
45      * Sets up an ExpressionVisitor and returns it's result when visiting @p ast .
46      *
47      * @see ExpressionVisitor
48      */
49     ExpressionEvaluationResult evaluateType(AstNode* ast, EditorIntegrator* editor);
50 
51 private:
52     /**
53      * This is private instead of reusing the method above with a default argument
54      * for the offset, because we _never_ want to use this directly.
55      */
56     ExpressionEvaluationResult evaluateType(AstNode* ast, EditorIntegrator* editor,
57                                             const KDevelop::CursorInRevision &offset);
58     bool m_debug;
59     bool m_createProblems;
60 };
61 
62 
63 }
64 #endif
65