1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef HIGHLIGHTDEFINITIONHANDLER_H
35 #define HIGHLIGHTDEFINITIONHANDLER_H
37 #include <QtCore/QString>
38 #include <QtCore/QList>
39 #include <QtCore/QSharedPointer>
40 #include <QtCore/QStack>
42 #include <QtXml/QXmlDefaultHandler>
44 namespace TextEditor {
50 class HighlightDefinition;
52 class HighlightDefinitionHandler : public QXmlDefaultHandler
55 HighlightDefinitionHandler(const QSharedPointer<HighlightDefinition> &definition);
56 ~HighlightDefinitionHandler();
60 bool startElement(const QString &namespaceURI, const QString &localName,
61 const QString &qName, const QXmlAttributes &atts);
62 bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
63 bool characters(const QString &ch);
66 void listElementStarted(const QXmlAttributes &atts);
67 void itemElementStarted();
68 void contextElementStarted(const QXmlAttributes &atts);
69 void itemDataElementStarted(const QXmlAttributes &atts) const;
70 void commentElementStarted(const QXmlAttributes &atts) const;
71 void keywordsElementStarted(const QXmlAttributes &atts) const;
72 void foldingElementStarted(const QXmlAttributes &atts) const;
73 void ruleElementStarted(const QXmlAttributes &atts, const QSharedPointer<Rule> &rule);
76 void detectCharStarted(const QXmlAttributes &atts);
77 void detect2CharsStarted(const QXmlAttributes &atts);
78 void anyCharStarted(const QXmlAttributes &atts);
79 void stringDetectedStarted(const QXmlAttributes &atts);
80 void regExprStarted(const QXmlAttributes &atts);
81 void keywordStarted(const QXmlAttributes &atts);
82 void intStarted(const QXmlAttributes &atts);
83 void floatStarted(const QXmlAttributes &atts);
84 void hlCOctStarted(const QXmlAttributes &atts);
85 void hlCHexStarted(const QXmlAttributes &atts);
86 void hlCStringCharStarted(const QXmlAttributes &atts);
87 void hlCCharStarted(const QXmlAttributes &atts);
88 void rangeDetectStarted(const QXmlAttributes &atts);
89 void lineContinue(const QXmlAttributes &atts);
90 void includeRulesStarted(const QXmlAttributes &atts);
91 void detectSpacesStarted(const QXmlAttributes &atts);
92 void detectIdentifier(const QXmlAttributes &atts);
94 void processIncludeRules() const;
95 void processIncludeRules(const QSharedPointer<Context> &context) const;
97 QSharedPointer<HighlightDefinition> m_definition;
99 bool m_processingKeyword;
100 QString m_currentKeyword;
101 QSharedPointer<KeywordList> m_currentList;
102 QSharedPointer<Context> m_currentContext;
103 QStack<QSharedPointer<Rule> > m_currentRule;
105 bool m_initialContext;
108 } // namespace Internal
109 } // namespace TextEditor
111 #endif // HIGHLIGHTDEFINITIONHANDLER_H