File indexing completed on 2024-04-28 12:21:50
0001 /* 0002 SPDX-FileCopyrightText: 2007 David Nolden <david.nolden.kdevelop@art-master.de> 0003 SPDX-FileCopyrightText: 2008 Niko Sams <niko.sams@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef EXPRESSIONPARSER_H 0009 #define EXPRESSIONPARSER_H 0010 0011 #include <language/duchain/duchainpointer.h> 0012 0013 #include "phpduchainexport.h" 0014 #include "expressionevaluationresult.h" 0015 0016 namespace Php 0017 { 0018 struct AstNode; 0019 class EditorIntegrator; 0020 0021 class KDEVPHPDUCHAIN_EXPORT ExpressionParser 0022 { 0023 public: 0024 /** 0025 * @param debug Enables additional output 0026 */ 0027 explicit ExpressionParser(bool debug = false); 0028 0029 /** 0030 * By default, no problems are created at the top-ducontext. 0031 */ 0032 void setCreateProblems(bool v); 0033 0034 /** 0035 * Evaluate the @p expression and find it's type and last-used declaration. 0036 * 0037 * @param offset Set this to the front-edge of the expression. 0038 * Used in the ExpressionVisitor to find visible declarations. 0039 * 0040 * @see ExpressionVisitor 0041 */ 0042 ExpressionEvaluationResult evaluateType(const QByteArray& expression, KDevelop::DUContextPointer context, 0043 const KDevelop::CursorInRevision &offset); 0044 /** 0045 * Sets up an ExpressionVisitor and returns it's result when visiting @p ast . 0046 * 0047 * @see ExpressionVisitor 0048 */ 0049 ExpressionEvaluationResult evaluateType(AstNode* ast, EditorIntegrator* editor); 0050 0051 private: 0052 /** 0053 * This is private instead of reusing the method above with a default argument 0054 * for the offset, because we _never_ want to use this directly. 0055 */ 0056 ExpressionEvaluationResult evaluateType(AstNode* ast, EditorIntegrator* editor, 0057 const KDevelop::CursorInRevision &offset); 0058 bool m_debug; 0059 bool m_createProblems; 0060 }; 0061 0062 0063 } 0064 #endif