File indexing completed on 2024-04-21 04:34:27
0001 /***************************************************************************** 0002 * Copyright (c) 2007 Andreas Pakulat <apaku@gmx.de> * 0003 * Copyright (c) 2007 Piyush verma <piyush.verma@gmail.com> * 0004 * Copyright (c) 2008-2009 Niko Sams <niko.sams@gmail.com> * 0005 * * 0006 * Permission is hereby granted, free of charge, to any person obtaining * 0007 * a copy of this software and associated documentation files (the * 0008 * "Software"), to deal in the Software without restriction, including * 0009 * without limitation the rights to use, copy, modify, merge, publish, * 0010 * distribute, sublicense, and/or sell copies of the Software, and to * 0011 * permit persons to whom the Software is furnished to do so, subject to * 0012 * the following conditions: * 0013 * * 0014 * The above copyright notice and this permission notice shall be * 0015 * included in all copies or substantial portions of the Software. * 0016 * * 0017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * 0018 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 0019 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * 0020 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * 0021 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * 0022 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * 0023 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 0024 *****************************************************************************/ 0025 #ifndef CSS_PARSESESSION_H 0026 #define CSS_PARSESESSION_H 0027 0028 #include <QString> 0029 #include <language/editor/rangeinrevision.h> 0030 #include "cssparser.h" 0031 0032 namespace KDevPG 0033 { 0034 class MemoryPool; 0035 } 0036 0037 namespace Css 0038 { 0039 struct StartAst; 0040 0041 typedef QPair<KDevelop::DUContextPointer, KDevelop::RangeInRevision> SimpleUse; 0042 0043 class KDEVCSSPARSER_EXPORT ParseSession 0044 { 0045 public: 0046 ParseSession(); 0047 ~ParseSession(); 0048 0049 void setContents(const QString& contents); 0050 void setCurrentDocument( const KDevelop::IndexedString& filename); 0051 bool readFile(const QString& filename, const char* charset = nullptr); 0052 void setDebug(bool); 0053 void setOffset(const KDevelop::CursorInRevision &offset); 0054 KDevPG::TokenStream* tokenStream() const; 0055 QString contents() const; 0056 KDevelop::IndexedString currentDocument() const; 0057 0058 bool parse(Css::StartAst**); 0059 bool parse(Css::DeclarationListAst**); 0060 Parser* createParser(); 0061 0062 QString symbol(qint64 token) const; 0063 QString symbol(AstNode* node) const; 0064 0065 /** 0066 * Return the position (\a line%, \a column%) of the \a offset in the file. 0067 * 0068 * \note the line starts from 0. 0069 */ 0070 KDevelop::CursorInRevision positionAt(qint64 offset) const; 0071 0072 QList<KDevelop::ProblemPointer> problems(); 0073 0074 //TODO warning implement this 0075 void mapAstUse(AstNode* node, const SimpleUse& use) 0076 { 0077 Q_UNUSED(node); 0078 Q_UNUSED(use); 0079 } 0080 0081 private: 0082 QString m_contents; 0083 bool m_debug; 0084 KDevelop::IndexedString m_currentDocument; 0085 KDevelop::CursorInRevision m_offset; 0086 KDevPG::MemoryPool* m_pool; 0087 KDevPG::TokenStream* m_tokenStream; 0088 QList<KDevelop::ProblemPointer> m_problems; 0089 }; 0090 0091 } 0092 0093 #endif 0094 0095 // kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on; auto-insert-doxygen on