1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/*
SPDX-FileCopyrightText: 2007 Piyush verma <piyush.verma@gmail.com>
SPDX-FileCopyrightText: 2008 Niko Sams <niko.sams@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef PHP_PARSESESSION_H
#define PHP_PARSESESSION_H
#include <QString>
#include "phpparser.h"
#include "parserexport.h"
namespace KDevPG
{
class MemoryPool;
}
namespace Php
{
class TokenStream;
struct StartAst;
typedef QPair<KDevelop::DUContextPointer, KDevelop::RangeInRevision> SimpleUse;
class KDEVPHPPARSER_EXPORT ParseSession
{
public:
ParseSession();
~ParseSession();
void setContents(const QString& contents);
void setCurrentDocument(const KDevelop::IndexedString& filename);
KDevelop::IndexedString currentDocument() const;
bool readFile(const QString& filename);
void setDebug(bool);
TokenStream* tokenStream() const;
QString contents() const;
bool parse(Php::StartAst**);
Parser* createParser(int initialState = Parser::HtmlState);
QString symbol(qint64 token) const;
QString symbol(AstNode* node) const;
/**
* Return the DocBlock before this token, if any
*/
QString docComment(qint64 token) const;
/**
* Return the position (\a line%, \a column%) of the \a offset in the file.
*
* \note the line starts from 0.
*/
KDevelop::CursorInRevision positionAt(qint64 offset) const;
QList<KDevelop::ProblemPointer> problems();
/// @TODO implement this
void mapAstUse(AstNode* node, const SimpleUse& use)
{
Q_UNUSED(node);
Q_UNUSED(use);
}
private:
QString m_contents;
bool m_debug;
KDevelop::IndexedString m_currentDocument;
KDevPG::MemoryPool* m_pool;
TokenStream* m_tokenStream;
QList<KDevelop::ProblemPointer> m_problems;
};
}
#endif
// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on; auto-insert-doxygen on
|